feat: add font style setting (#3092)

(cherry picked from commit b12412a3c1)
This commit is contained in:
Qi
2023-07-07 19:59:38 +08:00
committed by Alex Yang
parent a41d9c0ac2
commit 9ef492f5f8
5 changed files with 67 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import { useCallback } from 'react';
import {
type AppSetting,
fontStyleOptions,
useAppSetting,
windowFrameStyleOptions,
} from '../../../../../atoms/settings';
@@ -48,6 +49,46 @@ export const ThemeSettings = () => {
);
};
const FontFamilySettings = () => {
const [appSettings, setAppSettings] = useAppSetting();
return (
<RadioButtonGroup
width={250}
className={settingWrapper}
defaultValue={appSettings.fontStyle}
onValueChange={useCallback(
(key: AppSetting['fontStyle']) => {
const value = fontStyleOptions.find(option => option.key === key)
?.value;
setAppSettings({ fontStyle: key });
document
.querySelector('html')
?.style.setProperty('--affine-font-family', value || null);
},
[setAppSettings]
)}
>
{fontStyleOptions.map(({ key, value }) => {
return (
<RadioButton
key={key}
bold={true}
value={key}
data-testid="system-font-style-trigger"
style={{
fontFamily: value,
}}
>
{key}
</RadioButton>
);
})}
</RadioButtonGroup>
);
};
export const AppearanceSettings = () => {
const t = useAFFiNEI18N();
@@ -72,6 +113,12 @@ export const AppearanceSettings = () => {
>
<ThemeSettings />
</SettingRow>
<SettingRow
name={t['Font Style']()}
desc={t['Choose your font style']()}
>
<FontFamilySettings />
</SettingRow>
<SettingRow
name={t['Display Language']()}
desc={t['Select the language for the interface.']()}