mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
fix primary color css variable to use new shade value
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import type { MantineThemeOverride } from '@mantine/core';
|
import type { MantineThemeOverride } from '@mantine/core';
|
||||||
|
|
||||||
|
import { generateColors } from '@mantine/colors-generator';
|
||||||
import { useMantineColorScheme } from '@mantine/core';
|
import { useMantineColorScheme } from '@mantine/core';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
@@ -177,8 +178,30 @@ export const useAppTheme = (overrideTheme?: AppTheme) => {
|
|||||||
const primaryColor = useThemeAccentColor
|
const primaryColor = useThemeAccentColor
|
||||||
? themeProperties.colors?.primary || themeProperties.colors?.['state-info'] || accent
|
? themeProperties.colors?.primary || themeProperties.colors?.['state-info'] || accent
|
||||||
: accent;
|
: accent;
|
||||||
root.style.setProperty('--theme-colors-primary', primaryColor);
|
const effectivePrimaryShade: MantineThemeOverride['primaryShade'] = useThemePrimaryShade
|
||||||
}, [accent, selectedTheme, useThemeAccentColor]);
|
? themeProperties.mantineOverride?.primaryShade
|
||||||
|
: ({ dark: primaryShade, light: primaryShade } as MantineThemeOverride['primaryShade']);
|
||||||
|
const mode = themeProperties.mode ?? (isDarkTheme ? 'dark' : 'light');
|
||||||
|
const shadeIndex = Math.min(
|
||||||
|
9,
|
||||||
|
Math.max(
|
||||||
|
0,
|
||||||
|
typeof effectivePrimaryShade === 'object'
|
||||||
|
? (effectivePrimaryShade?.[mode] ?? 6)
|
||||||
|
: (effectivePrimaryShade ?? 6),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const primaryScale = generateColors(primaryColor);
|
||||||
|
const primaryAtShade = primaryScale[shadeIndex];
|
||||||
|
root.style.setProperty('--theme-colors-primary', primaryAtShade);
|
||||||
|
}, [
|
||||||
|
accent,
|
||||||
|
isDarkTheme,
|
||||||
|
primaryShade,
|
||||||
|
selectedTheme,
|
||||||
|
useThemeAccentColor,
|
||||||
|
useThemePrimaryShade,
|
||||||
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = document.documentElement;
|
const root = document.documentElement;
|
||||||
|
|||||||
Reference in New Issue
Block a user