1 import { c } from 'ttag';
3 import { ButtonLike } from '@proton/atoms';
4 import DropdownMenu from '@proton/components/components/dropdown/DropdownMenu';
5 import DropdownMenuButton from '@proton/components/components/dropdown/DropdownMenuButton';
6 import SimpleDropdown from '@proton/components/components/dropdown/SimpleDropdown';
7 import { DropdownSizeUnit } from '@proton/components/components/dropdown/utils';
8 import Icon from '@proton/components/components/icon/Icon';
9 import type { ThemeTypes } from '@proton/shared/lib/themes/themes';
10 import { PROTON_THEMES_MAP } from '@proton/shared/lib/themes/themes';
11 import clsx from '@proton/utils/clsx';
13 import ThemeCard from '../../containers/themes/ThemeCard';
14 import type { Theme } from './ThemeCards';
17 mode: 'light' | 'dark';
20 themeIdentifier: ThemeTypes;
22 onChange: (themeType: ThemeTypes) => void;
26 const ThemeSyncModeDropdown = ({ mode, className, themeIdentifier, list, onChange }: Props) => {
27 const dropdownButtonContent = (
29 <span className="w-custom" style={{ '--w-custom': '2.75rem' }}>
31 label={PROTON_THEMES_MAP[themeIdentifier].label}
32 id={`id_${PROTON_THEMES_MAP[themeIdentifier].identifier}`}
34 colors={PROTON_THEMES_MAP[themeIdentifier].thumbColors}
36 className="rounded-sm"
39 <span className="flex-1">{PROTON_THEMES_MAP[themeIdentifier].label}</span>
44 <div className={clsx('', className)}>
45 <div className={clsx('flex justify-space-between flex-nowrap gap-2 mb-2')}>
46 <div className="flex items-center flex-nowrap gap-2 text-sm">
47 <Icon name={mode === 'light' ? 'sun' : 'moon'} className={clsx('color-weak shrink-0')} />
48 <span className="color-weak">
49 {mode === 'light' ? c('Title').t`Day theme` : c('Title').t`Night theme`}
58 originalPlacement="bottom"
59 dropdownClassName="quickSettingsThemeDropdown"
60 content={dropdownButtonContent}
62 size: { width: DropdownSizeUnit.Anchor, height: DropdownSizeUnit.Dynamic, maxHeight: '10rem' },
64 className={clsx('w-full flex flex-nowrap justify-space-between p-2 gap-3 text-left', className)}
67 {list.map(({ identifier, label, thumbColors }) => {
68 const id = `id_${identifier}`;
72 isSelected={themeIdentifier === identifier}
73 className={clsx('flex flex-nowrap items-center gap-3')}
74 onClick={() => onChange(identifier)}
76 <span className="w-custom" style={{ '--w-custom': '2.75rem' }}>
82 selected={themeIdentifier === identifier}
87 themeIdentifier === identifier ? 'border-primary' : 'border-weak'
89 data-testid={`theme-card:theme-${label}`}
92 <span className="">{label}</span>
102 export default ThemeSyncModeDropdown;