Releases: Workday/canvas-kit
v5.0.3
2021-07-09
Components
- docs: Convert Buttons category stories to use mdx (#1127) @anicholls
- docs: Add MDX docs and examples for Input components (#1128) @jamesfan
- fix(tooltip): Fix overflow ellipsis detection (#1132) @NicholasBoll
- fix(modal): Fix focus trap when Modal contains an iframe (#1135)
Docs
- docs: Fix codemod link in v5 migration guide @anicholls
Infrastructure
- build: Pull component mdx + examples into docs module during build (#1130) @anicholls@NicholasBoll
- feat: Add storybook utils to labs common (#1136) @vibdev
v4.8.1
2021-07-09
Components
- fix(combobox): Modify combobox to accept empty string as initialValue (#1116) @bsaggese14
- fix(tooltip): Fix overflow ellipsis detection (#1132) @NicholasBoll
- fix(modal): Fix focus trap when Modal contains an iframe (#1135) @NicholasBoll
- fix(breadcrumbs): Fix onAction bugs in Breadcrumbs (#1073) @alanbsmith
- fix(checkbox): Fix Checkbox width bug (#1139) @alanbsmith
v5.0.2
2021-06-22
Components
- feat(combobox): Modify combobox to accept empty string as initialValue (#1116) @bsaggese14
- fix: Add missing exports for CKR bundle (#1118) @anicholls
- fix(tokens): Fixes color token exports (#1110) @alanbsmith
- fix(popup): Remove ref forwarding requirement in Popup.Target (#1115) @NicholasBoll
v5.0.1
2021-06-16
Docs
- docs: Update readme links to use mdx (#1103) @jpante
- docs: Update old labs references (#1105) @anicholls
Infrastructure
- build: Remove baseUrl and paths from tsconfig (#1107) @anicholls
- chore: Fix circular dep in preview module (#1104) @anicholls
v4.8.0
2021-06-16
Components
- feat(checkbox): Add aria-checked for accessibility and testability (#1045) @svagi
- feat(comboxbox): Add default maxHeight to autocomplete container (#1079) @sraj
- fix(combobox): Fix Combobox RTL issue (#1064) @alanbsmith
- fix(popup): Allow popups to be owners of each other (#1054) @csongnguyen
- fix(popup): Allow tooltips to close alongside modals on click outside (#1074) @csongnguyen
- fix(tabs): Fix aria-selected for unselected tabs (#1033) @angadkaflay
- fix(tooltip): Allow aria-label pass-through in muted tooltips (#1037) @NicholasBoll
Docs
- docs: Add better documentation to the
as
prop (#1046) @NicholasBoll - docs: Add Popup accessible example (#1056) @csongnguyen
Infrastructure
- chore: Bump y18n from 3.2.1 to 3.2.2 (#1011) @dependabot
- chore: Bump elliptic from 6.5.3 to 6.5.4 (#993) @dependabot
- chore: Upgrade storybook to v6.2.9 (#1055) @anicholls
- chore: Bump ssri, ua-parser-js, handlebars, lodash, and hosted-git-info (#1049) @dependabot
- ci: Fix font-loading issue by predownloading @NicholasBoll
- ci: Fix Tooltip flaky visual test (#1035) @NicholasBoll
- ci: Upgrade to node 14 (#1044) @NicholasBoll
- feat: Add package version in Storybook (#1082) @mihaelamiches
v5.0.0
What’s New in Canvas Kit v5?
Canvas Kit v5 is the first major release this year. A big focus for this release was improving usability and developer experience. The foundation of these improvements is the shift to compound components. Compound components are a better way to build Workday UIs in a composable and flexible way. We’ve also moved to slash imports to make Canvas Kit dependency management easier for teams.
Another big change made is to the way we release our packages. We are adding clarity around labs and have introduced preview into our pipeline. There are a number of changes to individual components. Some of the bigger changes in v5 are to layout and type components. In this release type and layout components evolved to increase usability and bring better alignment across our design system artifacts.
Read on for more information about these improvements and other big changes in Canvas Kit v5. And as always, thank you to our contributors!!!
Contents
- Compound Components
createComponent
- Layout Components
- New and Improved Type System
- Popup Changes
- Labs & Preview
- Slash Imports
- Button Reorganization
- Getting Started
Compound Components
This is the start of a fundamental shift for our library. For the past year, we’ve wondered: How can we make Canvas Kit forward-thinking? How can we build Canvas Kit in a way that empowers teams to move forward and evolve their UI while still keeping their core Canvas DNA?
We also spent a lot of time thinking about our consumers and how they use Canvas Kit. Our components work really well for teams who need exactly what we provide, but if they deviate from the default use case, they are left to create hacky patches or forced to build their own component from scratch. On top of frustrating developers, those solutions also create duplicated effort and less coherence across Workday.
That’s counterproductive to our mission and below our standards. The three highest friction points were:
- Teams need access to lower-level components, either for styling, accessibility, or testing
- Teams need more control over component behavior
- Teams need the ability to extend Canvas Kit components without rebuilding them from scratch
Solving those problems is the heart of v5.
We decided to go all-in on composition and expose lower-level components and utilities to help you get more value and flexibility out of Canvas Kit. We spent months experimenting with patterns and refined the concept to what we know today as compound components.
The compound component pattern composes higher-level components from smaller, subcomponents. The parent component (container) exposes its subcomponents which allows you retain access to all the semantic child elements.
Compound components that contain state or behavior will also provide a shared model to subcomponents. A container component takes props for either the model or configuration for the model. Below is an example of a single-panel Tab component which uses the model to control its behavior.
import * as React from ‘react’;
import Tabs, {useTabsModel} from '@workday/canvas-kit-react/tabs';
const TabsExample = () => {
const tabsModel = useTabsModel();
const contents = {
first: <div>Contents of First Tab</div>,
second: <div>Contents of Second Tab</div>,
third: <div>Contents of Third Tab</div>,
};
return (
<Tabs model={model}>
<Tabs.List>
<Tabs.Item name="first" aria-controls="mytab-panel">
First Tab
</Tabs.Item>
<Tabs.Item name="second" aria-controls="mytab-panel">
Second Tab
</Tabs.Item>
</Tabs.List>
<Tabs.Panel hidden={undefined} id="mytab-panel">
{contents[model.state.activeTab]}
</Tabs.Panel>
</Tabs>
);
}
But not all compound components have state or behavior. They can exist as styled elements that expose their child elements directly. Card
is a good example:
import Card from '@workday/canvas-kit-react/card';
<Card>
<Card.Heading>Title</Card.Heading>
<Card.Body>Card contents</Card.Body>
</Card>
The following components have been upgraded to Compound Components as part of v5:
- Card
- Modal
- Popup
- Tabs
These components also use our createComponent
utility which is described in the following section. We will continue to update the remainder of applicable components to use the compound component pattern.
createComponent
We’ve been thinking a lot about creating common interfaces across our components and ensuring their APIs are consistent. We want all element components (components that render semantic elements) to have certain shared attributes baked into their APIs. Specifically, we want every element component to have:
- access to all semantic element props
- consistent, type-safe, ref forwarding
- consistent, type-safe, element casting with the
as
prop - consistent prop merging when mixing in element props
To accomplish this, we added createComponent
for our internal use, but we’re also exporting it so you can benefit as well! This transition is a work-in-progress. The following components have been converted to use createComponent
:
- Box
- Button
- IconButton
- Card
- Checkbox
- ColorInput
- ColorPreview
- Flex
- Modal
- Popup
- Radio
- Select
- Stack / HStack / VStack
- Switch
- Tabs
- TextInput
- TextArea
We will continue updating our other components to use createComponent
to provide a consistent, predictable API across our entire library.
Layout Components
Three new components have been added in v5 to make laying out UIs using Canvas tokens much easier!
Box
is a primitive component that provides a common, ergonomic API around Canvas design tokens. It is highly flexible, and its primary purpose is to build other components.
<Box as="a" href="https://workday.github.io/canvas-kit" margin=”s” paddingX=”m” background=”blueberry100”>
Canvas Kit Storybook
</Box>
Flex
(built onBox
) is a low-level layout component that provides a common, ergonomic API for building one-dimensional layouts with CSS Flexbox.
<Flex flexDirection="column" padding="xxxs">
<Flex
flex={1}
padding="xs"
marginX="xxxs"
justifyContent="center"
>
My Content
</Flex>
</Flex>
Stack
,HStack
, andVStack
(built onFlex
) are higher-level layout components that provide an ergonomic API for building one-dimensional layouts with consistent spacing between elements. They're built on top ofFlex
andBox
and have access to allFlexProps
andBoxProps
. Stack can align items in either a horizontal or vertical orientation.HStack
andVStack
will only align items in a horizontal or vertical orientation, respectively.
<HStack shouldWrapChildren spacing="s" backgroundColor="soap100" padding="s">
<Card heading="Diavola" body="sauce, smoked mozzarella, pepperoni, basil, chili flake" />
<Card
heading="Four Cheese"
body="mozzarella, gorgonzola, smoked mozzarella, parmesan, garlic oil "
/>
<Card
heading="Veggie"
body="sauce, mozzarella, artichokes, roasted red peppers, broccolini"
/>
</HStack>
New and Improved Type System
In the past, there has been a lot of confusion around which Canvas Kit type hierarchy to use. The “legacy” hierarchy provided in our main package mimicked the type styles used in UI-Platform. As we iterated towards this new system, we offered a “beta” hierarchy in Canvas Kit Labs. The “beta” hierarchy grew in usage to the point where the majority of product teams were using that. Since then, there has been confusion as to why the “legacy” hierarchy is still around and why the “beta” hierarchy is still in Labs. Well as of today, there is a single flexible, unified approach to type in Canvas Kit. This is an evolution of the “beta” hierarchy and is now in the @workday/canvas-kit-react/tokens
package.
The following map indicates how the old type hierarchies map to the new one.
Note: this new type system is intended to improve the overall legibility of our products. As you uptake the new hierarchy, rather than just doing a direct mapping, consider your use case. For example, if you were using Body 1 (14px) from the legacy system, don’t automatically use Subtext Large (14px). Consider something semantically equivalent (e.g. Body Small (16px) or Body Medium (18px)).
Popup Changes
In v4, Popups were already broken down into small parts of functionality which allows developers to create custom popup UIs. The Popup component in v4 was really more of a “Popup Card” with an animation applied to it and it was up to developers to handle Popup visibility, positioning (most likely using our Popper component), and behaviors. Popup is now fully a compound component with a model, subcomponents, and behaviors. The pieces that developers needed to connect are now cohesively subcomponents of the Popup. Here’s a simple example of the new Popup compound component API:
import React from 'react';
import {DeleteButton} from '@w...
v5.0.0-rc.0
2021-06-07
Components
- fix(tabs): Fix aria-selected for unselected tabs (#1033) @angadkaflay
- fix(tooltip): Allow aria-label pass-through in muted tooltips (#1037) @NicholasBoll
- fix(popup): Allow popups to be owners of each other (#1054) @csongnguyen
- fix(combobox): Fix Combobox RTL issue (#1064) @alanbsmith
- refactor: Button recategorization (#1034) @anicholls
- fix(popup): Allow tooltips to close alongside modals on click outside (#1074) @csongnguyen
- fix: Move InputProvider from tokens to common (#1076) @anicholls
- feat(common): Add Box Component @alanbsmith
- feat(comboxbox):Added default maxHeight to autocomplete container (#1079) @sraj
- feat: Forward refs for input components (#1068) @jamesfan
- feat(checkbox): Add aria-checked for accessibility and testability (#1045) @svagi
- chore: Upgrade Card to use Box (#1086) @NicholasBoll
- refactor(popup): Convert Popup to a compound component (#1065) @NicholasBoll
- fix(skeleton): Change skeleton animation to fade in and out (#1084) @willklein
- fix: Refactor/modal compound component (#1091) @NicholasBoll
feat: Remove Preview/Tokens & Upgrade CKR Labs Type Hierarchy (#1078) @alanbsmith
Documentation
- docs: Add better documentation to the
as
prop (#1046) @NicholasBoll - docs(tabs): Update single tabs panel example (#1047) @NicholasBoll
- docs: Update Create Compound Component docs (#1048) @NicholasBoll
- docs: Popup accessible example (#1056) @csongnguyen
- docs: Review v5 migration guide @jamesfan
Infrastructure
- chore: Bump y18n from 3.2.1 to 3.2.2 (#1011) @dependabot
- chore: Bump elliptic from 6.5.3 to 6.5.4 (#993) @dependabot
- ci: Fix Tooltip flaky visual test (#1035) @NicholasBoll
- ci: Upgrade to node 14 (#1044) @NicholasBoll
- chore: Upgrade storybook to v6.2.9 (#1055) @anicholls
- chore: Bump ssri, ua-parser-js, handlebars, lodash, and hosted-git-info (#1049) @dependabot
- fix: Prevent finding matches on the wrong imports (buttons codemod) @anicholls
- feat: Add Canvas Kit Preview and focus the purpose of CK Labs @anicholls
- fix: Update yarn.lock @alanbsmith
- ci: Fix font-loading issue by predownloading @NicholasBoll
- feat: Add package version in Storybook (#1082) @mihaelamiches
v5.0.0-beta.2
2021-04-26
You can find the breaking changes coming in v5 and the codemod provided to make upgrading easier in our v5 Migration Guide.
Components
- chore(card): Convert to a Compound Component and create codemod (#1028) @NicholasBoll
Infrastructure
- fix: Fix slash import paths (#1038) @NicholasBoll
- chore: Remove package.json from create component script (#1039) @NicholasBoll
v5.0.0-beta.1
2021-04-12
You can find the breaking changes coming in v5 and the codemod provided to make upgrading easier right here.
Components
- feat(common): Spread additional props on CanvasProvider @NicholasBoll
- chore(tabs): Convert to a compound component utility functions (#953) @NicholasBoll
- feat(tabs): Update Tabs list model to support passing index position (#990) @omasrii
- fix: Allow refs to be passed to createComponent components (#1009) @NicholasBoll
- chore: Refactor Button to use createComponent (#1017) @NicholasBoll
Codemods
- chore: Add slash imports (#992) @anicholls
- chore: Update spacing tokens + codemod (#1010) @alanbsmith
- fix: Scope buttonRef codemod to only Button components (#1022) @NicholasBoll
- chore: Rename core packages to tokens and add codemod @alanbsmith
- fix: Updates jscodeshift build directories @alanbsmith
Infrastructure
Docs
- docs: Add compound Component Creation Doc (#950) @NicholasBoll
- docs: Update v5 migration TOC and ordering @anicholls
- docs: Relocate supplemental docs to new docs module (#998) @anicholls
- chore: Deprecate CKCSS and update migration guide (#1000) @anicholls
Testing
- test: Add verifyComponent test helper and fix test types (#958) @NicholasBoll
CI
- ci: Fix error in prerelease logic in publish-canary script @anicholls
- ci: Update setup-node action and remove custom matcher (#994) @NicholasBoll
- ci: Fix canary dist-tag for prerelease canaries in slack message (#1003) @anicholls
v4.7.0
2021-04-12
Components
Infrastructure
- docs: Fix Github Pages story link in Specifications (#1005) @NicholasBoll
- fix: Fix specification story links @NicholasBoll
CSS
- feat: Add basic primary theme support to CSS components (#995) @aaronanderson