File tree Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @vanilla-extract/css ' : patch
3+ ---
4+
5+ Allow passing of null contract tokens in ` createThemeContract `
Original file line number Diff line number Diff line change @@ -104,11 +104,15 @@ export interface Adapter {
104104 onEndFileScope : ( fileScope : FileScope ) => void ;
105105}
106106
107+ export type NullableTokens = {
108+ [ key : string ] : string | Tokens | null ;
109+ } ;
110+
107111export type Tokens = {
108112 [ key : string ] : string | Tokens ;
109113} ;
110114
111- export type ThemeVars < ThemeContract extends Tokens > = MapLeafNodes <
115+ export type ThemeVars < ThemeContract extends NullableTokens > = MapLeafNodes <
112116 ThemeContract ,
113117 CSSVarFunction
114118> ;
Original file line number Diff line number Diff line change 88import hash from '@emotion/hash' ;
99import cssesc from 'cssesc' ;
1010
11- import { ThemeVars , Tokens } from './types' ;
11+ import { NullableTokens , ThemeVars } from './types' ;
1212import { getAndIncrementRefCounter , getFileScope } from './fileScope' ;
1313import { validateContract } from './validateContract' ;
1414
@@ -69,7 +69,7 @@ export function assignVars<VarContract extends Contract>(
6969 return varSetters ;
7070}
7171
72- export function createThemeContract < ThemeTokens extends Tokens > (
72+ export function createThemeContract < ThemeTokens extends NullableTokens > (
7373 tokens : ThemeTokens ,
7474) : ThemeVars < ThemeTokens > {
7575 return walkObject ( tokens , ( _value , path ) => {
Original file line number Diff line number Diff line change 1+ import {
2+ createTheme ,
3+ createThemeContract ,
4+ createGlobalTheme ,
5+ } from '@vanilla-extract/css' ;
6+
7+ const vars = createThemeContract ( {
8+ shouldSupportNull : null ,
9+ shouldSupportString : '' ,
10+ } ) ;
11+
12+ createGlobalTheme ( ':root' , vars , {
13+ shouldSupportNull : 'some-value' ,
14+ shouldSupportString : 'some-value' ,
15+ } ) ;
16+
17+ createTheme ( vars , {
18+ shouldSupportNull : 'some-value' ,
19+ shouldSupportString : 'some-value' ,
20+ } ) ;
You can’t perform that action at this time.
0 commit comments