mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 12:30:12 +02:00
Add light/dark type to theme
This commit is contained in:
@@ -31,7 +31,7 @@ export const App = () => {
|
||||
withGlobalStyles
|
||||
withNormalizeCSS
|
||||
theme={{
|
||||
colorScheme: theme,
|
||||
colorScheme: theme as 'light' | 'dark',
|
||||
defaultRadius: 'xs',
|
||||
dir: 'ltr',
|
||||
focusRing: 'auto',
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import { Divider, Stack } from '@mantine/core';
|
||||
import { Switch, Select } from '@/renderer/components';
|
||||
import { SettingsOptions } from '@/renderer/features/settings/components/settings-option';
|
||||
import { THEME_DATA } from '@/renderer/hooks';
|
||||
import { useSettingsStore } from '@/renderer/store/settings.store';
|
||||
import { AppTheme } from '@/renderer/themes/types';
|
||||
|
||||
const THEME_OPTIONS = [
|
||||
{ label: 'Default Dark', value: AppTheme.DEFAULT_DARK },
|
||||
{ label: 'Default Light', value: AppTheme.DEFAULT_LIGHT },
|
||||
];
|
||||
|
||||
export const GeneralTab = () => {
|
||||
const settings = useSettingsStore((state) => state.general);
|
||||
const update = useSettingsStore((state) => state.setSettings);
|
||||
@@ -59,7 +55,7 @@ export const GeneralTab = () => {
|
||||
{
|
||||
control: (
|
||||
<Select
|
||||
data={THEME_OPTIONS}
|
||||
data={THEME_DATA}
|
||||
defaultValue={settings.theme}
|
||||
onChange={(e) => {
|
||||
update({
|
||||
@@ -78,7 +74,7 @@ export const GeneralTab = () => {
|
||||
{
|
||||
control: (
|
||||
<Select
|
||||
data={THEME_OPTIONS}
|
||||
data={THEME_DATA}
|
||||
defaultValue={settings.themeDark}
|
||||
onChange={(e) => {
|
||||
update({
|
||||
@@ -97,7 +93,7 @@ export const GeneralTab = () => {
|
||||
{
|
||||
control: (
|
||||
<Select
|
||||
data={THEME_OPTIONS}
|
||||
data={THEME_DATA}
|
||||
defaultValue={settings.themeLight}
|
||||
onChange={(e) => {
|
||||
update({
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useSettingsStore } from '@/renderer/store/settings.store';
|
||||
import { AppTheme } from '@/renderer/themes/types';
|
||||
|
||||
export const THEME_DATA = [
|
||||
{ label: 'Default dark', type: 'dark', value: AppTheme.DEFAULT_DARK },
|
||||
{ label: 'Default light', type: 'light', value: AppTheme.DEFAULT_LIGHT },
|
||||
];
|
||||
|
||||
export const useTheme = () => {
|
||||
const getCurrentTheme = () =>
|
||||
@@ -33,5 +39,5 @@ export const useTheme = () => {
|
||||
document.body.setAttribute('data-theme', appTheme);
|
||||
}, [appTheme]);
|
||||
|
||||
return isDarkTheme ? 'dark' : 'light';
|
||||
return THEME_DATA.find((t) => t.value === appTheme)?.type || 'dark';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user