* Copy the design-system app into a new one for ui-library. * Remove unneeded content. * Add supabase config. * Cleanup the css. * Add bunch of packages. * Cleanup the registry. * Regenerate the registry. * Add needed components for documenting components. * Add the pages for the components. * Fix the RegistryBlock. * Various fixes. * Add a turbo definition for ui-library. * Rename Remix to React Router. * Reorder the pages for all frameworks. * Remove the bottom pager. * Fix the pages and command menu. * Various fixes. * Minor fixes. * Add ai editor rules. * Various fixes. * Add local supabase env vars. * Try to fix a package error. * Bunch of various fixes. * Fix lint errors.
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
'use client'
|
|
|
|
import { useTheme } from 'next-themes'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import SVG from 'react-inlinesvg'
|
|
import { RadioGroupLargeItem_Shadcn_, RadioGroup_Shadcn_, Theme, singleThemes } from 'ui'
|
|
|
|
const ThemeSettings = () => {
|
|
const [mounted, setMounted] = useState(false)
|
|
const { theme, setTheme } = useTheme()
|
|
|
|
/**
|
|
* Avoid Hydration Mismatch
|
|
* https://github.com/pacocoursey/next-themes?tab=readme-ov-file#avoid-hydration-mismatch
|
|
*/
|
|
// useEffect only runs on the client, so now we can safely show the UI
|
|
useEffect(() => {
|
|
setMounted(true)
|
|
}, [])
|
|
|
|
if (!mounted) {
|
|
return null
|
|
}
|
|
|
|
function SingleThemeSelection() {
|
|
return (
|
|
<form className="py-8">
|
|
<RadioGroup_Shadcn_
|
|
name="theme"
|
|
onValueChange={setTheme}
|
|
aria-label="Choose a theme"
|
|
defaultValue={theme}
|
|
value={theme}
|
|
className="flex flex-wrap gap-3"
|
|
>
|
|
{singleThemes.map((theme: Theme) => (
|
|
<RadioGroupLargeItem_Shadcn_ key={theme.value} value={theme.value} label={theme.name}>
|
|
<SVG src={`${process.env.NEXT_PUBLIC_BASE_PATH}/img/themes/${theme.value}.svg`} />
|
|
</RadioGroupLargeItem_Shadcn_>
|
|
))}
|
|
</RadioGroup_Shadcn_>
|
|
</form>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<SingleThemeSelection />
|
|
</>
|
|
)
|
|
}
|
|
|
|
export { ThemeSettings }
|