Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoskolodny committed Jul 26, 2024
1 parent 0b69a61 commit a186a6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/theme-context-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,13 @@ const ThemeContextProvider: React.FC<Props> = ({theme, children, as, withoutStyl
return Object.assign({}, ...tokenValues) as TextPresetsVars;
}, [contextTheme]);

const themeVarsValues = {
const themeVars = {
textPresets: textPresetsVars,
colors,
rawColors,
borderRadii: theme.skin.borderRadii ?? defaultBorderRadiiConfig,
};

const responsiveThemeVarsValues = {
...themeVarsValues,
textPresets: textPresetsResponsiveVars,
};

return (
<>
<TabFocus disabled={!theme.enableTabFocus}>
Expand All @@ -255,11 +250,11 @@ const ThemeContextProvider: React.FC<Props> = ({theme, children, as, withoutStyl
isolation: 'isolate',
...assignInlineVars(
styles.themeVarsContract,
themeVarsValues
themeVars
),
...assignInlineVars(
styles.responsiveThemeVarsContract,
responsiveThemeVarsValues
styles.textPresetResponsiveVarsContract,
textPresetsResponsiveVars
),
},
className: withoutStyles
Expand All @@ -275,9 +270,9 @@ const ThemeContextProvider: React.FC<Props> = ({theme, children, as, withoutStyl
process.env.SSR_TEST) && (
<style>
{`
:root {${assignInlineVars(vars, themeVarsValues)}}
:root {${assignInlineVars(vars, themeVars)}}
@media ${mq.tabletOrSmaller} {
:root {${assignInlineVars(vars, responsiveThemeVarsValues)}}
:root {${assignInlineVars(vars.textPresets, textPresetsResponsiveVars)}}
}
`}
</style>
Expand Down
4 changes: 2 additions & 2 deletions src/theme-context.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {vars as skinVars} from './skins/skin-contract.css';
import * as mq from './media-queries.css';

export const themeVarsContract = createThemeContract(skinVars);
export const responsiveThemeVarsContract = createThemeContract(skinVars);
export const textPresetResponsiveVarsContract = createThemeContract(skinVars.textPresets);

export const themeVars = style({
vars: assignVars(skinVars, themeVarsContract),

'@media': {
[mq.tabletOrSmaller]: {
vars: assignVars(skinVars, responsiveThemeVarsContract),
vars: assignVars(skinVars.textPresets, textPresetResponsiveVarsContract),
},
},
});

0 comments on commit a186a6f

Please sign in to comment.