2023-10-23 00:46:28 +00:00
|
|
|
import { ColorPicker, Stack } from '@mantine/core';
|
|
|
|
|
import { Switch, Select, Text } from '/@/renderer/components';
|
2023-03-30 06:44:33 -07:00
|
|
|
import {
|
2023-07-01 19:10:05 -07:00
|
|
|
SettingsSection,
|
|
|
|
|
SettingOption,
|
2023-03-30 06:44:33 -07:00
|
|
|
} from '/@/renderer/features/settings/components/settings-section';
|
|
|
|
|
import { THEME_DATA } from '/@/renderer/hooks';
|
|
|
|
|
import { useGeneralSettings, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
|
|
|
|
import { AppTheme } from '/@/renderer/themes/types';
|
2023-10-30 19:22:45 -07:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-03-30 06:44:33 -07:00
|
|
|
|
|
|
|
|
export const ThemeSettings = () => {
|
2023-10-30 19:22:45 -07:00
|
|
|
const { t } = useTranslation();
|
2023-07-01 19:10:05 -07:00
|
|
|
const settings = useGeneralSettings();
|
|
|
|
|
const { setSettings } = useSettingsStoreActions();
|
2023-03-30 06:44:33 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const themeOptions: SettingOption[] = [
|
|
|
|
|
{
|
|
|
|
|
control: (
|
|
|
|
|
<Switch
|
|
|
|
|
defaultChecked={settings.followSystemTheme}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setSettings({
|
|
|
|
|
general: {
|
|
|
|
|
...settings,
|
|
|
|
|
followSystemTheme: e.currentTarget.checked,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
),
|
2023-10-30 19:22:45 -07:00
|
|
|
description: t('setting.useSystemTheme', {
|
|
|
|
|
context: 'description',
|
|
|
|
|
postProcess: 'sentenceCase',
|
|
|
|
|
}),
|
2023-07-01 19:10:05 -07:00
|
|
|
isHidden: false,
|
2023-10-30 19:22:45 -07:00
|
|
|
title: t('setting.useSystemTheme', { postProcess: 'sentenceCase' }),
|
2023-07-01 19:10:05 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
control: (
|
|
|
|
|
<Select
|
|
|
|
|
data={THEME_DATA}
|
|
|
|
|
defaultValue={settings.theme}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setSettings({
|
|
|
|
|
general: {
|
|
|
|
|
...settings,
|
|
|
|
|
theme: e as AppTheme,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
),
|
2023-10-30 19:22:45 -07:00
|
|
|
description: t('setting.theme', {
|
|
|
|
|
context: 'description',
|
|
|
|
|
postProcess: 'sentenceCase',
|
|
|
|
|
}),
|
2023-07-01 19:10:05 -07:00
|
|
|
isHidden: settings.followSystemTheme,
|
2023-10-30 19:22:45 -07:00
|
|
|
title: t('setting.theme', { postProcess: 'sentenceCase' }),
|
2023-07-01 19:10:05 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
control: (
|
|
|
|
|
<Select
|
|
|
|
|
data={THEME_DATA}
|
|
|
|
|
defaultValue={settings.themeDark}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setSettings({
|
|
|
|
|
general: {
|
|
|
|
|
...settings,
|
|
|
|
|
themeDark: e as AppTheme,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
),
|
2023-10-30 19:22:45 -07:00
|
|
|
description: t('setting.themeDark', {
|
|
|
|
|
context: 'description',
|
|
|
|
|
postProcess: 'sentenceCase',
|
|
|
|
|
}),
|
2023-07-01 19:10:05 -07:00
|
|
|
isHidden: !settings.followSystemTheme,
|
2023-10-30 19:22:45 -07:00
|
|
|
title: t('setting.themeDark', { postProcess: 'sentenceCase' }),
|
2023-07-01 19:10:05 -07:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
control: (
|
|
|
|
|
<Select
|
|
|
|
|
data={THEME_DATA}
|
|
|
|
|
defaultValue={settings.themeLight}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setSettings({
|
|
|
|
|
general: {
|
|
|
|
|
...settings,
|
|
|
|
|
themeLight: e as AppTheme,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
),
|
2023-10-30 19:22:45 -07:00
|
|
|
description: t('setting.themeLight', {
|
|
|
|
|
context: 'description',
|
|
|
|
|
postProcess: 'sentenceCase',
|
|
|
|
|
}),
|
2023-07-01 19:10:05 -07:00
|
|
|
isHidden: !settings.followSystemTheme,
|
2023-10-30 19:22:45 -07:00
|
|
|
title: t('setting.themeLight', { postProcess: 'sentenceCase' }),
|
2023-07-01 19:10:05 -07:00
|
|
|
},
|
2023-10-23 00:46:28 +00:00
|
|
|
{
|
|
|
|
|
control: (
|
|
|
|
|
<Stack align="center">
|
|
|
|
|
<ColorPicker
|
|
|
|
|
defaultValue={settings.accent}
|
|
|
|
|
format="rgb"
|
|
|
|
|
swatches={[
|
|
|
|
|
'rgb(53, 116, 252)',
|
|
|
|
|
'rgb(240, 170, 22)',
|
|
|
|
|
'rgb(29, 185, 84)',
|
|
|
|
|
'rgb(214, 81, 63)',
|
|
|
|
|
'rgb(170, 110, 216)',
|
|
|
|
|
]}
|
|
|
|
|
swatchesPerRow={5}
|
|
|
|
|
onChangeEnd={(e) => {
|
|
|
|
|
setSettings({
|
|
|
|
|
general: {
|
|
|
|
|
...settings,
|
|
|
|
|
accent: e,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Text>{settings.accent}</Text>
|
|
|
|
|
</Stack>
|
|
|
|
|
),
|
2023-10-30 19:22:45 -07:00
|
|
|
description: t('setting.accentColor', {
|
|
|
|
|
context: 'description',
|
|
|
|
|
postProcess: 'sentenceCase',
|
|
|
|
|
}),
|
|
|
|
|
title: t('setting.accentColor', { postProcess: 'sentenceCase' }),
|
2023-10-23 00:46:28 +00:00
|
|
|
},
|
2023-07-01 19:10:05 -07:00
|
|
|
];
|
2023-03-30 06:44:33 -07:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return <SettingsSection options={themeOptions} />;
|
2023-03-30 06:44:33 -07:00
|
|
|
};
|