diff --git a/modules/react/common/lib/CanvasProvider.tsx b/modules/react/common/lib/CanvasProvider.tsx index b7cc51c223..540c4a66d8 100644 --- a/modules/react/common/lib/CanvasProvider.tsx +++ b/modules/react/common/lib/CanvasProvider.tsx @@ -7,8 +7,15 @@ import {createStyles, getCache} from '@workday/canvas-kit-styling'; export interface CanvasProviderProps { theme?: PartialEmotionCanvasTheme; + density?: 'low' | 'medium' | 'high' | undefined; } +export const DensityContext = React.createContext('medium'); + +export const useDensityContext = (): CanvasProviderProps['density'] => { + return React.useContext(DensityContext); +}; + // copied from brand/_variables.css const defaultBranding = createStyles({ [brand.error.darkest]: 'rgba(128,22,14,1)', @@ -84,14 +91,15 @@ export const useCanvasThemeToCssVars = ( export const CanvasProvider = ({ children, - theme = {canvas: defaultCanvasTheme, custom: {}}, + theme = {canvas: defaultCanvasTheme}, + density = 'medium', ...props }: CanvasProviderProps & React.HTMLAttributes) => { const elemProps = useCanvasThemeToCssVars(theme, props); const cache = getCache(); return ( - - + +
- - + + ); }; - -export type CanvasProviderType = { - theme: PartialEmotionCanvasTheme; -}; - -const CanvasThemeContext = React.createContext({ - theme: {custom: {}}, -}); -export const useCanvasProvider = () => { - return React.useContext(CanvasThemeContext); -};