@patreon/studio
Version:
Patreon Studio Design System
25 lines • 1.23 kB
JSX
'use client';
import React, { createContext, useContext, useMemo } from 'react';
import { ColorSchemeProvider } from '../ColorSchemeProvider';
export const TokenModeContext = createContext({
rootColorMode: 'auto',
rootScreenMode: 'auto',
currentColorMode: 'auto',
currentScreenMode: 'auto',
});
export function useTokenModes() {
return useContext(TokenModeContext);
}
export function TokenModeProvider({ rootColorMode, rootScreenMode, currentColorMode, currentScreenMode, children, }) {
const currentTokenModes = useTokenModes();
const value = useMemo(() => ({
rootColorMode: rootColorMode ?? currentTokenModes.rootColorMode,
rootScreenMode: rootScreenMode ?? currentTokenModes.rootScreenMode,
currentColorMode: currentColorMode ?? currentTokenModes.currentColorMode,
currentScreenMode: currentScreenMode ?? currentTokenModes.currentScreenMode,
}), [rootColorMode, rootScreenMode, currentColorMode, currentScreenMode, currentTokenModes]);
return (<TokenModeContext.Provider value={value}>
<ColorSchemeProvider tokenColorMode={value.currentColorMode}>{children}</ColorSchemeProvider>
</TokenModeContext.Provider>);
}
//# sourceMappingURL=index.jsx.map