Skip to content

Instantly share code, notes, and snippets.

@ReVoid
Created October 4, 2023 09:48
Show Gist options
  • Save ReVoid/6c8150c0f9a48c200dbf9e1fd67ba14a to your computer and use it in GitHub Desktop.
Save ReVoid/6c8150c0f9a48c200dbf9e1fd67ba14a to your computer and use it in GitHub Desktop.
UI Element size tokens example
type SizeToken = 'XSmall' | 'Small' | 'Medium' | 'Large' | 'XLarge';
type ElementSizeVariant<T = string> = T extends SizeToken ? T | 'Medium' : { width: number, height: number };
type ButtonSize = ElementSizeVariant<'Small' | 'Large'>; // 'Small' | 'Large' | 'Medium';
type CardSize = ElementSizeVariant; // { width: number, height: number }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment