Skip to content
This repository was archived by the owner on Mar 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn commitlint --edit $1
yarn commitlint --edit $1
24 changes: 6 additions & 18 deletions src/provider/DesignProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,33 @@ import {
cookieStorageManagerSSR,
} from '@chakra-ui/react';
import type { Dict } from '@chakra-ui/utils';
import type { RequestCookie } from 'next/dist/compiled/@edge-runtime/cookies';

import { AppAlertDialogProvider } from '../component/dialog/AppAlertDialog';
import StyledComponentsRegistry from '../registry';

import { InitialCookiesProvider } from './InitialCookieProvider';

type Props = PropsWithChildren<{
cookies: RequestCookie[];
cookiesString: string;
theme?: Dict;
initialColorMode?: 'dark' | 'ligh';
initialColorMode?: 'dark' | 'light';
enableColorModeScript?: boolean;
}>;

const cookieKey = 'chakra-ui-color-mode';
export const DesignProvider = ({
children,
cookies,
cookiesString,
theme,
initialColorMode,
initialColorMode = 'light',
enableColorModeScript = true,
}: Props) => {
return (
<InitialCookiesProvider cookies={cookies}>
<InitialCookiesProvider cookies={[{ name: cookieKey, value: initialColorMode }]}>
{enableColorModeScript ? (
<ColorModeScript
initialColorMode={
initialColorMode ??
cookies.find((i) => i.name === 'chakra-ui-color-mode')?.value === 'dark'
? 'dark'
: 'light'
}
type={'cookie'}
/>
<ColorModeScript initialColorMode={initialColorMode} type={'cookie'} />
) : null}
<StyledComponentsRegistry>
<ChakraProvider
colorModeManager={cookieStorageManagerSSR(cookiesString)}
colorModeManager={cookieStorageManagerSSR(`cookieKey=${initialColorMode}`)}
theme={theme ?? baseTheme}
>
<AppAlertDialogProvider>{children}</AppAlertDialogProvider>
Expand Down