mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 15:35:35 +00:00
feat: add layout transition
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
export const PREFER_DARK_THEME = 'prefer_dark_theme';
|
export const PREFER_DARK_THEME = 'prefer_dark_theme';
|
||||||
|
export const DARK_THEME_DEFAULT_VALUE = true;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { PREFER_DARK_THEME } from '#constants/session';
|
import { PREFER_DARK_THEME } from '#constants/session';
|
||||||
import { updateUserThemeValidator } from '#validators/user_theme';
|
import { updateUserThemeValidator } from '#validators/user';
|
||||||
import type { HttpContext } from '@adonisjs/core/http';
|
import type { HttpContext } from '@adonisjs/core/http';
|
||||||
|
|
||||||
export default class AppsController {
|
export default class AppsController {
|
||||||
|
|||||||
8
inertia/components/layouts/_transition_layout.tsx
Normal file
8
inertia/components/layouts/_transition_layout.tsx
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import styled from '@emotion/styled';
|
||||||
|
import { fadeInScale } from '~/styles/keyframes';
|
||||||
|
|
||||||
|
const TransitionLayout = styled.div(({ theme }) => ({
|
||||||
|
animation: `${theme.transition.delay} ${fadeInScale} both`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
export default TransitionLayout;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import Footer from '~/components/footer/footer';
|
import Footer from '~/components/footer/footer';
|
||||||
|
import TransitionLayout from '~/components/layouts/_transition_layout';
|
||||||
import Navbar from '../navbar/navbar';
|
import Navbar from '../navbar/navbar';
|
||||||
import BaseLayout from './_base_layout';
|
import BaseLayout from './_base_layout';
|
||||||
|
|
||||||
const ContentLayoutStyle = styled.div(({ theme }) => ({
|
const ContentLayoutStyle = styled(TransitionLayout)(({ theme }) => ({
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: theme.media.small_desktop,
|
width: theme.media.small_desktop,
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
import TransitionLayout from '~/components/layouts/_transition_layout';
|
||||||
import BaseLayout from './_base_layout';
|
import BaseLayout from './_base_layout';
|
||||||
|
|
||||||
const DashboardLayoutStyle = styled.div(({ theme }) => ({
|
const DashboardLayoutStyle = styled(TransitionLayout)(({ theme }) => ({
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: theme.media.medium_desktop,
|
width: theme.media.medium_desktop,
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { usePage } from '@inertiajs/react';
|
import { usePage } from '@inertiajs/react';
|
||||||
|
import { route } from '@izzyjs/route/client';
|
||||||
import { ReactNode, createContext, useEffect, useState } from 'react';
|
import { ReactNode, createContext, useEffect, useState } from 'react';
|
||||||
import { makeRequest } from '~/lib/request';
|
import { makeRequest } from '~/lib/request';
|
||||||
|
|
||||||
@@ -18,9 +19,10 @@ export default function DarkThemeContextProvider({
|
|||||||
const [isDarkTheme, setDarkTheme] = useState<boolean>(preferDarkTheme);
|
const [isDarkTheme, setDarkTheme] = useState<boolean>(preferDarkTheme);
|
||||||
const toggleDarkTheme = (value: boolean) => {
|
const toggleDarkTheme = (value: boolean) => {
|
||||||
setDarkTheme(value);
|
setDarkTheme(value);
|
||||||
|
const { method, url } = route('user.theme');
|
||||||
makeRequest({
|
makeRequest({
|
||||||
method: 'POST',
|
method,
|
||||||
url: '/user/theme',
|
url,
|
||||||
body: {
|
body: {
|
||||||
preferDarkTheme: value,
|
preferDarkTheme: value,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap');
|
|
||||||
|
|
||||||
* {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
|
||||||
body,
|
|
||||||
#app {
|
|
||||||
background-color: #f7f8fa;
|
|
||||||
font-family: 'Poppins', sans-serif;
|
|
||||||
color: #46444c;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 42px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #5a45ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
text-decoration: underline;
|
|
||||||
color: #5a45ff;
|
|
||||||
}
|
|
||||||
@@ -17,3 +17,14 @@ export const rotate = keyframes({
|
|||||||
transform: 'rotate(360deg)',
|
transform: 'rotate(360deg)',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const fadeInScale = keyframes({
|
||||||
|
from: {
|
||||||
|
opacity: 0,
|
||||||
|
transform: 'scale(0.95)',
|
||||||
|
},
|
||||||
|
to: {
|
||||||
|
opacity: 1,
|
||||||
|
transform: 'scale(1)',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user