Skip to content

Instantly share code, notes, and snippets.

@anuraghazra
Last active March 21, 2023 21:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuraghazra/1cb5c9ff7b822ac6a85660d9e9862e59 to your computer and use it in GitHub Desktop.
Save anuraghazra/1cb5c9ff7b822ac6a85660d9e9862e59 to your computer and use it in GitHub Desktop.
TypeScript TokenizeTheme type performance

In these two files if you change getToken{slow,fast}'s passed value (just add a random letter anywhere) you'll see that the fast version is getting type checked about 3x to 5x faster than the slow one.

I'm not sure why using key remapping and using keyof {} is about 3x to 5x faster when doing type checking.

My guess is that in the slow version is using index access with the {}[keyof Theme] which is generally slower?

Performance tracing

Today did some actual performance tracing of the two variants:

  • slow.ts - took 450ms to do type-checking
  • fast.ts - took only 80ms to do type-checking

What's fascinating is that slow.ts is triggering this structuredTypeRelatedTo which is I think the culprit here. On parallel with type-checking (structuredTypeRelatedTo) took:

  • slow.ts - 1100ms
  • fast.ts - 140ms (no structuredTypeRelatedTo)

Screenshot 2022-03-11 at 12 53 03 PM

Why?

My guess is that the culprit is the index access signature.

So whats happening is in slow.ts we are using the index access signature which is triggering the structuredTypeRelatedTo function which does type checking for index access signatures. https://github.com/microsoft/TypeScript/blob/main/src/compiler/checker.ts#L19124

And I assume that is the root cause of the slowness, the checker has to validate and typecheck that keyof Theme (which is a HUGE union) is indexable with the mapped type.

But in the fast.ts we are not using index access signature thus there is no need to do that extra typechecking, we just need to get all of it's keys. Thus it resolves faster.

type Dollar<First extends boolean> = First extends true ? "$" : "";
type TokenizeFast<Theme, First extends boolean = true> = keyof {
[K in keyof Theme as `${Dollar<First>}${K & string}.${Extract<
Theme[K] extends Record<string, string | number>
? keyof Theme[K]
: TokenizeFast<Theme[K], false>,
string
>}`]: true;
};
function createThemeFast<T>(theme: T) {
return { getTokenFast: (token: TokenizeFast<T>) => {} };
}
const t = {
colors: {
surface: {
background: {
level1: {
lowContrast: "",
highContrast: "",
},
level2: {
lowContrast: "",
highContrast: "",
},
level3: {
lowContrast: "",
highContrast: "",
},
},
border: {
normal: {
lowContrast: "",
highContrast: "",
},
subtle: {
lowContrast: "",
highContrast: "",
},
},
text: {
normal: {
lowContrast: "",
highContrast: "",
},
subtle: {
lowContrast: "",
highContrast: "",
},
subdued: {
lowContrast: "",
highContrast: "",
},
muted: {
lowContrast: "",
highContrast: "",
},
placeholder: {
lowContrast: "",
highContrast: "",
},
},
action: {
icon: {
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
overlay: {
background: "",
},
brand: {
primary: {
300: "",
400: "",
500: "",
600: "",
700: "",
},
gray: {
300: "",
400: "",
500: "",
600: "",
700: "",
},
secondary: { 500: "" },
},
feedback: {
background: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
border: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
text: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
icon: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
neutral: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
positive: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
negative: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
notice: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
information: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
},
action: {
background: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
border: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
text: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
link: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
icon: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
link: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
},
},
border: {
radius: {
none: 0,
small: 0,
medium: 0,
large: 0,
max: 0,
round: "0%", // this needs to be in % but need to figure out how will we store unitless things
},
width: {
none: 0,
thin: 0,
},
},
spacing: {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0,
},
shadows: {
offsetX: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
offsetY: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
blurRadius: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
color: {
level: {
1: "",
2: "",
3: "",
4: "",
5: "",
},
},
androidElevation: {
// this is required for android
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
// shadowOpacity: 1, // this is required for iOS
},
typography: {
fonts: {
family: {
text: 'Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
code: "monospace",
},
size: {
10: 0,
25: 0,
50: 0,
75: 0,
100: 0,
200: 0,
300: 0,
400: 0,
500: 0,
600: 0,
700: 0,
800: 0,
900: 0,
1000: 0,
},
weight: {
regular: 400,
bold: 700,
},
},
lineHeights: {
s: 0,
m: 0,
l: 0,
xl: 0,
"2xl": 0,
"3xl": 0,
"4xl": 0,
"5xl": 0,
"6xl": 0,
},
// letterSpacings: {},
},
};
const { getTokenFast } = createThemeFast(t);
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
getTokenFast("$border.radius.medium");
type Dollar<First extends boolean> = First extends true ? "$" : "";
type TokenizeSlow<Theme, First extends boolean = true> = {
[K in keyof Theme]: `${Dollar<First>}${K &
string}.${Theme[K] extends Record<string, string | number>
? Extract<keyof Theme[K], string | number>
: TokenizeSlow<Theme[K], false>}`;
}[keyof Theme];
function createThemeSlow<T>(theme: T) {
return { getTokenSlow: (token: TokenizeSlow<T>) => {} };
}
const t = {
colors: {
surface: {
background: {
level1: {
lowContrast: "",
highContrast: "",
},
level2: {
lowContrast: "",
highContrast: "",
},
level3: {
lowContrast: "",
highContrast: "",
},
},
border: {
normal: {
lowContrast: "",
highContrast: "",
},
subtle: {
lowContrast: "",
highContrast: "",
},
},
text: {
normal: {
lowContrast: "",
highContrast: "",
},
subtle: {
lowContrast: "",
highContrast: "",
},
subdued: {
lowContrast: "",
highContrast: "",
},
muted: {
lowContrast: "",
highContrast: "",
},
placeholder: {
lowContrast: "",
highContrast: "",
},
},
action: {
icon: {
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
overlay: {
background: "",
},
brand: {
primary: {
300: "",
400: "",
500: "",
600: "",
700: "",
},
gray: {
300: "",
400: "",
500: "",
600: "",
700: "",
},
secondary: { 500: "" },
},
feedback: {
background: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
border: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
text: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
icon: {
neutral: {
lowContrast: "",
highContrast: "",
},
positive: {
lowContrast: "",
highContrast: "",
},
negative: {
lowContrast: "",
highContrast: "",
},
notice: {
lowContrast: "",
highContrast: "",
},
information: {
lowContrast: "",
highContrast: "",
},
},
neutral: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
positive: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
negative: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
notice: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
information: {
action: {
background: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
border: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
text: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
icon: {
primary: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
link: {
default: {
lowContrast: "",
highContrast: "",
},
hover: {
lowContrast: "",
highContrast: "",
},
focus: {
lowContrast: "",
highContrast: "",
},
active: {
lowContrast: "",
highContrast: "",
},
disabled: {
lowContrast: "",
highContrast: "",
},
},
},
},
},
},
action: {
background: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
border: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
text: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
link: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
icon: {
primary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
secondary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
tertiary: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
link: {
default: "",
hover: "",
focus: "",
active: "",
disabled: "",
},
},
},
},
border: {
radius: {
none: 0,
small: 0,
medium: 0,
large: 0,
max: 0,
round: "0%", // this needs to be in % but need to figure out how will we store unitless things
},
width: {
none: 0,
thin: 0,
},
},
spacing: {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
10: 0,
},
shadows: {
offsetX: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
offsetY: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
blurRadius: {
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
color: {
level: {
1: "",
2: "",
3: "",
4: "",
5: "",
},
},
androidElevation: {
// this is required for android
level: {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
},
},
// shadowOpacity: 1, // this is required for iOS
},
typography: {
fonts: {
family: {
text: 'Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
code: "monospace",
},
size: {
10: 0,
25: 0,
50: 0,
75: 0,
100: 0,
200: 0,
300: 0,
400: 0,
500: 0,
600: 0,
700: 0,
800: 0,
900: 0,
1000: 0,
},
weight: {
regular: 400,
bold: 700,
},
},
lineHeights: {
s: 0,
m: 0,
l: 0,
xl: 0,
"2xl": 0,
"3xl": 0,
"4xl": 0,
"5xl": 0,
"6xl": 0,
},
// letterSpacings: {},
},
};
const { getTokenSlow } = createThemeSlow(t);
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
getTokenSlow("$border.radius.medium");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment