From b39633c7361f1bf9bab87d7fc0eb887fc64caccb Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Sat, 29 Apr 2023 21:46:21 +0600 Subject: [PATCH] filled default light and dark theme --- public/locales/en/translation.json | 7 +- public/locales/ru/translation.json | 7 +- .../containers/ColorSettings/index.tsx | 77 +++++++++++++++---- src/modules/theme/constants/theme.ts | 24 +++--- src/modules/theme/utils/fillThemeHeadings.ts | 10 +++ 5 files changed, 95 insertions(+), 30 deletions(-) create mode 100644 src/modules/theme/utils/fillThemeHeadings.ts diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index a4dc99d..8499b3f 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -16,5 +16,10 @@ "Light theme": "Light theme", "Blueberry boar": "Blueberry boar", "User defined theme": "User defined", - "Built-in theme": "Built-in" + "Built-in theme": "Built-in", + "Heading 1": "Heading 1", + "Heading 2": "Heading 2", + "Heading 3": "Heading 3", + "Heading 4": "Heading 4", + "Heading 5": "Heading 5" } diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 956cffd..beaf3c8 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -16,5 +16,10 @@ "Light theme": "Светлая", "Blueberry boar": "Черничный кабанчик", "User defined theme": "Пользовательская", - "Built-in theme": "Встроенная" + "Built-in theme": "Встроенная", + "Heading 1": "Заголовок 1", + "Heading 2": "Заголовок 2", + "Heading 3": "Заголовок 3", + "Heading 4": "Заголовок 4", + "Heading 5": "Заголовок 5" } diff --git a/src/modules/settings/containers/ColorSettings/index.tsx b/src/modules/settings/containers/ColorSettings/index.tsx index a113394..b93fc94 100644 --- a/src/modules/settings/containers/ColorSettings/index.tsx +++ b/src/modules/settings/containers/ColorSettings/index.tsx @@ -7,14 +7,13 @@ import { SettingsValue, useSettings, } from "~/modules/settings/context/SettingsContext"; -import { ThemeSelect } from "../../components/ThemeSelect"; import { useBuiltinThemes } from "~/modules/theme/constants/themes"; -import { useDefaultTheme } from "~/modules/theme/hooks/useDefaultTheme"; +import { fillThemeHeadings } from "~/modules/theme/utils/fillThemeHeadings"; +import { ThemeSelect } from "../../components/ThemeSelect"; const ColorSettings: FC = () => { const { update, settings } = useSettings(); const { t } = useTranslation(); - const defaultColors = useDefaultTheme(); const setString = useCallback( (field: keyof SettingsValue) => (event: ChangeEvent) => { @@ -28,19 +27,19 @@ const ColorSettings: FC = () => { const currentTheme = useMemo( () => themes.find((it) => - Object.entries({ ...defaultColors, ...it.colors }).every( + Object.entries(fillThemeHeadings(it.colors)).every( ([key, value]) => (settings as unknown as Record)[key] === value ) ), - [themes, defaultColors, settings] + [themes, settings] ); const setThemeColors = useCallback( (val: ColorSettings) => { - update({ ...defaultColors, ...val }); + update(fillThemeHeadings(val)); }, - [defaultColors, update] + [update] ); const themeSubtitle = useMemo(() => { @@ -57,7 +56,7 @@ const ColorSettings: FC = () => { return ( - ); }; diff --git a/src/modules/theme/constants/theme.ts b/src/modules/theme/constants/theme.ts index b6a8bda..9ce6138 100644 --- a/src/modules/theme/constants/theme.ts +++ b/src/modules/theme/constants/theme.ts @@ -10,21 +10,21 @@ export const defaultDarkTheme: ColorSettings = { textColor: "#eeeeee", linkColor: "#25bfe6", codeColor: "#ff3344", - h1Color: "", - h2Color: "", - h3Color: "", - h4Color: "", - h5Color: "", + h1Color: "#f66151", + h2Color: "#ffbe6f", + h3Color: "#f9f06b", + h4Color: "#8ff0a4", + h5Color: "#99c1f1", }; export const defaultLightTheme: ColorSettings = { - backgroundColor: "#eeeeee", + backgroundColor: "#deddda", textColor: "#2e2e2e", - linkColor: "#25bfe6", + linkColor: "#1c71d8", codeColor: "#ff3344", - h1Color: "", - h2Color: "", - h3Color: "", - h4Color: "", - h5Color: "", + h1Color: "#6b5554", + h2Color: "#4f403f", + h3Color: "#3d302f", + h4Color: "#2e2625", + h5Color: "#2c2322", }; diff --git a/src/modules/theme/utils/fillThemeHeadings.ts b/src/modules/theme/utils/fillThemeHeadings.ts new file mode 100644 index 0000000..c1c73eb --- /dev/null +++ b/src/modules/theme/utils/fillThemeHeadings.ts @@ -0,0 +1,10 @@ +import { ColorSettings } from "~/modules/settings/context/SettingsContext"; + +export const fillThemeHeadings = (theme: ColorSettings): ColorSettings => ({ + ...theme, + h1Color: theme.h1Color || theme.textColor, + h2Color: theme.h2Color || theme.textColor, + h3Color: theme.h3Color || theme.textColor, + h4Color: theme.h4Color || theme.textColor, + h5Color: theme.h5Color || theme.textColor, +});