'use client'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuRadioItemIndicator,
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useTheme } from 'next-themes'
import { useTranslation } from 'react-i18next'
const THEMES = ['light', 'dark', 'system'] as const
export type Theme = (typeof THEMES)[number]
const isTheme = (value: string): value is Theme => {
return (THEMES as readonly string[]).includes(value)
}
export default function ThemeSelector() {
const { t } = useTranslation()
const { theme, setTheme } = useTheme()
const currentTheme: Theme = theme && isTheme(theme) ? theme : 'system'
const getCurrentIcon = () => {
switch (theme) {
case 'light':
return
case 'dark':
return
default:
return
}
}
return (
$['theme.theme'], { ns: 'common' })}
size="lg"
className="data-popup-open:bg-state-base-hover"
>
{getCurrentIcon()}
}
/>
value={currentTheme}
onValueChange={(nextTheme) => setTheme(nextTheme)}
>
value="light" closeOnClick>
{t(($) => $['theme.light'], { ns: 'common' })}
value="dark" closeOnClick>
{t(($) => $['theme.dark'], { ns: 'common' })}
value="system" closeOnClick>
{t(($) => $['theme.auto'], { ns: 'common' })}
)
}