|
| 1 | +import { Meta } from '@storybook/addon-docs'; |
| 2 | +import { Table } from '@workday/canvas-kit-react/table'; |
| 3 | +import { base, brand, system } from '@workday/canvas-tokens-web'; |
| 4 | +import { StatusIndicator } from '@workday/canvas-kit-preview-react/status-indicator'; |
| 5 | +import { cssVar } from '@workday/canvas-kit-styling'; |
| 6 | +import { Box } from '@workday/canvas-kit-react/layout'; |
| 7 | + |
| 8 | +<Meta title="Guides/Upgrade Guides/v13.0" /> |
| 9 | + |
| 10 | +# Canvas Kit 13.0 Upgrade Guide |
| 11 | + |
| 12 | +This guide contains an overview of the changes in Canvas Kit v13. Please |
| 13 | +[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have |
| 14 | +any questions. |
| 15 | + |
| 16 | + |
| 17 | +## Table of contents |
| 18 | + |
| 19 | +- [Codemod](#codemod) |
| 20 | + - [Instructions](#instructions) |
| 21 | +- [Troubleshooting](#troubleshooting) |
| 22 | +- [Glossary](#glossary) |
| 23 | + - [Main](#main) |
| 24 | + - [Preview](#preview) |
| 25 | + - [Labs](#labs) |
| 26 | + |
| 27 | +## Codemod |
| 28 | + |
| 29 | +We've provided a [codemod](https://github.com/Workday/canvas-kit/tree/master/modules/codemod) to |
| 30 | +automatically update your code to work with most of the breaking changes in v13. **Breaking changes |
| 31 | +handled by the codemod are marked with 🤖 in the Upgrade Guide.** |
| 32 | + |
| 33 | +A codemod is a script that makes programmatic transformations on your codebase by traversing the |
| 34 | +[AST](https://www.codeshiftcommunity.com/docs/understanding-asts), identifying patterns, and making |
| 35 | +prescribed changes. This greatly decreases opportunities for error and reduces the number of manual |
| 36 | +updates, which allows you to focus on changes that need your attention. **We highly recommend you |
| 37 | +use the codemod for these reasons.** |
| 38 | + |
| 39 | +If you're new to running codemods or if it's been a minute since you've used one, there are a few |
| 40 | +things you'll want to keep in mind. |
| 41 | + |
| 42 | +- Our codemods are meant to be run sequentially. For example, if you're using v8 of Canvas Kit, |
| 43 | + you'll need to run the v9 codemod before you run v10 and so on. |
| 44 | +- The codemod will update your code to be compatible with the specified version, but it will **not** |
| 45 | + remove outdated dependencies or upgrade dependencies to the latest version. You'll need to upgrade |
| 46 | + dependencies on your own. |
| 47 | + - We recommend upgrading dependencies before running the codemod. |
| 48 | + - Always review your `package.json` files to make sure your dependency versions look correct. |
| 49 | +- The codemod will not handle every breaking change in v13. You will likely need to make some manual |
| 50 | + changes to be compatible. Use our Upgrade Guide as a checklist. |
| 51 | +- Codemods are not bulletproof. |
| 52 | + - Conduct a thorough PR and QA review of all changes to ensure no regressions were introduced. |
| 53 | + - As a safety precaution, we recommend committing the changes from the codemod as a single |
| 54 | + isolated commit (separate from other changes) so you can roll back more easily if necessary. |
| 55 | + |
| 56 | +We're here to help! Automatic changes to your codebase can feel scary. You can always reach out to |
| 57 | +our team. We'd be very happy to walk you through the process to set you up for success. |
| 58 | + |
| 59 | +### Instructions |
| 60 | + |
| 61 | +The easiest way to run our codemod is to use `npx` in your terminal. |
| 62 | + |
| 63 | +```sh |
| 64 | +npx @workday/canvas-kit-codemod v13 [path] |
| 65 | +``` |
| 66 | + |
| 67 | +Be sure to provide specific directories that need to be updated via the `[path]` argument. This |
| 68 | +decreases the amount of AST the codemod needs to traverse and reduces the chances of the script |
| 69 | +having an error. For example, if your source code lives in `src/`, use `src/` as your `[path]`. Or, |
| 70 | +if you have a monorepo with three packages using Canvas Kit, provide those specific packages as your |
| 71 | +`[path]`. |
| 72 | + |
| 73 | +Alternatively, if you're unable to run the codemod successfully using `npx`, you can install the |
| 74 | +codemod package as a dev dependency, run it with `yarn`, and then remove the package after you're |
| 75 | +finished. |
| 76 | + |
| 77 | +```sh |
| 78 | +yarn add @workday/canvas-kit-codemod --dev |
| 79 | +yarn canvas-kit-codemod v13 [path] |
| 80 | +yarn remove @workday/canvas-kit-codemod |
| 81 | +``` |
| 82 | + |
| 83 | +> **Note**: The codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` files. You'll need to |
| 84 | +> manually edit other file types (`.json`, `.mdx`, `.md`, etc.). You may need to run your linter |
| 85 | +> after executing the codemod, as its resulting formatting (spacing, quotes, etc.) may not match |
| 86 | +> your project conventions. |
| 87 | +
|
| 88 | + |
| 89 | +## Troubleshooting |
| 90 | + |
| 91 | +## Glossary |
| 92 | + |
| 93 | +### Main |
| 94 | + |
| 95 | +Our Main package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-react` has |
| 96 | +undergone a full design and a11y review and is approved for use in product. |
| 97 | + |
| 98 | +Breaking changes to code in Main will only occur during major version updates and will always be |
| 99 | +communicated in advance and accompanied by migration strategies. |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +### Preview |
| 104 | + |
| 105 | +Our Preview package of Canvas Kit tokens, components, and utilities at |
| 106 | +`@workday/canvas-kit-preview-react` has undergone a full design and a11y review and is approved for |
| 107 | +use in product, but may not be up to the high code standards upheld in the [Main](#main) package. |
| 108 | +Preview is analagous to code in beta. |
| 109 | + |
| 110 | +Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without |
| 111 | +triggering a major version update, though such changes will be communicated in advance and |
| 112 | +accompanied by migration strategies. |
| 113 | + |
| 114 | +Generally speaking, our goal is to eventually promote code from Preview to [Main](#main). |
| 115 | +Occasionally, a component with the same name will exist in both [Main](#main) and Preview (for |
| 116 | +example, see Segmented Control in [Preview](/components/buttons/segmented-control/) and |
| 117 | +[Main](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-buttons-segmented-control--basic)). |
| 118 | +In these cases, Preview serves as a staging ground for an improved version of the component with a |
| 119 | +different API. The component in [Main](#main) will eventually be replaced with the one in Preview. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +### Labs |
| 124 | + |
| 125 | +Our Labs package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-labs-react` |
| 126 | +has **not** undergone a full design and a11y review. Labs serves as an incubator space for new and |
| 127 | +experimental code and is analagous to code in alpha. |
| 128 | + |
| 129 | +Breaking changes can be deployed to Labs at any time without triggering a major version update and |
| 130 | +may not be subject to the same rigor in communcation and migration strategies reserved for breaking |
| 131 | +changes in [Preview](#preview) and [Main](#main). |
| 132 | +`import { opacity } from "@workday/canvas-tokens-web/dist/es6/system"` |
0 commit comments