Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Bulletproof Design System with TypeScript

Avatar for takanorip takanorip
May 23, 2025

Bulletproof Design System with TypeScript

Avatar for takanorip

takanorip

May 23, 2025
Tweet

More Decks by takanorip

Other Decks in Design

Transcript

  1. Style Dictionaryを掻甚 typescript/es6-declarations で型定矩を出力する export const : export const :

    ; ; ColorBackgroundGray string ColorBackgroundBlue string これを利甚しおコンポヌネントのPropsなどを自動生成できる
  2. Branded Typesの掻甚 SpacingずRadiusなど構造が同䞀だが混同したくないものを区別できる type extends = & in : type

    = type extends = extends ? | : export type = export const : < , > { [ ] }; ; < > < , > ; < >; ; Branded T U T key U TokenType DesignToken T T TokenType Branded T DesignTokenSpacing DesignToken DesignTokenSpacing string never string string never SizeSpacingXs 'spacing' 'designToken' 'spacing'
  3. Branded Typesの生成 Style Dictionaryの を利甚する registerTransform import from => =>

    StyleDictionary ; StyleDictionary. ({ type: , transitive: , name: , : ( , ) {}, : ( ) { }, }); 'style-dictionary' `value` `myTransitiveTransform` registerTransform filter transform true token options token // token.value will be resolved and transformed at this point
  4. export const : | = ... => return < =

    ? : ? : ... > </ > < > ({ mx, props }) { ( style {{ : rightKey (rightKey) , : leftKey (leftKey) , }} { } { } BoxComponent ); }; Box FC PropsWithoutText PropsWithTextBody createSpacingVariableFromKey createSpacingVariableFromKey BoxComponent props children '--padding-right' '0' '--padding-left' '0'
  5. CSS VariablesをTemplate Literalで管理する const = : => return export const

    = ?: => return ? : as ( ) { DesignTokens radius key path ; }; ( ) { { : radius (radius) , } ; }; createRadiusVariableFromKey Radius join radiusVariables Radius createRadiusVariableFromKey CSSProperties key radius `var(--${ . [ ]. . ('-')})` '--radius' '0'
  6. as Propの掻甚 type extends = ?: : & export default

    function extends = ... : const = as || return ... </ > < . > { ; . ; } . ; < . >({ , , } < >) { ; < { }> : {children} Component ; } BoxProps C React ElementType C React ReactNode React ComponentPropsWithoutRef Box C React ElementType BoxProps C Component rest as children as children rest 'div' 'div' Component BOX
  7. GitHub Actions経由でデザむントヌクンを曞き出す できる限り自動化しおおくこずでデザむナヌでも曎新できるようにする Figma REST API の Open API Spec

    が公開されおいるので、 TypeScriptを掻甚しお凊理を実装できる https://github.com/figma/rest-api-spec import type from const = await { GetFileResponse } axios. < >(url); result.data '@figma/rest-api-spec' result get GetFileResponse // This has type GetFileResponse