Skip to content

Commit

Permalink
Expose all coreui color definitions as css custom properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfalke committed Nov 22, 2024
1 parent d1db6f9 commit d3d6966
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/libs/coreui/src/components/theming/UIThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { css, Global, ThemeProvider } from '@emotion/react';
import { useCoreUIFonts } from '../../hooks';

import { UITheme } from './types';
import colors from '../../definitions/colors';

export type UIThemeProviderProps = {
theme: UITheme;
Expand All @@ -21,6 +22,15 @@ export default function UIThemeProvider({
<Global
styles={css`
:root {
${Object.entries(colors).flatMap(([colorName, byHueOrValue]) =>
typeof byHueOrValue === 'string'
? [`--coreui-${colorName}: ${byHueOrValue};`]
: Object.entries(byHueOrValue).map(
([hueName, colorValue]) =>
`--coreui-${colorName}-${hueName}: ${colorValue};`
)
)}
--coreui-color-primary: ${theme.palette.primary.hue[
theme.palette.primary.level
]};
Expand Down

0 comments on commit d3d6966

Please sign in to comment.