refactor: improve style of antd switch in new UI
This commit is contained in:
parent
ffee0b8799
commit
1bd18fa412
@ -6,14 +6,14 @@ import { TokenLoginContainer } from './components/TokenLoginContainer';
|
|||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { trpc, trpcClient } from './api/trpc';
|
import { trpc, trpcClient } from './api/trpc';
|
||||||
import { useInjectWebsiteScript } from './hooks/useInjectWebsiteScript';
|
import { useInjectWebsiteScript } from './hooks/useInjectWebsiteScript';
|
||||||
import { ConfigProvider, theme } from 'antd';
|
import { ConfigProvider } from 'antd';
|
||||||
import { useColorSchema } from './store/settings';
|
|
||||||
import { RouterProvider, createRouter } from '@tanstack/react-router';
|
import { RouterProvider, createRouter } from '@tanstack/react-router';
|
||||||
import { routeTree } from './routeTree.gen';
|
import { routeTree } from './routeTree.gen';
|
||||||
import { DefaultNotFound } from './components/DefaultNotFound';
|
import { DefaultNotFound } from './components/DefaultNotFound';
|
||||||
import { TooltipProvider } from './components/ui/tooltip';
|
import { TooltipProvider } from './components/ui/tooltip';
|
||||||
import { Toaster } from './components/ui/sonner';
|
import { Toaster } from './components/ui/sonner';
|
||||||
import { DefaultError } from './components/DefaultError';
|
import { DefaultError } from './components/DefaultError';
|
||||||
|
import { useAntdTheme } from './hooks/useTheme';
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
routeTree,
|
routeTree,
|
||||||
@ -51,16 +51,14 @@ AppRouter.displayName = 'AppRouter';
|
|||||||
|
|
||||||
export const App: React.FC = React.memo(() => {
|
export const App: React.FC = React.memo(() => {
|
||||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||||
const colorScheme = useColorSchema();
|
const theme = useAntdTheme();
|
||||||
const algorithm =
|
|
||||||
colorScheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={rootRef} className="App">
|
<div ref={rootRef} className="App">
|
||||||
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
<trpc.Provider client={trpcClient} queryClient={queryClient}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<ConfigProvider
|
<ConfigProvider
|
||||||
theme={{ algorithm }}
|
theme={theme}
|
||||||
getPopupContainer={() => rootRef.current!}
|
getPopupContainer={() => rootRef.current!}
|
||||||
>
|
>
|
||||||
<TokenLoginContainer>
|
<TokenLoginContainer>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { useColorSchema } from '@/store/settings';
|
||||||
|
import { theme, ThemeConfig } from 'antd';
|
||||||
import { useEffect, useMemo } from 'react';
|
import { useEffect, useMemo } from 'react';
|
||||||
import { colord } from 'colord';
|
import { colord } from 'colord';
|
||||||
|
|
||||||
@ -95,3 +97,13 @@ export function useTheme() {
|
|||||||
|
|
||||||
return { theme, saveTheme, colors };
|
return { theme, saveTheme, colors };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useAntdTheme(): ThemeConfig {
|
||||||
|
const colorScheme = useColorSchema();
|
||||||
|
const algorithm =
|
||||||
|
colorScheme === 'dark' ? theme.darkAlgorithm : theme.defaultAlgorithm;
|
||||||
|
|
||||||
|
return {
|
||||||
|
algorithm,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -70,6 +70,10 @@ a {
|
|||||||
.ant-btn-primary {
|
.ant-btn-primary {
|
||||||
background-color: #1677ff;
|
background-color: #1677ff;
|
||||||
}
|
}
|
||||||
|
.ant-switch {
|
||||||
|
@apply bg-muted;
|
||||||
|
/* background: hsl(var(--muted)); */
|
||||||
|
}
|
||||||
|
|
||||||
/* https://ui.shadcn.com/themes */
|
/* https://ui.shadcn.com/themes */
|
||||||
@layer base {
|
@layer base {
|
||||||
|
Loading…
Reference in New Issue
Block a user