From f57fbda2d65234d388593f7147a688e653f673ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96ZT=C3=9CRK?= <76204082+iamsedatozturk@users.noreply.github.com> Date: Fri, 27 Mar 2026 16:49:15 +0300 Subject: [PATCH] Theme Configuration --- .../Seeds/LanguagesData.json | 16 ++- .../ThemeConfigurator/LayoutSwitcher.tsx | 3 +- .../ThemeConfigurator/NavModeSwitcher.tsx | 28 +++-- .../ThemeConfigurator/StyleSwitcher.tsx | 113 ++++++++++++++++++ .../ThemeConfigurator/ThemeConfigurator.tsx | 76 ++++++------ ui/src/constants/theme.constant.ts | 4 +- ui/src/proxy/theme/models.ts | 1 + ui/src/proxy/theme/theme.config.ts | 5 +- ui/src/store/theme.model.ts | 68 +++-------- ui/src/views/admin/listForm/edit/options.ts | 101 ++++++++++++++++ ui/src/views/settings/Settings.tsx | 15 +-- 11 files changed, 315 insertions(+), 115 deletions(-) create mode 100644 ui/src/components/template/ThemeConfigurator/StyleSwitcher.tsx diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index f173874..25a54ac 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -5349,14 +5349,14 @@ { "resourceName": "Platform", "key": "SidePanel.Mode", - "en": "Mode", - "tr": "Mod" + "en": "Dark Mode", + "tr": "Karanlık Mod" }, { "resourceName": "Platform", "key": "SidePanel.Mode.Description", "en": "Switch theme to dark mode", - "tr": "Switch theme to dark mode" + "tr": "Tema karanlık moda geçiş yap" }, { "resourceName": "Platform", @@ -5373,8 +5373,8 @@ { "resourceName": "Platform", "key": "SidePanel.NavMode", - "en": "Nav Mode", - "tr": "Nav Mod" + "en": "Navigation Mode", + "tr": "Gezinme Modu" }, { "resourceName": "Platform", @@ -17796,6 +17796,12 @@ "key": "App.DeveloperKit.DynamicServices.Editor.CharCount", "en": "Char:", "tr": "Karakter:" + }, + { + "resourceName": "Platform", + "key": "SuccessfullySaved", + "en": "Successfully Saved", + "tr": "Başarıyla Kaydedildi" } ] } diff --git a/ui/src/components/template/ThemeConfigurator/LayoutSwitcher.tsx b/ui/src/components/template/ThemeConfigurator/LayoutSwitcher.tsx index 4b888c4..e4f920e 100644 --- a/ui/src/components/template/ThemeConfigurator/LayoutSwitcher.tsx +++ b/ui/src/components/template/ThemeConfigurator/LayoutSwitcher.tsx @@ -12,6 +12,7 @@ import { LAYOUT_TYPE_SIMPLE, LAYOUT_TYPE_DECKED, LAYOUT_TYPE_BLANK, + NAV_MODE_TRANSPARENT, } from '@/constants/theme.constant' import type { LayoutType } from '@/proxy/theme/models' import { useLocalization } from '@/utils/hooks/useLocalization' @@ -57,7 +58,7 @@ const layouts = [ const LayoutSwitcher = () => { const type = useStoreState((state) => state.theme.layout.type) - const { setLayout } = useStoreActions((actions) => actions.theme) + const { setLayout, setNavMode } = useStoreActions((actions) => actions.theme) const onLayoutSelect = (val: LayoutType) => { setLayout(val) diff --git a/ui/src/components/template/ThemeConfigurator/NavModeSwitcher.tsx b/ui/src/components/template/ThemeConfigurator/NavModeSwitcher.tsx index 3b640cc..71fcfbb 100644 --- a/ui/src/components/template/ThemeConfigurator/NavModeSwitcher.tsx +++ b/ui/src/components/template/ThemeConfigurator/NavModeSwitcher.tsx @@ -1,23 +1,31 @@ import Radio from '@/components/ui/Radio' import { useStoreState, useStoreActions } from '@/store' -import { NAV_MODE_THEMED } from '@/constants/theme.constant' - -type NavModeParam = 'default' | 'themed' +import { + NAV_MODE_DARK, + NAV_MODE_LIGHT, + NAV_MODE_THEMED, + NAV_MODE_TRANSPARENT, +} from '@/constants/theme.constant' +import { NavMode } from '@/proxy/theme/models' +import { availableNavColorLayouts } from '@/proxy/theme/theme.config' const NavModeSwitcher = () => { - const navMode = useStoreState((state) => state.theme.navMode) + const { navMode, layout } = useStoreState((state) => state.theme) const { setNavMode } = useStoreActions((actions) => actions.theme) - const onSetNavMode = (val: NavModeParam) => { + const onSetNavMode = (val: NavMode) => { setNavMode(val) } return ( - - Default + + Transparent + {!availableNavColorLayouts.includes(layout.type) && ( + <> + Light + Dark + + )} Themed ) diff --git a/ui/src/components/template/ThemeConfigurator/StyleSwitcher.tsx b/ui/src/components/template/ThemeConfigurator/StyleSwitcher.tsx new file mode 100644 index 0000000..d559067 --- /dev/null +++ b/ui/src/components/template/ThemeConfigurator/StyleSwitcher.tsx @@ -0,0 +1,113 @@ +import { HiCheck } from 'react-icons/hi' +import { components } from 'react-select' + +import { Select, toast } from '@/components/ui' +import { styleMapOptions } from '@/views/admin/listForm/edit/options' +import Notification from '@/components/ui/Notification' +import { useLocalization } from '@/utils/hooks/useLocalization' +import { useStoreActions, useStoreState } from '@/store' +import { updateSettingValues } from '@/services/setting-ui.service' +import React from 'react' + +const StyleSwitcher = () => { + const { translate } = useLocalization() + const { setMode, setStyle, abpConfig } = useStoreActions((actions) => ({ + setMode: actions.theme.setMode, + setStyle: actions.theme.setStyle, + abpConfig: actions.abpConfig.getConfig, + })) + const { style } = useStoreState((state) => state.theme) + + const onSetStyle = React.useCallback( + async (val: string) => { + setStyle(val) + setMode(val.includes('.dark') ? 'dark' : 'light') + const values: Record = { + App_SiteManagement_Theme_Style: val, + } + const resp = await updateSettingValues(values) + if (resp.status !== 204) { + toast.push(, { + placement: 'top-end', + }) + } + abpConfig(false) + }, + [setStyle, setMode, abpConfig, translate], + ) + + // Custom Option + const CustomSelectOption = ({ innerProps, label, data, isSelected }: any) => { + const { border, fill } = data.color + return ( +
+
+ + {label} +
+ {isSelected && } +
+ ) + } + + // Custom Control + const CustomControl = ({ children, ...props }: any) => { + const selected = props.getValue()[0] + const { border, fill } = selected?.color + return ( + + {selected ? ( +
+ +
+ ) : null} + {children} +
+ ) + } + + return ( +