Skip to content

Latest commit

 

History

History
173 lines (127 loc) · 7.53 KB

13.0-UPGRADE-GUIDE.mdx

File metadata and controls

173 lines (127 loc) · 7.53 KB

import { Meta } from '@storybook/addon-docs'; import { Table } from '@workday/canvas-kit-react/table'; import { base, brand, system } from '@workday/canvas-tokens-web'; import { StatusIndicator } from '@workday/canvas-kit-preview-react/status-indicator'; import { cssVar } from '@workday/canvas-kit-styling'; import { Box } from '@workday/canvas-kit-react/layout';

Canvas Kit 13.0 Upgrade Guide

This guide contains an overview of the changes in Canvas Kit v13. Please reach out if you have any questions.

Table of contents

Codemod

We've provided a codemod to automatically update your code to work with most of the breaking changes in v13. Breaking changes handled by the codemod are marked with 🤖 in the Upgrade Guide.

A codemod is a script that makes programmatic transformations on your codebase by traversing the AST, identifying patterns, and making prescribed changes. This greatly decreases opportunities for error and reduces the number of manual updates, which allows you to focus on changes that need your attention. We highly recommend you use the codemod for these reasons.

If you're new to running codemods or if it's been a minute since you've used one, there are a few things you'll want to keep in mind.

  • Our codemods are meant to be run sequentially. For example, if you're using v8 of Canvas Kit, you'll need to run the v9 codemod before you run v10 and so on.
  • The codemod will update your code to be compatible with the specified version, but it will not remove outdated dependencies or upgrade dependencies to the latest version. You'll need to upgrade dependencies on your own.
    • We recommend upgrading dependencies before running the codemod.
    • Always review your package.json files to make sure your dependency versions look correct.
  • The codemod will not handle every breaking change in v13. You will likely need to make some manual changes to be compatible. Use our Upgrade Guide as a checklist.
  • Codemods are not bulletproof.
    • Conduct a thorough PR and QA review of all changes to ensure no regressions were introduced.
    • As a safety precaution, we recommend committing the changes from the codemod as a single isolated commit (separate from other changes) so you can roll back more easily if necessary.

We're here to help! Automatic changes to your codebase can feel scary. You can always reach out to our team. We'd be very happy to walk you through the process to set you up for success.

Instructions

The easiest way to run our codemod is to use npx in your terminal.

npx @workday/canvas-kit-codemod v13 [path]

Be sure to provide specific directories that need to be updated via the [path] argument. This decreases the amount of AST the codemod needs to traverse and reduces the chances of the script having an error. For example, if your source code lives in src/, use src/ as your [path]. Or, if you have a monorepo with three packages using Canvas Kit, provide those specific packages as your [path].

Alternatively, if you're unable to run the codemod successfully using npx, you can install the codemod package as a dev dependency, run it with yarn, and then remove the package after you're finished.

yarn add @workday/canvas-kit-codemod --dev
yarn canvas-kit-codemod v13 [path]
yarn remove @workday/canvas-kit-codemod

Note: The codemod only works on .js, .jsx, .ts, and .tsx files. You'll need to manually edit other file types (.json, .mdx, .md, etc.). You may need to run your linter after executing the codemod, as its resulting formatting (spacing, quotes, etc.) may not match your project conventions.

Component Updates

Styling API and CSS Tokens

PRs: #3101, #3088

Several components have been refactored to use our Canvas Tokens and styling API. The React interface has not changed, but CSS variables are now used for dynamic properties.

Note: These components also support our cs prop for styling. Learn more about styling with cs in our documentation.

The following components are affected:

  • ExternalHyperlink
  • Skeleton

External Hyperlink

PR: #3101

iconLabel is now a required prop. We've removed the default aria-label of Opens link in new window to better support internationalization. You must provide a value to iconLabel.

//v12
<ExternalHyperlink href="https://workday.com">
  External Hyperlink
</ExternalHyperlink>

//v13
<ExternalHyperlink href="https://workday.com" iconLabel='Open link in new window'>
  External Hyperlink
</ExternalHyperlink>

Troubleshooting

Glossary

Main

Our Main package of Canvas Kit tokens, components, and utilities at @workday/canvas-kit-react has undergone a full design and a11y review and is approved for use in product.

Breaking changes to code in Main will only occur during major version updates and will always be communicated in advance and accompanied by migration strategies.


Preview

Our Preview package of Canvas Kit tokens, components, and utilities at @workday/canvas-kit-preview-react has undergone a full design and a11y review and is approved for use in product, but may not be up to the high code standards upheld in the Main package. Preview is analagous to code in beta.

Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without triggering a major version update, though such changes will be communicated in advance and accompanied by migration strategies.

Generally speaking, our goal is to eventually promote code from Preview to Main. Occasionally, a component with the same name will exist in both Main and Preview (for example, see Segmented Control in Preview and Main). In these cases, Preview serves as a staging ground for an improved version of the component with a different API. The component in Main will eventually be replaced with the one in Preview.


Labs

Our Labs package of Canvas Kit tokens, components, and utilities at @workday/canvas-kit-labs-react has not undergone a full design and a11y review. Labs serves as an incubator space for new and experimental code and is analagous to code in alpha.

Breaking changes can be deployed to Labs at any time without triggering a major version update and may not be subject to the same rigor in communcation and migration strategies reserved for breaking changes in Preview and Main. import { opacity } from "@workday/canvas-tokens-web/dist/es6/system"