Skip to content

Commit

Permalink
Release (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 authored Mar 17, 2024
2 parents 29d0817 + ce79ab8 commit 2aa44d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
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

0 comments on commit 2aa44d3

Please sign in to comment.