-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
296 additions
and
20 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
'use client'; | ||
|
||
export default function Home() { | ||
return <div>哈哈qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq哈</div>; | ||
return <div className="">哈哈qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq哈</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
const Content = ({ children }: PropsWithChildren) => { | ||
return <main className="relative z-[1] px-4 pt-[4.5rem] fill-content md:px-0">{children}</main>; | ||
}; | ||
|
||
export default Content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Content from './Content'; | ||
export default Content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ThemeSwitcher from '@/components/ui/ThemeSwitcher'; | ||
|
||
const Footer = () => { | ||
return ( | ||
<footer | ||
data-hide-print | ||
className="relative z-[1] h-40 mt-32 border-t border-x-uk-separator-opaque-light py-6 text-base-content/80 dark:border-white/10" | ||
> | ||
<div className="px-4 sm:px-8 h-full"> | ||
<div className="relative mx-auto max-w-7xl lg:px-8 h-full"> | ||
<div className="mt-6 block text-center md:absolute md:bottom-0 md:right-0 md:mt-0"> | ||
<ThemeSwitcher></ThemeSwitcher> | ||
</div> | ||
</div> | ||
</div> | ||
</footer> | ||
); | ||
}; | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Footer from './Footer'; | ||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
// import { ClientOnly } from '~/components/common/ClientOnly'; | ||
|
||
import Content from '../Content'; | ||
import Footer from '../Footer'; | ||
// import { Header } from '../Header'; | ||
|
||
const Root = ({ children }: PropsWithChildren) => { | ||
return ( | ||
<> | ||
{/* <Header /> */} | ||
<Content>{children}</Content> | ||
|
||
<Footer /> | ||
{/* <ClientOnly> | ||
<FABContainer /> | ||
</ClientOnly> */} | ||
</> | ||
); | ||
}; | ||
|
||
export default Root; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Root from './Root'; | ||
export default Root; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
'use client'; | ||
|
||
import { useTheme } from 'next-themes'; | ||
import { flushSync } from 'react-dom'; | ||
import { tv } from 'tailwind-variants'; | ||
|
||
import useIsClient from '@/hooks/common/use-is-client'; | ||
import transitionViewIfSupported from '@/lib/transitionViewIfSupported'; | ||
|
||
const styles = tv({ | ||
base: 'rounded-inherit inline-flex h-[32px] w-[32px] items-center justify-center border-0 text-current', | ||
variants: { | ||
status: { | ||
active: '', | ||
}, | ||
}, | ||
}); | ||
|
||
const iconClassNames = 'h-4 w-4 text-current'; | ||
|
||
const SunIcon = () => { | ||
return ( | ||
<svg | ||
className={iconClassNames} | ||
fill="none" | ||
height="24" | ||
shapeRendering="geometricPrecision" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="1.5" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
> | ||
<circle cx="12" cy="12" r="5" /> | ||
<path d="M12 1v2" /> | ||
<path d="M12 21v2" /> | ||
<path d="M4.22 4.22l1.42 1.42" /> | ||
<path d="M18.36 18.36l1.42 1.42" /> | ||
<path d="M1 12h2" /> | ||
<path d="M21 12h2" /> | ||
<path d="M4.22 19.78l1.42-1.42" /> | ||
<path d="M18.36 5.64l1.42-1.42" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
const SystemIcon = () => { | ||
return ( | ||
<svg | ||
className={iconClassNames} | ||
fill="none" | ||
height="24" | ||
shapeRendering="geometricPrecision" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="1.5" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
> | ||
<rect x="2" y="3" width="20" height="14" rx="2" ry="2" /> | ||
<path d="M8 21h8" /> | ||
<path d="M12 17v4" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
const DarkIcon = () => { | ||
return ( | ||
<svg | ||
fill="none" | ||
height="24" | ||
shapeRendering="geometricPrecision" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="1.5" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
className={iconClassNames} | ||
> | ||
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" /> | ||
</svg> | ||
); | ||
}; | ||
|
||
const ThemeSwitcher = () => { | ||
return ( | ||
<div className="relative inline-block"> | ||
<ThemeIndicator /> | ||
<ButtonGroup /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ThemeSwitcher; | ||
|
||
const ThemeIndicator = () => { | ||
const { theme } = useTheme(); | ||
const isClient = useIsClient(); | ||
|
||
if (!theme) return null; | ||
if (!isClient) return null; | ||
|
||
return ( | ||
<div | ||
className="absolute top-[4px] z-[-1] size-[32px] rounded-full bg-base-100 shadow-[0_1px_2px_0_rgba(127.5,127.5,127.5,.2),_0_1px_3px_0_rgba(127.5,127.5,127.5,.1)] duration-200" | ||
style={{ | ||
left: { light: 4, system: 36, dark: 68 }[theme], | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
const ButtonGroup = () => { | ||
const { setTheme } = useTheme(); | ||
|
||
const buildThemeTransition = (theme: 'light' | 'dark' | 'system') => { | ||
transitionViewIfSupported(() => flushSync(() => setTheme(theme))); | ||
}; | ||
|
||
return ( | ||
<div className="w-fit-content inline-flex rounded-full border border-zinc-200 p-[3px] dark:border-zinc-700"> | ||
<button | ||
aria-label="Switch to light theme" | ||
type="button" | ||
className={styles.base} | ||
onClick={() => { | ||
buildThemeTransition('light'); | ||
}} | ||
> | ||
<SunIcon /> | ||
</button> | ||
<button | ||
aria-label="Switch to system theme" | ||
className={styles.base} | ||
type="button" | ||
onClick={() => { | ||
buildThemeTransition('system'); | ||
}} | ||
> | ||
<SystemIcon /> | ||
</button> | ||
<button | ||
aria-label="Switch to dark theme" | ||
className={styles.base} | ||
type="button" | ||
onClick={() => { | ||
buildThemeTransition('dark'); | ||
}} | ||
> | ||
<DarkIcon /> | ||
</button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ThemeSwitcher from './ThemeSwitcher'; | ||
|
||
export default ThemeSwitcher; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
const useIsClient = () => { | ||
const [isClient, setIsClient] = useState(false); | ||
|
||
useEffect(() => { | ||
setIsClient(true); | ||
}, []); | ||
|
||
return isClient; | ||
}; | ||
|
||
export default useIsClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const transitionViewIfSupported = (updateCb: () => any) => { | ||
if (window.matchMedia(`(prefers-reduced-motion: reduce)`).matches) { | ||
updateCb(); | ||
|
||
return; | ||
} | ||
|
||
if (document.startViewTransition) { | ||
document.startViewTransition(updateCb); | ||
} else { | ||
updateCb(); | ||
} | ||
}; | ||
|
||
export default transitionViewIfSupported; | ||
|
||
declare global { | ||
interface Document { | ||
startViewTransition: (cb: any) => void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters