Migrating from Canvas Kit React Tokens #77
alanbsmith
started this conversation in
General
Replies: 1 comment
-
|
Tiny update here (I use this page a lot for converting tokens) - I think |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Migrating from Canvas Kit React Tokens
Overview
If you've been using Canvas Kit, you're probably familiar with our former tokens in
@workday/canvas-kit-react/tokens. While we still support them for now, we plan to fully replace them with our new Canvas Tokens in@workday/canvas-tokens-webso we can use CSS custom properties as a single source of truth for everything using Canvas.Installation
Importing CSS Variables
Before you can use our CSS variables in your components, you'll need to import them at the top-level of your application.
You can import them in a CSS file.
You can also import them in a JS or TS file:
Using CSS Variables
One common hangup for folks switching from JavaScript variables to using CSS variables is that you'll need to wrap CSS variables in
var()for their property to be applied.If you're using our
@workday/canvas-kit-stylingpackage, you can also usecssVarinstead of template literals to get the same result.Migrating Base Tokens
Color
Migrating from our old color tokens to our new base colors is pretty straightforward. If you replace
colorswithbase, you can easily migrate to the new tokens. There are a lot of base color tokens (144!), so we'll only list one per palette below.colors.cinnamon400base.cinnamon400--cnvs-base-palette-cinnamon-400colors.peach400base.peach400--cnvs-base-palette-peach-400colors.chiliMango400base.chiliMango400--cnvs-base-palette-chili-mango-400colors.cantaloupe400base.cantaloupe400--cnvs-base-palette-cantaloupe-400colors.sourLemon400base.sourLemon400--cnvs-base-palette-sour-lemon-400colors.juicyPear400base.juicyPear400--cnvs-base-palette-juicy-pear-400colors.kiwi400base.kiwi400--cnvs-base-palette-kiwi-400colors.greenApple400base.greenApple400--cnvs-base-palette-green-apple-400colors.watermelon400base.watermelon400--cnvs-base-palette-watermelon-400colors.jewel400base.jewel400--cnvs-base-palette-jewel-400colors.toothpaste400base.toothpaste400--cnvs-base-palette-toothpaste-400colors.blueberry400base.blueberry400--cnvs-base-palette-blueberry-400colors.plum400base.plum400--cnvs-base-palette-plum-400colors.berrySmoothie400base.berrySmoothie400--cnvs-base-palette-berry-smoothie-400colors.blackberry400base.blackberry400--cnvs-base-palette-blackberry-400colors.islandPunch400base.islandPunch400--cnvs-base-palette-island-punch-400colors.grapeSoda400base.grapeSoda400--cnvs-base-palette-grape-soda-400colors.pomegranate400base.pomegranate400--cnvs-base-palette-pomegranate-400colors.fruitPunch400base.fruitPunch400--cnvs-base-palette-fruit-punch-400colors.rootBeer400base.rootBeer400--cnvs-base-palette-root-beer-400colors.toastedMarshmallow400base.toastedMarshmallow400--cnvs-base-palette-toasted-marshmallow-400colors.cappuccino400base.cappuccino400--cnvs-base-palette-cappuccino-400colors.licorice400base.licorice400--cnvs-base-palette-licorice-400colors.blackPepper400base.blackPepper400--cnvs-base-palette-black-pepper-400Migrating Brand Tokens
Our old brand tokens live in the Emotion theme object, but now we can use CSS variables directly.
Color
theme.canvas.palette.primary.lightestbrand.primary.lightest--cnvs-brand-primary-lightesttheme.canvas.palette.primary.lightbrand.primary.light--cnvs-brand-primary-lighttheme.canvas.palette.primary.mainbrand.primary.base--cnvs-brand-primary-basetheme.canvas.palette.primary.darkbrand.primary.dark--cnvs-brand-primary-darktheme.canvas.palette.primary.darkestbrand.primary.darkest--cnvs-brand-primary-darkesttheme.canvas.palette.primary.contrastbrand.primary.accent--cnvs-brand-primary-accenttheme.canvas.palette.alert.lightestbrand.alert.lightest--cnvs-brand-alert-lightesttheme.canvas.palette.alert.lightbrand.alert.light--cnvs-brand-alert-lighttheme.canvas.palette.alert.mainbrand.alert.base--cnvs-brand-alert-basetheme.canvas.palette.alert.darkbrand.alert.dark--cnvs-brand-alert-darktheme.canvas.palette.alert.darkestbrand.alert.darkest--cnvs-brand-alert-darkesttheme.canvas.palette.alert.contrastbrand.alert.accent--cnvs-brand-alert-accenttheme.canvas.palette.error.lightestbrand.error.lightest--cnvs-brand-error-lightesttheme.canvas.palette.error.lightbrand.error.light--cnvs-brand-error-lighttheme.canvas.palette.error.mainbrand.error.base--cnvs-brand-error-basetheme.canvas.palette.error.darkbrand.error.dark--cnvs-brand-error-darktheme.canvas.palette.error.darkestbrand.error.darkest--cnvs-brand-error-darkesttheme.canvas.palette.error.contrastbrand.error.accent--cnvs-brand-error-accenttheme.canvas.palette.success.lightestbrand.success.lightest--cnvs-brand-success-lightesttheme.canvas.palette.success.lightbrand.success.light--cnvs-brand-success-lighttheme.canvas.palette.success.mainbrand.success.base--cnvs-brand-success-basetheme.canvas.palette.success.darkbrand.success.dark--cnvs-brand-success-darktheme.canvas.palette.success.darkestbrand.success.darkest--cnvs-brand-success-darkesttheme.canvas.palette.success.contrastbrand.success.accent--cnvs-brand-success-accenttheme.canvas.palette.neutral.lightestbrand.neutral.lightest--cnvs-brand-neutral-lightesttheme.canvas.palette.neutral.lightbrand.neutral.light--cnvs-brand-neutral-lighttheme.canvas.palette.neutral.mainbrand.neutral.base--cnvs-brand-neutral-basetheme.canvas.palette.neutral.darkbrand.neutral.dark--cnvs-brand-neutral-darktheme.canvas.palette.neutral.darkestbrand.neutral.darkest--cnvs-brand-neutral-darkesttheme.canvas.palette.neutral.contrastbrand.neutral.accent--cnvs-brand-neutral-accenttheme.canvas.palette.common.focusOutlinebrand.common.focusOutline--cnvs-brand-common-focus-outlinebrand.common.errorInner--cnvs-brand-common-error-innerbrand.common.alertInner--cnvs-brand-common-alert-innerMigrating System Tokens
Color
Background Colors
colors.frenchVanilla100system.color.bg.defaultcolors.blueberry200system.color.bg.primary.softcolors.blueberry400system.color.bg.primary.defaultcolors.blueberry500system.color.bg.primary.strongcolors.blueberry600system.color.bg.primary.strongercolors.cantaloupe100system.color.bg.caution.softercolors.cantaloupe400system.color.bg.caution.defaultcolors.cantaloupe500system.color.bg.caution.strongcolors.cantaloupe600system.color.bg.caution.strongercolors.cinnamon100system.color.bg.critical.softercolors.cinnamon500system.color.bg.critical.defaultcolors.cinnamon600system.color.bg.critical.strong#80160Esystem.color.bg.critical.strongercolors.greenApple100system.color.bg.positive.softercolors.greenApple400system.color.bg.positive.defaultcolors.greenApple500system.color.bg.positive.strongcolors.greenApple600system.color.bg.positive.strongercolors.licorice100system.color.bg.muted.softercolors.licorice200system.color.bg.muted.softcolors.licorice300system.color.bg.muted.defaultcolors.licorice500system.color.bg.muted.strongcolors.soap100system.color.bg.alt.softercolors.soap200system.color.bg.alt.softcolors.soap300system.color.bg.alt.defaultcolors.soap400system.color.bg.alt.strongcolors.soap500system.color.bg.alt.strongercolors.blackPepper400system.color.bg.contrast.defaultcolors.blackPepper500system.color.bg.contrast.strongForeground Colors
colors.blackPepper300system.color.fg.defaultcolors.blackPepper400system.color.fg.strongcolors.blackPepper500system.color.fg.strongercolors.blueberry400system.color.fg.primary.defaultcolors.blueberry500system.color.fg.primary.strongcolors.cinnamon500system.color.fg.critical.defaultcolors.frenchVanilla100system.color.fg.inversecolors.licorice100system.color.fg.disabledcolors.licorice200system.color.fg.muted.softcolors.licorice300system.color.fg.muted.defaultcolors.licorice400system.color.fg.muted.strongcolors.licorice500system.color.fg.muted.strongerBorder Colors
colors.blackPepper400system.color.border.contrast.defaultcolors.blackPepper500system.color.border.contrast.strongcolors.blueberry400system.color.border.primary.defaultcolors.cantaloupe400system.color.border.caution.defaultcolors.cantaloupe600system.color.border.caution.strongcolors.cinnamon500system.color.border.critical.defaultcolors.frenchVanilla100system.color.border.inversecolors.licorice100system.color.border.input.disabledcolors.licorice200system.color.border.input.defaultcolors.licorice500system.color.border.input.strongcolors.soap300system.color.border.input.inversecolors.soap400system.color.border.dividercolors.soap500system.color.border.containerBorder Radius (Shape)
Border radius tokens are now called Shape tokens to better align with design.
borderRadius.zerosystem.shape.zero--cnvs-sys-shape-zeroborderRadius.ssystem.shape.half--cnvs-sys-shape-halfborderRadius.msystem.shape.x1--cnvs-sys-shape-x1borderRadius.lsystem.shape.x2--cnvs-sys-shape-x2borderRadius.circlesystem.shape.round--cnvs-sys-shape-roundDepth
depth.nonedepth[1]system.depth[1]--cnvs-system-depth-1depth[2]system.depth[2]--cnvs-system-depth-2depth[3]system.depth[3]--cnvs-system-depth-3depth[4]system.depth[4]--cnvs-system-depth-4depth[5]system.depth[5]--cnvs-system-depth-5depth[6]system.depth[6]--cnvs-system-depth-6Space
space.zerosystem.space.zero--cnvs-sys-space-zerospace.xxxssystem.space.x1--cnvs-sys-space-x1space.xxssystem.space.x2--cnvs-sys-space-x2space.xssystem.space.x3--cnvs-sys-space-x3space.ssystem.space.x4--cnvs-sys-space-x4space.msystem.space.x6--cnvs-sys-space-x6space.lsystem.space.x8--cnvs-sys-space-x8space.xlsystem.space.x10--cnvs-sys-space-x10space.xxlsystem.space.x16--cnvs-sys-space-x16space.xxxlsystem.space.x20--cnvs-sys-space-x20Type
Font Family
type.properties.fontFamilies.defaultsystem.fontFamily.default--cnvs-sys-font-family-defaulttype.properties.fontFamilies.monospacesystem.fontFamily.mono--cnvs-sys-font-family-monosystem.fontFamily.global--cnvs-sys-font-family-globalFont Size
type.properties.fontSizes[10]system.fontSize.subtext.small--cnvs-sys-font-size-subtext-smalltype.properties.fontSizes[12]system.fontSize.subtext.medium--cnvs-sys-font-size-subtext-mediumtype.properties.fontSizes[14]system.fontSize.subtext.large--cnvs-sys-font-size-subtext-largetype.properties.fontSizes[16]system.fontSize.body.small--cnvs-sys-font-size-body-smalltype.properties.fontSizes[18]system.fontSize.body.medium--cnvs-sys-font-size-body-mediumtype.properties.fontSizes[20]system.fontSize.body.large--cnvs-sys-font-size-body-largetype.properties.fontSizes[24]system.fontSize.heading.small--cnvs-sys-font-size-heading-smalltype.properties.fontSizes[28]system.fontSize.heading.medium--cnvs-sys-font-size-heading-mediumtype.properties.fontSizes[32]system.fontSize.heading.large--cnvs-sys-font-size-heading-largetype.properties.fontSizes[40]system.fontSize.title.small--cnvs-sys-font-size-title-smalltype.properties.fontSizes[48]system.fontSize.title.medium--cnvs-sys-font-size-title-mediumtype.properties.fontSizes[56]system.fontSize.title.large--cnvs-sys-font-size-title-largeFont Weight
system.fontWeight.light--cnvs-system-font-weight-lighttype.properties.fontWeights.regularsystem.fontWeight.regular--cnvs-system-font-weight-regulartype.properties.fontWeights.mediumsystem.fontWeight.medium--cnvs-system-font-weight-mediumtype.properties.fontWeights.boldsystem.fontWeight.bold--cnvs-system-font-weight-boldType Level
type.levels.subtext.smallsystem.type.subtext.smalltype.levels.subtext.mediumsystem.type.subtext.mediumtype.levels.subtext.largesystem.type.subtext.largetype.levels.body.smallsystem.type.body.smalltype.levels.body.mediumsystem.type.body.mediumtype.levels.body.largesystem.type.body.largetype.levels.heading.smallsystem.type.heading.smalltype.levels.heading.mediumsystem.type.heading.mediumtype.levels.heading.largesystem.type.heading.largetype.levels.title.smallsystem.type.title.smalltype.levels.title.mediumsystem.type.title.mediumtype.levels.title.largesystem.type.title.largeType Variants
There are no longer type variant tokens. Instead, use system text colors.
Beta Was this translation helpful? Give feedback.
All reactions