@workday/canvas-kit-docs 14.2.2 → 14.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/es6/lib/docs.js +1037 -7
  2. package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
  3. package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
  4. package/dist/mdx/10.0-UPGRADE-GUIDE.mdx +1 -1
  5. package/dist/mdx/5.0-UPGRADE-GUIDE.mdx +3 -3
  6. package/dist/mdx/7.0-UPGRADE-GUIDE.mdx +4 -4
  7. package/dist/mdx/8.0-UPGRADE-GUIDE.mdx +5 -5
  8. package/dist/mdx/9.0-UPGRADE-GUIDE.mdx +2 -2
  9. package/dist/mdx/CONTRIBUTING.mdx +4 -4
  10. package/dist/mdx/CREATING_COMPOUND_COMPONENTS.mdx +1 -1
  11. package/dist/mdx/labs-react/side-panel/SidePanel.mdx +85 -54
  12. package/dist/mdx/labs-react/side-panel/examples/AlwaysOpen.tsx +3 -3
  13. package/dist/mdx/labs-react/side-panel/examples/Basic.tsx +17 -37
  14. package/dist/mdx/labs-react/side-panel/examples/ExternalControl.tsx +6 -20
  15. package/dist/mdx/labs-react/side-panel/examples/{HiddenName.tsx → Heading.tsx} +4 -3
  16. package/dist/mdx/labs-react/side-panel/examples/OnStateTransition.tsx +3 -1
  17. package/dist/mdx/labs-react/side-panel/examples/RightOrigin.tsx +3 -9
  18. package/dist/mdx/labs-react/side-panel/examples/Variant.tsx +2 -8
  19. package/dist/mdx/preview-react/multi-select/MultiSelect.mdx +3 -3
  20. package/dist/mdx/preview-react/segmented-control/SegmentedControl.mdx +2 -2
  21. package/dist/mdx/preview-react/status-indicator/StatusIndicator.mdx +1 -1
  22. package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
  23. package/dist/mdx/react/banner/Banner.mdx +1 -1
  24. package/dist/mdx/react/breadcrumbs/Breadcrumbs.mdx +1 -1
  25. package/dist/mdx/react/card/card.mdx +1 -1
  26. package/dist/mdx/react/common/mdx/CompoundComponentUtilities.mdx +1 -1
  27. package/dist/mdx/react/layout/Box.mdx +13 -13
  28. package/dist/mdx/react/layout/Flex.mdx +3 -3
  29. package/dist/mdx/react/layout/Grid.mdx +3 -3
  30. package/dist/mdx/react/pagination/pagination.mdx +4 -4
  31. package/dist/mdx/react/popup/Popup.mdx +1 -1
  32. package/dist/mdx/react/select/Select.mdx +4 -4
  33. package/dist/mdx/react/tabs/Tabs.mdx +2 -2
  34. package/dist/mdx/react/text/Text.mdx +1 -1
  35. package/dist/mdx/react/toast/toast.mdx +1 -1
  36. package/package.json +6 -6
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "14.2.2",
22
- "@workday/canvas-kit-preview-react": "14.2.2",
23
- "@workday/canvas-kit-react": "14.2.2",
24
- "@workday/canvas-kit-react-fonts": "^14.2.2",
25
- "@workday/canvas-kit-styling": "14.2.2",
21
+ "@workday/canvas-kit-labs-react": "14.2.4",
22
+ "@workday/canvas-kit-preview-react": "14.2.4",
23
+ "@workday/canvas-kit-react": "14.2.4",
24
+ "@workday/canvas-kit-react-fonts": "^14.2.4",
25
+ "@workday/canvas-kit-styling": "14.2.4",
26
26
  "@workday/canvas-system-icons-web": "3.0.36",
27
27
  "@workday/canvas-tokens-web": "3.1.2"
28
28
  },
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "14.2.2",
22
- "@workday/canvas-kit-preview-react": "14.2.2",
23
- "@workday/canvas-kit-react": "14.2.2",
24
- "@workday/canvas-kit-react-fonts": "^14.2.2",
25
- "@workday/canvas-kit-styling": "14.2.2",
21
+ "@workday/canvas-kit-labs-react": "14.2.4",
22
+ "@workday/canvas-kit-preview-react": "14.2.4",
23
+ "@workday/canvas-kit-react": "14.2.4",
24
+ "@workday/canvas-kit-react-fonts": "^14.2.4",
25
+ "@workday/canvas-kit-styling": "14.2.4",
26
26
  "@workday/canvas-system-icons-web": "3.0.36",
27
27
  "@workday/canvas-tokens-web": "3.1.2"
28
28
  },
@@ -255,7 +255,7 @@ the target and popup to `4px`.
255
255
  **PR:** [#2309](https://github.com/Workday/canvas-kit/pull/2309)
256
256
 
257
257
  We've converted `Select` into a
258
- [compound component](/getting-started/for-developers/resources/compound-components/) which provides
258
+ [compound component](/get-started/for-developers/documentation/compound-components/) which provides
259
259
  a flexible API and access to its internals via its subcomponents.
260
260
 
261
261
  ```tsx
@@ -867,7 +867,7 @@ interface MyButtonProps extends ExtractProps<> {
867
867
 
868
868
  ### Card
869
869
 
870
- Card is now a [compound component](/getting-started/for-developers/resources/compound-components/)
870
+ Card is now a [compound component](/get-started/for-developers/documentation/compound-components/)
871
871
  composed of a `Card.Body` and an optional `Card.Heading`. This allows direct access to the heading
872
872
  and body elements.
873
873
 
@@ -1058,7 +1058,7 @@ There is no codemod for this change.
1058
1058
  ### Popups
1059
1059
 
1060
1060
  Popup has transitioned to a
1061
- [compound component](/getting-started/for-developers/resources/compound-components/), along with all
1061
+ [compound component](/get-started/for-developers/documentation/compound-components/), along with all
1062
1062
  Popup-based behavior hooks. What was a `Popup` in v4 is now a `Popup.Card` in v5. The target button
1063
1063
  and `Popper` components have also been converted to subcomponents of `Popup`.
1064
1064
 
@@ -1394,7 +1394,7 @@ const MyPopup = () => {
1394
1394
  ### Modal
1395
1395
 
1396
1396
  Modal has transitioned to a
1397
- [compound component](/getting-started/for-developers/resources/compound-components/). What was
1397
+ [compound component](/get-started/for-developers/documentation/compound-components/). What was
1398
1398
  `Modal` in v4 is now `Modal.Card` in v5.
1399
1399
 
1400
1400
  #### v4
@@ -513,7 +513,7 @@ creating `ActionBar.List` subcomponent and replacing all `ActionBar` children to
513
513
 
514
514
  ### Banner
515
515
 
516
- Banner is now a [compound component](/getting-started/for-developers/resources/compound-components/)
516
+ Banner is now a [compound component](/get-started/for-developers/documentation/compound-components/)
517
517
  composed of `Banner.Icon`, `Banner.Label`, and `Banner.ActionText`. This allows direct access to the
518
518
  icon, label, and text elements.
519
519
 
@@ -532,7 +532,7 @@ icon, label, and text elements.
532
532
  🤖 The codemod will rewrite your JSX to match the new API.
533
533
 
534
534
  Like all compound components, `Banner` is written using the
535
- [createComponent](/getting-started/for-developers/resources/creating-compound-components/#disclosurecontent-component)
535
+ [createComponent](/get-started/for-developers/documentation/creating-compound-components/#disclosurecontent-component)
536
536
  utility from our
537
537
  [common](https://github.com/Workday/canvas-kit/blob/ff77c5bd83e41c3ab2b9c55e41a8b7c1fde33a1b/modules/react/common/lib/utils/components.ts#L167)
538
538
  module; it supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html) and using the
@@ -741,7 +741,7 @@ buttons or other buttons that aren't supported by our standard button components
741
741
 
742
742
  We've updated `AccentIcon`, `AppletIcon`, `Graphic`, `Icon`, `Svg`, `SystemIcon`, and
743
743
  `SystemIconCircle` to use the
744
- [createComponent](/getting-started/for-developers/resources/creating-compound-components/#disclosurecontent-component)
744
+ [createComponent](/get-started/for-developers/documentation/creating-compound-components/#disclosurecontent-component)
745
745
  utility from our
746
746
  [common](https://github.com/Workday/canvas-kit/blob/ff77c5bd83e41c3ab2b9c55e41a8b7c1fde33a1b/modules/react/common/lib/utils/components.ts#L167)
747
747
  module; they now support [ref forwarding](https://reactjs.org/docs/forwarding-refs.html) and using
@@ -915,7 +915,7 @@ codemod.
915
915
  ### Segmented Control
916
916
 
917
917
  `SegmentedControl` is now a
918
- [compound component](/getting-started/for-developers/resources/compound-components/).
918
+ [compound component](/get-started/for-developers/documentation/compound-components/).
919
919
 
920
920
  Given the [removal of `IconButton`](#removal-of-icon-button) in v7, you'll now need to use
921
921
  `SegmentedControl.Button` instead.
@@ -191,7 +191,7 @@ const Example = styled('div')(
191
191
  ### Responsive Styles
192
192
 
193
193
  We've added a set of
194
- [responsive utilities](/getting-started/for-developers/resources/responsive-styling/) to facilitate
194
+ [responsive utilities](/get-started/for-developers/guides/responsive-styling/) to facilitate
195
195
  container-based and viewport-based responsive styling:
196
196
 
197
197
  - **useResponsiveContainerStyles**: A hook that allows developers to create container-based
@@ -253,7 +253,7 @@ return (
253
253
  We've added a new `@workday/canvas-kit-react/testing` slash import to house our testing utilities
254
254
  and components. You may find them useful for testing the different visual states of your components.
255
255
 
256
- View the [Testing](/utilities/testing/) documentation for more information. The example below
256
+ View the [Testing](/get-started/for-developers/documentation/testing#visual-tests) documentation for more information. The example below
257
257
  creates a visual states table of our `DeleteButton`. Each row renders a different size of
258
258
  `DeleteButton` with each column representing different combinations of the `disabled`, `hover`, and
259
259
  `active` states.
@@ -365,7 +365,7 @@ text with built-in support for our Canvas type tokens.
365
365
  We've added a new version of
366
366
  [`SegmentedControl`](https://workday.github.io/canvas-kit/?path=/docs/preview-segmented-control-react--basic)
367
367
  which has been redesigned as a
368
- [compound component](/getting-started/for-developers/resources/compound-components/) to the Preview
368
+ [compound component](/get-started/for-developers/documentation/compound-components/) to the Preview
369
369
  package. `SegmentedControl` represents a linear group of multiple buttons allowing the selection of
370
370
  a specific value and is best used for switching between different views of the same content.
371
371
 
@@ -417,7 +417,7 @@ You may still use `SegmentedControl` in the Main package, but note that it will
417
417
  We've added a new version of
418
418
  [`StatusIndicator`](https://workday.github.io/canvas-kit/?path=/docs/preview-status-indicator-react--basic)
419
419
  which has been redesigned as a
420
- [compound component](/getting-started/for-developers/resources/compound-components/) to the Preview
420
+ [compound component](/get-started/for-developers/documentation/compound-components/) to the Preview
421
421
  package. `StatusIndicator` is best used for helping the user quickly identify the status of a task,
422
422
  action, or page element.
423
423
 
@@ -671,7 +671,7 @@ const StyledBox = styled(Box)({
671
671
  ### Breadcrumbs
672
672
 
673
673
  `Breadcrumbs` has been promoted to the Main package. It now uses the list system from our
674
- [Collection API](/getting-started/for-developers/resources/collection-api/) which provides new
674
+ [Collection API](/get-started/for-developers/guides/collection-api/) which provides new
675
675
  overflow behavior based on container width.
676
676
 
677
677
  The following code-moddable changes have been made to the `Breadcrumbs` API (see below for
@@ -98,7 +98,7 @@ finished.
98
98
  ### Table
99
99
 
100
100
  We've introduced a new `Table`
101
- [compound component](/getting-started/for-developers/resources/compound-components/) to the Preview
101
+ [compound component](/get-started/for-developers/documentation/compound-components/) to the Preview
102
102
  package. `Table` is a compound component that is used to present information in a two-dimensional
103
103
  [table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) comprised of rows and
104
104
  columns of cells containing data.
@@ -374,7 +374,7 @@ previously in [Main](#main) (for reference, see
374
374
  [`Toast`](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-popups-toast--error) in
375
375
  [Main](#main) from v8).
376
376
 
377
- `Toast` is a [compound component](/getting-started/for-developers/resources/compound-components/)
377
+ `Toast` is a [compound component](/get-started/for-developers/documentation/compound-components/)
378
378
  which provides a flexible API and access to its internals via its subcomponents. It supports a new
379
379
  `mode` prop which applies the proper accessibility features to the component based on the desired
380
380
  mode: `status`, `alert`, or `dialog`.
@@ -148,7 +148,7 @@ dependencies, then it's required.
148
148
  Canvas Kit uses [Jest](https://jestjs.io/) and
149
149
  [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) to unit test
150
150
  our React components. For more information about our testing strategy and how we write unit tests,
151
- visit our [Testing Readme](/getting-started/for-developers/resources/testing/).
151
+ visit our [Testing Readme](/get-started/for-developers/documentation/testing/).
152
152
 
153
153
  Canvas Kit uses [Cypress](https://cypress.io) for UI tests. For info on why we chose Cypress, visit
154
154
  [Why Cypress?](https://github.com/Workday/canvas-kit/tree/master/cypress/WHY_CYPRESS.md) For more
@@ -188,9 +188,9 @@ Upon commit, [lint-staged](https://github.com/okonet/lint-staged) will run your
188
188
 
189
189
  If creating a React module, a new compound component will be created. To find out more about
190
190
  Compound Components, refer to
191
- [Compound Components](/getting-started/for-developers/resources/compound-components/). To find out
191
+ [Compound Components](/get-started/for-developers/documentation/compound-components/). To find out
192
192
  more about creating Compound Components, refer to
193
- [Creating Compound Components](/getting-started/for-developers/resources/creating-compound-components/).
193
+ [Creating Compound Components](/get-started/for-developers/documentation/creating-compound-components/).
194
194
 
195
195
  ### Exporting a Module
196
196
 
@@ -214,7 +214,7 @@ This will start the unit tests.
214
214
  ### Code Style Guide
215
215
 
216
216
  Refer to the
217
- [API & Pattern Guidelines](/getting-started/for-developers/resources/api-pattern-guidelines/).
217
+ [API & Pattern Guidelines](/get-started/for-developers/documentation/api-pattern-guidelines/).
218
218
 
219
219
  Rules are enforced using [ESLint](https://eslint.org) and code formatting is provided through
220
220
  [Prettier](https://prettier.io).
@@ -1,7 +1,7 @@
1
1
  # Building a Compound Component
2
2
 
3
3
  Refer to the
4
- [Compound Component documentation](/getting-started/for-developers/resources/compound-components/)
4
+ [Compound Component documentation](/get-started/for-developers/documentation/compound-components/)
5
5
  document to learn about what a compound component is.
6
6
 
7
7
  This document will go through building a simplified Disclosure component to help solidify the
@@ -1,6 +1,11 @@
1
- import {ExampleCodeBlock, SymbolDoc, Specifications, StorybookStatusIndicator} from '@workday/canvas-kit-docs';
1
+ import {
2
+ ExampleCodeBlock,
3
+ SymbolDoc,
4
+ Specifications,
5
+ StorybookStatusIndicator,
6
+ } from '@workday/canvas-kit-docs';
2
7
  import Basic from './examples/Basic';
3
- import HiddenName from './examples/HiddenName';
8
+ import Heading from './examples/Heading';
4
9
  import AlternatePanel from './examples/Variant';
5
10
  import ExternalControl from './examples/ExternalControl';
6
11
  import RightOrigin from './examples/RightOrigin';
@@ -23,7 +28,8 @@ yarn add @workday/canvas-kit-labs-react
23
28
 
24
29
  ## Migrating from Preview
25
30
 
26
- If you're migrating from `@workday/canvas-kit-preview-react/side-panel`, here are the key API changes:
31
+ If you're migrating from `@workday/canvas-kit-preview-react/side-panel`, here are the key API
32
+ changes:
27
33
 
28
34
  ### Import Changes
29
35
 
@@ -37,27 +43,27 @@ import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-
37
43
 
38
44
  ### Hook API Changes
39
45
 
40
- | Preview (`useSidePanel`) | Labs (`useSidePanelModel`) |
41
- |--------------------------|----------------------------|
42
- | `initialExpanded: boolean` | `initialTransitionState: 'expanded' \| 'collapsed'` |
43
- | `origin: 'left' \| 'right'` | `origin: 'start' \| 'end'` |
44
- | Returns `expanded: boolean` | Returns `model.state.transitionState` |
45
- | Returns `setExpanded(bool)` | Use `model.events.expand()` / `model.events.collapse()` |
46
- | Returns `panelProps` to spread | Props applied automatically via `elemPropsHook` |
47
- | Returns `labelProps` to spread | Use `id={model.state.labelId}` on label element |
46
+ | Preview (`useSidePanel`) | Labs (`useSidePanelModel`) |
47
+ | -------------------------------- | ------------------------------------------------------- |
48
+ | `initialExpanded: boolean` | `initialTransitionState: 'expanded' \| 'collapsed'` |
49
+ | `origin: 'left' \| 'right'` | `origin: 'start' \| 'end'` |
50
+ | Returns `expanded: boolean` | Returns `model.state.transitionState` |
51
+ | Returns `setExpanded(bool)` | Use `model.events.expand()` / `model.events.collapse()` |
52
+ | Returns `panelProps` to spread | Props applied automatically via `elemPropsHook` |
53
+ | Returns `labelProps` to spread | Use `id={model.state.labelId}` on label element |
48
54
  | Returns `controlProps` to spread | Props applied automatically to `SidePanel.ToggleButton` |
49
55
 
50
56
  ### Component API Changes
51
57
 
52
- | Preview | Labs |
53
- |---------|------|
54
- | `<SidePanel {...panelProps}>` | `<SidePanel model={model}>` or just `<SidePanel>` |
55
- | `<SidePanel.ToggleButton {...controlProps} />` | `<SidePanel.ToggleButton />` |
56
- | `<Heading {...labelProps}>` | `<Heading id={model.state.labelId}>` |
57
- | `expanded` prop on SidePanel | Managed by model's `transitionState` |
58
- | `touched` prop on SidePanel | Managed internally |
59
- | `onExpandedChange` callback | Use `onStateTransition` and derive expanded state |
60
- | `onStateTransition` on component | `onStateTransition` on model config |
58
+ | Preview | Labs |
59
+ | ---------------------------------------------- | ------------------------------------------------- |
60
+ | `<SidePanel {...panelProps}>` | `<SidePanel model={model}>` or just `<SidePanel>` |
61
+ | `<SidePanel.ToggleButton {...controlProps} />` | `<SidePanel.ToggleButton />` |
62
+ | `<Heading {...labelProps}>` | `<Heading id={model.state.labelId}>` |
63
+ | `expanded` prop on SidePanel | Managed by model's `transitionState` |
64
+ | `touched` prop on SidePanel | Managed internally |
65
+ | `onExpandedChange` callback | Use `onStateTransition` and derive expanded state |
66
+ | `onStateTransition` on component | `onStateTransition` on model config |
61
67
 
62
68
  ### Code Migration Example
63
69
 
@@ -67,17 +73,17 @@ const {expanded, panelProps, labelProps, controlProps} = useSidePanel({
67
73
  initialExpanded: false,
68
74
  });
69
75
 
70
- <SidePanel {...panelProps} origin="right" onExpandedChange={(exp) => console.log(exp)}>
76
+ <SidePanel {...panelProps} origin="right" onExpandedChange={exp => console.log(exp)}>
71
77
  <SidePanel.ToggleButton {...controlProps} />
72
78
  <Heading {...labelProps}>Panel Title</Heading>
73
79
  {expanded && <Content />}
74
- </SidePanel>
80
+ </SidePanel>;
75
81
 
76
82
  // After (labs-react)
77
83
  const model = useSidePanelModel({
78
84
  initialTransitionState: 'collapsed',
79
85
  origin: 'end',
80
- onStateTransition: (state) => {
86
+ onStateTransition: state => {
81
87
  const isExpanded = state === 'expanded' || state === 'expanding';
82
88
  console.log(isExpanded);
83
89
  },
@@ -87,21 +93,25 @@ const model = useSidePanelModel({
87
93
  <SidePanel.ToggleButton />
88
94
  <Heading id={model.state.labelId}>Panel Title</Heading>
89
95
  {model.state.transitionState === 'expanded' && <Content />}
90
- </SidePanel>
96
+ </SidePanel>;
91
97
  ```
92
98
 
93
99
  ### Checking Expanded State
94
100
 
95
101
  ```tsx
96
102
  // Before (preview-react)
97
- if (expanded) { /* ... */ }
103
+ if (expanded) {
104
+ /* ... */
105
+ }
98
106
 
99
107
  // After (labs-react) - for exact state
100
- if (model.state.transitionState === 'expanded') { /* ... */ }
108
+ if (model.state.transitionState === 'expanded') {
109
+ /* ... */
110
+ }
101
111
 
102
112
  // After (labs-react) - including animation states
103
- const isExpanded = model.state.transitionState === 'expanded' ||
104
- model.state.transitionState === 'expanding';
113
+ const isExpanded =
114
+ model.state.transitionState === 'expanded' || model.state.transitionState === 'expanding';
105
115
  ```
106
116
 
107
117
  ## Usage
@@ -111,14 +121,9 @@ const isExpanded = model.state.transitionState === 'expanded' ||
111
121
  `SidePanel` is composed of three parts:
112
122
 
113
123
  - The panel container (with an optional `model` prop)
114
- - An accessible name (using `model.state.labelId` on a visible or hidden element)
124
+ - A heading (`SidePanel.Heading`) for the panel that is visually hidden when the panel is collapsed
115
125
  - A toggle button (`SidePanel.ToggleButton`) to control the expand / collapse states
116
126
 
117
- The component automatically handles:
118
- - ARIA attributes (`aria-labelledby`, `aria-controls`, `aria-expanded`)
119
- - Transition states (`expanding`, `expanded`, `collapsing`, `collapsed`)
120
- - CSS transitions for smooth animations
121
-
122
127
  Bidirectional support is built into `SidePanel`. As seen in the example below, CSS Flexbox flips the
123
128
  page layout and the panel's contents. `SidePanel` also has logic to flip the position and direction
124
129
  of the `ToggleButton` as well as the direction of the expand / collapse animation. If you're using
@@ -129,13 +134,12 @@ logic or styling for bidirectional support.
129
134
 
130
135
  ### Hidden Name
131
136
 
132
- `SidePanel` must always have an accessible label for both the HTML `<section>` container and the
133
- `ToggleButton`. The label element must have `id={model.state.labelId}` to properly connect it to
134
- the panel and toggle button via `aria-labelledby`. The label can be visually hidden using
135
- `AccessibleHide` which relies on CSS properties to hide text visually while keeping it available
136
- for screen readers.
137
+ `SidePanel`'s `<section>` element container should always have an accessible name to help screen
138
+ reader users understand the purpose of the panel. For this reason, we recommend using the
139
+ `SidePanel.Heading` component and setting the `hidden` prop to `true`. This will visually hide the
140
+ heading while keeping it accessible to screen readers.
137
141
 
138
- <ExampleCodeBlock code={HiddenName} />
142
+ <ExampleCodeBlock code={Heading} />
139
143
 
140
144
  ### Alternate Variant
141
145
 
@@ -148,8 +152,8 @@ used (this case is covered in the Examples section).
148
152
  ### External Control
149
153
 
150
154
  Sometimes you'll want to control `SidePanel`'s expand / collapse behavior from outside the
151
- component. You can use the model's events (`model.events.expand()` and `model.events.collapse()`)
152
- to programmatically control the panel.
155
+ component. You can use the model's events (`model.events.expand()` and `model.events.collapse()`) to
156
+ programmatically control the panel.
153
157
 
154
158
  #### Notes about accessibility
155
159
 
@@ -168,9 +172,9 @@ state and call `model.events.expand()` or `model.events.collapse()` on click.
168
172
  ### Right Origin
169
173
 
170
174
  By default, `SidePanel` uses a `start` origin (left in LTR, right in RTL). This sets the
171
- `ToggleButton`'s position and direction as well as the direction of the animation. You can set
172
- the origin to `"end"` to flip these. The origin uses logical properties (`start`/`end`) for
173
- proper bidirectional support.
175
+ `ToggleButton`'s position and direction as well as the direction of the animation. You can set the
176
+ origin to `"end"` to flip these. The origin uses logical properties (`start`/`end`) for proper
177
+ bidirectional support.
174
178
 
175
179
  <ExampleCodeBlock code={RightOrigin} />
176
180
 
@@ -183,26 +187,53 @@ If you do not need `SidePanel`'s expand / collapse behavior, you can simply omit
183
187
  ### Deriving Expanded State
184
188
 
185
189
  If you need a simple boolean `expanded` state (similar to the preview-react `onExpandedChange`
186
- callback), you can derive it from the `transitionState` using the `onStateTransition` callback
187
- on the model.
190
+ callback), you can derive it from the `transitionState` using the `onStateTransition` callback on
191
+ the model.
188
192
 
189
193
  ### onStateTransition
190
194
 
191
195
  The `onStateTransition` callback is called whenever the panel's transition state changes. This
192
- includes all four states: `expanding`, `expanded`, `collapsing`, and `collapsed`. You can pass
193
- this callback directly to the `SidePanel` component or to the `useSidePanelModel` hook.
196
+ includes all four states: `expanding`, `expanded`, `collapsing`, and `collapsed`. You can pass this
197
+ callback directly to the `SidePanel` component or to the `useSidePanelModel` hook.
194
198
 
195
199
  The transition flow is:
200
+
196
201
  1. **Collapsing**: `expanded` → `collapsing` → `collapsed`
197
202
  2. **Expanding**: `collapsed` → `expanding` → `expanded`
198
203
 
199
204
  This is useful for:
205
+
200
206
  - Triggering side effects when the panel state changes
201
207
  - Syncing the panel state with external state management
202
208
  - Animating child components based on the transition state
203
209
 
204
210
  <ExampleCodeBlock code={OnStateTransition} />
205
211
 
212
+ ### Accessibility
213
+
214
+ `SidePanel` renders a `<section>` element with an accessible name provided by `aria-labelledby`,
215
+ which references the `SidePanel.Heading` component. This ensures screen reader users understand the
216
+ purpose of the panel.
217
+
218
+ #### Panel and Heading
219
+
220
+ - The `SidePanel.Heading` provides the accessible name for the panel via `aria-labelledby`
221
+ - When the panel is collapsed, the heading is automatically hidden visually but remains accessible
222
+ to screen readers
223
+ - Use the `hidden` prop on `SidePanel.Heading` if you want the heading always visually hidden
224
+
225
+ #### Toggle Button
226
+
227
+ - `SidePanel.ToggleButton` automatically includes `aria-controls` (references the panel's `id`),
228
+ `aria-pressed` (indicates current state), and `aria-describedby` (references the panel's heading)
229
+ - Developers must provide a static `aria-label` string on `SidePanel.ToggleButton` to describe the
230
+ button's purpose (e.g., "Collapse View"). Avoid using ambiguous terms like "Toggle" in the label.
231
+ Since `aria-pressed` communicates the state, avoid dynamically updating `aria-label`
232
+ - The button includes a Tooltip with customizable text via `tooltipTextExpand` and
233
+ `tooltipTextCollapse` props (defaults: "Expand View" and "Collapse View")
234
+ - For optimal keyboard navigation, place `SidePanel.ToggleButton` as the first focusable element in
235
+ the panel
236
+
206
237
  ## Component API
207
238
 
208
239
  <SymbolDoc name="SidePanel" fileName="/labs-react/" />
@@ -221,17 +252,17 @@ import {useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
221
252
  const model = useSidePanelModel({
222
253
  initialTransitionState: 'collapsed',
223
254
  origin: 'end',
224
- onStateTransition: (state) => console.log('State:', state),
255
+ onStateTransition: state => console.log('State:', state),
225
256
  });
226
257
 
227
258
  // Access state
228
259
  model.state.transitionState; // 'expanded' | 'expanding' | 'collapsed' | 'collapsing'
229
- model.state.panelId; // unique ID for the panel
230
- model.state.labelId; // unique ID for the label
260
+ model.state.panelId; // unique ID for the panel
261
+ model.state.labelId; // unique ID for the label
231
262
 
232
263
  // Trigger events
233
- model.events.expand(); // Set to expanded (no animation)
234
- model.events.collapse(); // Set to collapsed (no animation)
264
+ model.events.expand(); // Set to expanded (no animation)
265
+ model.events.collapse(); // Set to collapsed (no animation)
235
266
  model.events.handleAnimationStart(); // Start expand/collapse animation
236
267
  ```
237
268
 
@@ -2,7 +2,7 @@ import {AccentIcon} from '@workday/canvas-kit-react/icon';
2
2
  import {rocketIcon} from '@workday/canvas-accent-icons-web';
3
3
  import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
4
4
  import {Flex} from '@workday/canvas-kit-react/layout';
5
- import {Heading, Text} from '@workday/canvas-kit-react/text';
5
+ import {Text} from '@workday/canvas-kit-react/text';
6
6
  import {system} from '@workday/canvas-tokens-web';
7
7
  import {createStyles, px2rem} from '@workday/canvas-kit-styling';
8
8
 
@@ -37,9 +37,9 @@ export default () => {
37
37
  <SidePanel model={model}>
38
38
  <Flex cs={stylesOverride.panelContainer}>
39
39
  <AccentIcon icon={rocketIcon} cs={stylesOverride.accentIcon} />
40
- <Heading size="small" cs={stylesOverride.panelHeading} id={model.state.labelId}>
40
+ <SidePanel.Heading size="small" cs={stylesOverride.panelHeading}>
41
41
  Tasks Panel
42
- </Heading>
42
+ </SidePanel.Heading>
43
43
  </Flex>
44
44
  </SidePanel>
45
45
  <Flex as="main" cs={stylesOverride.mainContent}>
@@ -1,54 +1,34 @@
1
1
  import * as React from 'react';
2
- import {SecondaryButton} from '@workday/canvas-kit-react/button';
2
+
3
3
  import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
4
4
  import {Flex} from '@workday/canvas-kit-react/layout';
5
- import {Heading, Text} from '@workday/canvas-kit-react/text';
6
5
  import {AccentIcon} from '@workday/canvas-kit-react/icon';
7
- import {rocketIcon} from '@workday/canvas-accent-icons-web';
8
6
  import {createStyles, px2rem} from '@workday/canvas-kit-styling';
7
+ import {rocketIcon} from '@workday/canvas-accent-icons-web';
9
8
  import {system} from '@workday/canvas-tokens-web';
10
9
 
11
- const stylesOverride = {
12
- viewPortContainer: createStyles({
13
- height: px2rem(320),
14
- }),
15
- panel: createStyles({
16
- alignItems: 'center',
17
- padding: system.space.x4,
18
- }),
19
- accentIcon: createStyles({
20
- marginInlineEnd: system.space.x4,
21
- }),
22
- mainContent: createStyles({
23
- alignItems: 'center',
24
- justifyContent: 'center',
25
- flexDirection: 'column',
26
- flex: 1,
27
- flexBasis: 'auto',
28
- }),
29
- };
10
+ const flexHeadingStyles = createStyles({
11
+ alignItems: 'center',
12
+ gap: system.space.x2,
13
+ });
14
+
15
+ const viewPortStyles = createStyles({
16
+ height: px2rem(320),
17
+ });
30
18
 
31
19
  export default () => {
32
20
  const model = useSidePanelModel();
33
21
 
34
22
  return (
35
- <Flex cs={stylesOverride.viewPortContainer}>
23
+ <Flex cs={viewPortStyles}>
36
24
  <SidePanel model={model}>
37
- <SidePanel.ToggleButton />
38
- <Flex cs={stylesOverride.panel}>
39
- {model.state.transitionState === 'expanded' && (
40
- <Flex cs={stylesOverride.accentIcon}>
41
- <AccentIcon icon={rocketIcon} />
42
- </Flex>
43
- )}
44
- <Heading
45
- size="small"
46
- id={model.state.labelId}
47
- hidden={model.state.transitionState === 'collapsed' ? true : undefined}
48
- >
25
+ <SidePanel.Heading size="small">
26
+ <Flex cs={flexHeadingStyles}>
27
+ <AccentIcon icon={rocketIcon} />
49
28
  Tasks Panel
50
- </Heading>
51
- </Flex>
29
+ </Flex>
30
+ </SidePanel.Heading>
31
+ <SidePanel.ToggleButton aria-label="Collapse View" />
52
32
  </SidePanel>
53
33
  </Flex>
54
34
  );
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
3
3
  import {Flex} from '@workday/canvas-kit-react/layout';
4
- import {Heading, Text} from '@workday/canvas-kit-react/text';
4
+ import {Text} from '@workday/canvas-kit-react/text';
5
5
  import {SecondaryButton} from '@workday/canvas-kit-react/button';
6
6
  import {createStyles, px2rem} from '@workday/canvas-kit-styling';
7
7
  import {system} from '@workday/canvas-tokens-web';
@@ -26,19 +26,6 @@ const stylesOverride = {
26
26
  }),
27
27
  };
28
28
 
29
- /*
30
- * NOTE TO DEV:
31
- * Spreading the `controlProps` onto an external control creates serious accessibility issues.
32
- * - `aria-labelledby` id reference is invalid when the SidePanel is collapsed
33
- * - `aria-labelledby` will change the name of "Toggle Side Panel" button to "Tasks Panel"
34
- * - `aria-expanded` won't make sense to screen reader users when the expanded SidePanel content isn't following the control
35
- * - `aria-controls` is unsupported by screen readers and will not allow users to navigate to the controlled content
36
- *
37
- * SOLUTION:
38
- * - Pass the `controlProps` click handler function down to the external control component.
39
- * - Add a toggle state to Button components with `aria-pressed` for screen readers,
40
- * - OR use a similar toggle input like Checkbox or Switch.
41
- */
42
29
  export default () => {
43
30
  const model = useSidePanelModel({
44
31
  initialTransitionState: 'collapsed',
@@ -48,13 +35,12 @@ export default () => {
48
35
  return (
49
36
  <Flex cs={stylesOverride.viewport}>
50
37
  <SidePanel model={model}>
51
- <SidePanel.ToggleButton />
38
+ <SidePanel.ToggleButton aria-label="Collapse View" />
39
+ <SidePanel.Heading size="small" cs={stylesOverride.panelHeading}>
40
+ Task Panel
41
+ </SidePanel.Heading>
52
42
  {model.state.transitionState === 'expanded' && (
53
- <Flex cs={stylesOverride.panel}>
54
- <Heading size="small" cs={stylesOverride.panelHeading} id={model.state.labelId}>
55
- Tasks Panel
56
- </Heading>
57
- </Flex>
43
+ <Flex cs={stylesOverride.panel}>Contents</Flex>
58
44
  )}
59
45
  </SidePanel>
60
46
  <Flex as="main" cs={stylesOverride.main}>
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
3
3
  import {Flex} from '@workday/canvas-kit-react/layout';
4
- import {AccessibleHide} from '@workday/canvas-kit-react/common';
5
4
  import {Text} from '@workday/canvas-kit-react/text';
6
5
  import {createStyles, px2rem} from '@workday/canvas-kit-styling';
7
6
 
@@ -28,8 +27,10 @@ export default () => {
28
27
  return (
29
28
  <Flex cs={stylesOverride.viewport}>
30
29
  <SidePanel model={model}>
31
- <SidePanel.ToggleButton />
32
- <AccessibleHide id={model.state.labelId}>Hidden Title</AccessibleHide>
30
+ <SidePanel.ToggleButton aria-label="Collapse View" />
31
+ <SidePanel.Heading hidden size="small">
32
+ Tasks Panel
33
+ </SidePanel.Heading>
33
34
  </SidePanel>
34
35
  <Flex as="main" cs={stylesOverride.main}>
35
36
  <Text as="p" typeLevel="body.large">