INSTUI-4842 [v12] better typing for themes#2223
Conversation
| // the following types are coming from SingleXYToken in @token-studio/types | ||
| // we could add them as imports from @token-studio/types if needed |
There was a problem hiding this comment.
I decided to just hardcode these simple types here, because importing them all if they are required would be lots of extra code
| if (componentTypes.includes('TokenBoxshadowValueInst')) { | ||
| importBoxShadow = `import type { TokenBoxshadowValueInst } from '../commonTypes'` | ||
| } | ||
| let importBorder = '' | ||
| if (componentTypes.includes('TokenBorderValue')) { | ||
| importBorder = `import type { TokenBorderValue } from '@tokens-studio/types'` | ||
| } | ||
| let importTypography = '' | ||
| if (componentTypes.includes('TokenTypographyValueInst')) { | ||
| importTypography = `import type { TokenTypographyValueInst } from '../commonTypes'` |
There was a problem hiding this comment.
This is a bit ugly, but simple. If we want we can make this nicer and dynamic, IMO its not needed because I dont expect Token Studio to change its types often
|
| export type BaseTheme<P extends Record<string, any>, S extends Record<string, any>> = { | ||
| primitives: P | ||
| semantics: S | ||
| components: ComponentTypes |
There was a problem hiding this comment.
This type will likely change in the future, the structure of primitives and semantics is fixed
it uses now types from Token Studio
f1bbba8 to
68629b5
Compare
| params: StyleParams, | ||
| //TODO type themes properly | ||
| theme: any | ||
| theme: any // TODO BaseTheme is is not good, it accesses theme.semantics.spacing |
There was a problem hiding this comment.
This is the new theme already. I'm not sure what you mean about BaseTheme being not good. Can you elaborate?
Also typo (is is)
There was a problem hiding this comment.
I figured out what you meant. This theme should be the whole new theme in time, but as of right now, any will be enough
To test:
run
build:themesand check out the generated code (especially the types) inui-themes/src/themes/newThemes