import { Divider } from 'components/divider'; import { Col, Container, Row } from 'components/layout'; import { Radio } from 'components/radio'; import { Text } from 'components/text'; import { Visible } from 'components/visible'; import { useTheme } from 'hooks'; import { useCallback } from 'react'; import { Sample } from './sample/Sample'; export const Theme = () => { const { themeMode, updateThemeMode } = useTheme(); const preferences = [ { id: 1, title: 'Sync with OS settings', variant: 'light', theme: null, caption: 'Automatically switch between light and dark themes when your system does.', }, { id: 2, title: 'Light', variant: 'light', theme: 'light', caption: 'Automatically switch between light and dark themes when your system does.', }, { id: 3, title: 'Dark', variant: 'dark', theme: 'dark', caption: 'Automatically switch between light and dark themes when your system does.', }, ]; const isActive = useCallback( (currentThemeMode) => { return currentThemeMode === themeMode; }, [themeMode] ); const handleThemeChange = useCallback( (newTheme) => { updateThemeMode(newTheme); }, [updateThemeMode] ); return ( {preferences.map(({ title, id, caption, theme, variant }) => { return ( handleThemeChange(null)} isActive={isActive(null)} sizeVariant="extra-small" colorVariant="title" rightElement={ {title} {caption} } /> ); })} ); };