test refactor
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import DarkModeOutlinedIcon from '@mui/icons-material/DarkModeOutlined'
|
||||
import LightModeOutlinedIcon from '@mui/icons-material/LightModeOutlined'
|
||||
import IconButton from '@mui/material/IconButton'
|
||||
import Tooltip from '@mui/material/Tooltip'
|
||||
import type { ThemeModePreference } from '@/shared/model/theme'
|
||||
|
||||
type Props = {
|
||||
mode: ThemeModePreference
|
||||
resolvedMode: 'light' | 'dark'
|
||||
onCycleMode: () => void
|
||||
}
|
||||
|
||||
function getModeLabel(mode: ThemeModePreference, resolvedMode: 'light' | 'dark'): string {
|
||||
switch (mode) {
|
||||
case 'system':
|
||||
return `Авто (${resolvedMode === 'dark' ? 'тёмная' : 'светлая'})`
|
||||
case 'light':
|
||||
return 'Светлая'
|
||||
case 'dark':
|
||||
return 'Тёмная'
|
||||
}
|
||||
}
|
||||
|
||||
export function ModeSwitcher({ mode, resolvedMode, onCycleMode }: Props) {
|
||||
return (
|
||||
<Tooltip title={`Тема: ${getModeLabel(mode, resolvedMode)}`}>
|
||||
<IconButton color="inherit" onClick={onCycleMode} aria-label="Переключить тему">
|
||||
{resolvedMode === 'dark' ? <LightModeOutlinedIcon /> : <DarkModeOutlinedIcon />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { ModeSwitcher } from './ModeSwitcher'
|
||||
Reference in New Issue
Block a user