1 import { c } from 'ttag';
3 import Info from '@proton/components/components/link/Info';
4 import Toggle from '@proton/components/components/toggle/Toggle';
5 import SettingsLayout from '@proton/components/containers/account/SettingsLayout';
6 import SettingsLayoutLeft from '@proton/components/containers/account/SettingsLayoutLeft';
7 import SettingsLayoutRight from '@proton/components/containers/account/SettingsLayoutRight';
8 import SettingsParagraph from '@proton/components/containers/account/SettingsParagraph';
9 import SettingsSectionWide from '@proton/components/containers/account/SettingsSectionWide';
10 import useNotifications from '@proton/components/hooks/useNotifications';
11 import { BRAND_NAME } from '@proton/shared/lib/constants';
12 import { ColorScheme, ThemeModeSetting, getThemes } from '@proton/shared/lib/themes/themes';
14 import ThemeCards from './ThemeCards';
15 import { useTheme } from './ThemeProvider';
16 import ThemeSyncModeCard from './ThemeSyncModeCard';
18 const ThemesSection = () => {
19 const { information, settings, setTheme, setAutoTheme } = useTheme();
21 const { createNotification } = useNotifications();
22 const notifyPreferenceSaved = () => createNotification({ text: c('Success').t`Preference saved` });
24 const themes = getThemes();
29 <SettingsParagraph>{c('Info')
30 .t`Customize the look and feel of ${BRAND_NAME} applications.`}</SettingsParagraph>
31 </SettingsSectionWide>
35 <label htmlFor="themeSyncToggle" className="text-semibold">
36 <span className="mr-2">{c('Label').t`Sync with system`}</span>
39 .t`Automatically switch between your preferred themes for day and night in sync with your system’s day and night modes`}
43 <SettingsLayoutRight isToggleContainer>
46 checked={settings.Mode === ThemeModeSetting.Auto}
48 setAutoTheme(e.target.checked);
49 notifyPreferenceSaved();
52 </SettingsLayoutRight>
55 {settings.Mode === ThemeModeSetting.Auto ? (
56 <SettingsSectionWide className="flex mt-6 flex-nowrap gap-4 flex-column lg:flex-row">
61 themeIdentifier={settings.LightTheme}
62 onChange={(themeType) => {
63 setTheme(themeType, ThemeModeSetting.Light);
64 notifyPreferenceSaved();
66 active={information.colorScheme === ColorScheme.Light}
72 themeIdentifier={settings.DarkTheme}
73 onChange={(themeType) => {
74 setTheme(themeType, ThemeModeSetting.Dark);
75 notifyPreferenceSaved();
77 active={information.colorScheme === ColorScheme.Dark}
79 </SettingsSectionWide>
81 <SettingsSectionWide className="mt-6">
85 themeIdentifier={information.theme}
86 onChange={(themeType) => {
88 notifyPreferenceSaved();
91 </SettingsSectionWide>
97 export default ThemesSection;