@workday/canvas-kit-docs 14.0.0-alpha.1147-next.0 → 14.0.0-alpha.1149-next.0

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 (29) hide show
  1. package/dist/es6/lib/docs.js +320 -550
  2. package/dist/mdx/14.0-UPGRADE-GUIDE.mdx +112 -3
  3. package/dist/mdx/react/card/card.mdx +19 -1
  4. package/dist/mdx/react/card/examples/Borderless.tsx +23 -0
  5. package/dist/mdx/react/card/examples/Filled.tsx +14 -0
  6. package/dist/mdx/react/card/examples/Stencils.tsx +2 -1
  7. package/dist/mdx/react/modal/examples/Basic.tsx +1 -1
  8. package/dist/mdx/react/modal/examples/BodyOverflow.tsx +1 -1
  9. package/dist/mdx/react/modal/examples/CustomFocus.tsx +1 -1
  10. package/dist/mdx/react/modal/examples/FormModal.tsx +1 -1
  11. package/dist/mdx/react/modal/examples/FullOverflow.tsx +1 -1
  12. package/dist/mdx/react/modal/examples/ReturnFocus.tsx +1 -1
  13. package/dist/mdx/react/modal/examples/WithoutCloseIcon.tsx +1 -1
  14. package/dist/mdx/react/popup/examples/Basic.tsx +1 -1
  15. package/dist/mdx/react/popup/examples/FocusRedirect.tsx +1 -1
  16. package/dist/mdx/react/popup/examples/FocusTrap.tsx +1 -1
  17. package/dist/mdx/react/popup/examples/InitialFocus.tsx +1 -1
  18. package/dist/mdx/react/popup/examples/NestedPopups.tsx +2 -2
  19. package/dist/mdx/react/popup/examples/PopupWithFallbackPlacements.tsx +4 -4
  20. package/dist/mdx/react/popup/examples/RTL.tsx +1 -1
  21. package/dist/mdx/react/tooltip/examples/Placements.tsx +1 -0
  22. package/package.json +6 -6
  23. package/dist/mdx/preview-react/menu/Menu.mdx +0 -105
  24. package/dist/mdx/preview-react/menu/examples/Basic.tsx +0 -74
  25. package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +0 -67
  26. package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +0 -15
  27. package/dist/mdx/preview-react/menu/examples/Headers.tsx +0 -32
  28. package/dist/mdx/preview-react/menu/examples/Icons.tsx +0 -26
  29. package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +0 -15
@@ -9,8 +9,11 @@ any questions.
9
9
  - [Codemod](#codemod)
10
10
  - [Instructions](#instructions)
11
11
  - [Component Updates](#component-updates)
12
- - [Styling API and CSS Tokens](#styling-api-and-css-tokens)
12
+ - [Styling Changes](#styling-changes)
13
+ - [Card](#card)
13
14
  - [SearchForm](#search-form)
15
+ - [Removals](#removals)
16
+ - [Menu (preview)](#menu-preview)
14
17
  - [Troubleshooting](#troubleshooting)
15
18
  - [Glossary](#glossary)
16
19
  - [Main](#main)
@@ -78,7 +81,9 @@ yarn remove @workday/canvas-kit-codemod
78
81
  > after executing the codemod, as its resulting formatting (spacing, quotes, etc.) may not match
79
82
  > your project conventions.
80
83
 
81
- ## Styling API and Canvas Tokens 💅
84
+ ## Component Updates
85
+
86
+ ### Styling Changes 💅
82
87
 
83
88
  Several components have been refactored to use our Canvas tokens and styling API. The React
84
89
  interface has not changed, but Canvas Tokens are now used for dynamic properties.
@@ -98,7 +103,96 @@ The following components have been updated:
98
103
  - `ToolbarDropdownButton` [#3293](https://github.com/Workday/canvas-kit/pull/3293)
99
104
  - `ToolbarIconButton` [#3293](https://github.com/Workday/canvas-kit/pull/3293)
100
105
 
101
- ## Search Form 🚨
106
+ ### Card 🚨
107
+
108
+ **PR:** [#3350](https://github.com/Workday/canvas-kit/pull/3350)
109
+
110
+ We've rebranded the `Card` component to align with our new brand directions and provide better
111
+ visual hierarchy and more flexible styling options. The following changes have been made:
112
+
113
+ #### Default Card No Longer Has Shadow
114
+
115
+ The default `Card` variant no longer includes a shadow, creating a cleaner, flatter appearance that
116
+ aligns with our new brand's emphasis on simplicity and clarity. This is a **visual breaking change**
117
+ that may affect your application's visual hierarchy. If your design requires shadow you can added
118
+ through `cs` prop.
119
+
120
+ **Before in v13**
121
+
122
+ ```tsx
123
+ <Card>
124
+ <Card.Heading>Card Title</Card.Heading>
125
+ <Card.Body>Card content with shadow</Card.Body>
126
+ </Card>
127
+ ```
128
+
129
+ **After in v14**
130
+
131
+ ```tsx
132
+ <Card cs={{boxShadow: system.depth[1]}}>
133
+ <Card.Heading>Card Title</Card.Heading>
134
+ <Card.Body>Card content with shadow</Card.Body>
135
+ </Card>
136
+ ```
137
+
138
+ #### New Card Variants
139
+
140
+ We've added two new variants to provide more styling flexibility:
141
+
142
+ - **`borderless`**: Use this variant when placing cards on colored backgrounds where you want the
143
+ card to blend seamlessly without borders or shadows.
144
+ - **`filled`**: Use this variant when you need a card with a grayish background to create visual
145
+ separation from the page background.
146
+
147
+ The `variant` prop is optional - if no variant is specified, the card will use the default styling.
148
+
149
+ ```tsx
150
+ // Default card (no variant prop needed)
151
+ <Card>
152
+ <Card.Heading>Default Card</Card.Heading>
153
+ <Card.Body>Default styling with borders, no shadow</Card.Body>
154
+ </Card>
155
+
156
+ // Borderless variant for colored backgrounds
157
+ <Card variant="borderless">
158
+ <Card.Heading>Card on Colored Background</Card.Heading>
159
+ <Card.Body>Content blends with background</Card.Body>
160
+ </Card>
161
+
162
+ // Filled variant with grayish background
163
+ <Card variant="filled">
164
+ <Card.Heading>Card with grayish Background</Card.Heading>
165
+ <Card.Body>Content with visual separation</Card.Body>
166
+ </Card>
167
+ ```
168
+
169
+ #### Gap Instead of Margins
170
+
171
+ We've replaced the individual margins on `Card.Heading` and `Card.Body` with a `gap` prop on the
172
+ card container. The card now uses `display: flex` with `flex-direction: column` by default, and the
173
+ `gap` prop provides consistent spacing between all direct children. This provides more consistent
174
+ spacing and better control over the layout. This is a **visual breaking change** that may affect the
175
+ spacing between card elements.
176
+
177
+ **Before in v13**
178
+
179
+ ```tsx
180
+ <Card>
181
+ <Card.Heading marginBlock="zero">Title</Card.Heading>
182
+ <Card.Body marginBlock="zero">Card without any spacing</Card.Body>
183
+ </Card>
184
+ ```
185
+
186
+ **After in v14**
187
+
188
+ ```tsx
189
+ <Card cs={{gap: system.space.zero}}>
190
+ <Card.Heading>Title</Card.Heading>
191
+ <Card.Body>Card without any spacing</Card.Body>
192
+ </Card>
193
+ ```
194
+
195
+ ### Search Form 🚨
102
196
 
103
197
  **PR:** [#3303](https://github.com/Workday/canvas-kit/pull/3303)
104
198
 
@@ -151,6 +245,21 @@ const customTheme = {
151
245
  This **should not** affect the way you use the type unless you're passing a `number` of `0`, `1`
152
246
  or `2` to the `searchTheme` prop.
153
247
 
248
+ ## Removals
249
+
250
+ Removals are deletions from our codebase and you can no longer consume this component. We've either
251
+ promoted or replaced a component or utility.
252
+
253
+ ### Menu (preview)
254
+
255
+ **PR:** [#3353](https://github.com/Workday/canvas-kit/pull/3353)
256
+
257
+ We've removed `Menu` from `@workday/canvas-kit-preview-react` package. Please use
258
+ [Menu](https://workday.github.io/canvas-kit/?path=/docs/components-popups-menu--docs) from
259
+ `@workday/canvas-kit-react` instead.
260
+
261
+ ---
262
+
154
263
  ## Troubleshooting
155
264
 
156
265
  - When upgrading to the latest major version of Canvas Kit, all related Canvas Kit packages should
@@ -1,5 +1,7 @@
1
- import { ExampleCodeBlock, SymbolDoc } from '@workday/canvas-kit-docs';
1
+ import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
2
2
  import Basic from './examples/Basic';
3
+ import Borderless from './examples/Borderless';
4
+ import Filled from './examples/Filled';
3
5
  import WithCustomStyles from './examples/CustomStyles';
4
6
  import WithStencils from './examples/Stencils';
5
7
 
@@ -27,6 +29,22 @@ yarn add @workday/canvas-kit-react
27
29
 
28
30
  <ExampleCodeBlock code={Basic} />
29
31
 
32
+ ### Borderless Example
33
+
34
+ The `borderless` variant removes the border from the Card, creating a cleaner appearance while
35
+ maintaining the same internal spacing and structure. Use this variant when placing cards on colored
36
+ backgrounds where you want the card to blend seamlessly without borders or shadows.
37
+
38
+ <ExampleCodeBlock code={Borderless} />
39
+
40
+ ### Filled Example
41
+
42
+ The `filled` variant adds a background color to the Card, creating a more prominent appearance while
43
+ maintaining the same internal spacing and structure. Use this variant when you need a card with a
44
+ grayish background to create visual separation from the page background.
45
+
46
+ <ExampleCodeBlock code={Filled} />
47
+
30
48
  ### Custom Styles
31
49
 
32
50
  Card and its subcomponents support custom styling via the `cs` prop. For more information, check our
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import {Card} from '@workday/canvas-kit-react/card';
3
+ import {createStyles} from '@workday/canvas-kit-styling';
4
+ import {system} from '@workday/canvas-tokens-web';
5
+
6
+ const styles = createStyles({
7
+ background: system.color.bg.alt.softer,
8
+ padding: system.space.x4,
9
+ });
10
+
11
+ export default () => {
12
+ return (
13
+ <div className={styles}>
14
+ <Card variant="borderless">
15
+ <Card.Heading>Canvas Supreme</Card.Heading>
16
+ <Card.Body>
17
+ Our house special supreme pizza includes pepperoni, sausage, bell peppers, mushrooms,
18
+ onions, and oregano.
19
+ </Card.Body>
20
+ </Card>
21
+ </div>
22
+ );
23
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import {Card} from '@workday/canvas-kit-react/card';
3
+
4
+ export default () => {
5
+ return (
6
+ <Card variant="filled">
7
+ <Card.Heading>Canvas Supreme</Card.Heading>
8
+ <Card.Body>
9
+ Our house special supreme pizza includes pepperoni, sausage, bell peppers, mushrooms,
10
+ onions, and oregano.
11
+ </Card.Body>
12
+ </Card>
13
+ );
14
+ };
@@ -11,6 +11,8 @@ const menuCardStencil = createStencil({
11
11
  flexDirection: 'column',
12
12
  padding: system.space.zero,
13
13
  maxWidth: px2rem(320),
14
+ boxShadow: system.depth[1],
15
+ overflow: 'hidden',
14
16
  },
15
17
  });
16
18
 
@@ -22,7 +24,6 @@ const menuCardHeroStencil = createStencil({
22
24
  aspectRatio: '1',
23
25
  maxHeight: px2rem(80),
24
26
  padding: system.space.x2,
25
- borderRadius: `${system.shape.x2} ${system.shape.x2} 0 0`,
26
27
  },
27
28
  });
28
29
 
@@ -24,7 +24,7 @@ export default () => {
24
24
  software and associated documentation files (the "Software").
25
25
  </Box>
26
26
  </Modal.Body>
27
- <Flex gap="s" padding="xxs" marginTop="xxs">
27
+ <Flex gap="s" padding="xxs">
28
28
  <Modal.CloseButton as={PrimaryButton} onClick={handleAcknowledge}>
29
29
  Acknowledge
30
30
  </Modal.CloseButton>
@@ -81,7 +81,7 @@ export default () => {
81
81
  ut aliquam purus sit.
82
82
  </p>
83
83
  </Modal.Body>
84
- <Flex gap="s" padding="xxs" marginTop="xxs">
84
+ <Flex gap="s" padding="xxs">
85
85
  <Modal.CloseButton as={PrimaryButton} onClick={handleAcknowledge}>
86
86
  Acknowledge
87
87
  </Modal.CloseButton>
@@ -39,7 +39,7 @@ export default () => {
39
39
  />
40
40
  </FormField>
41
41
  </Modal.Body>
42
- <Flex gap="s" padding="xxs" marginTop="xxs">
42
+ <Flex gap="s" padding="xxs">
43
43
  <Modal.CloseButton as={PrimaryButton} onClick={handleAcknowledge}>
44
44
  Acknowledge
45
45
  </Modal.CloseButton>
@@ -41,7 +41,7 @@ export default () => {
41
41
  <FormField.Input as={TextInput} name="last" />
42
42
  </FormField>
43
43
  </Modal.Body>
44
- <Flex gap="s" padding="xxs" marginTop="xxs">
44
+ <Flex gap="s" padding="xxs">
45
45
  <Modal.CloseButton>Cancel</Modal.CloseButton>
46
46
  <PrimaryButton type="submit">Submit</PrimaryButton>
47
47
  </Flex>
@@ -81,7 +81,7 @@ export default () => {
81
81
  ut aliquam purus sit.
82
82
  </p>
83
83
  </Modal.Body>
84
- <Flex gap="s" padding="xxs" marginTop="xxs">
84
+ <Flex gap="s" padding="xxs">
85
85
  <Modal.CloseButton as={PrimaryButton} onClick={handleAcknowledge}>
86
86
  Acknowledge
87
87
  </Modal.CloseButton>
@@ -50,7 +50,7 @@ export default () => {
50
50
  Are you sure you want to delete the item?
51
51
  </Box>
52
52
  </Modal.Body>
53
- <Flex gap="s" padding="xxs" marginTop="xxs">
53
+ <Flex gap="s" padding="xxs">
54
54
  <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
55
55
  Delete
56
56
  </Modal.CloseButton>
@@ -41,7 +41,7 @@ export default () => {
41
41
  Are you sure you want to delete the item?
42
42
  </Box>
43
43
  </Modal.Body>
44
- <Flex gap="s" padding="xxs" marginTop="xxs">
44
+ <Flex gap="s" padding="xxs">
45
45
  <Modal.CloseButton ref={cancelBtnRef}>Cancel</Modal.CloseButton>
46
46
  <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
47
47
  Delete
@@ -33,7 +33,7 @@ export default () => {
33
33
  Are you sure you'd like to delete the item titled 'My Item'?
34
34
  </Box>
35
35
  </Popup.Body>
36
- <Flex gap="s" padding="xxs" marginTop="xxs">
36
+ <Flex gap="s" padding="xxs">
37
37
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
38
38
  Delete
39
39
  </Popup.CloseButton>
@@ -47,7 +47,7 @@ export default () => {
47
47
  Are you sure you'd like to delete the item titled 'My Item'?
48
48
  </Box>
49
49
  </Popup.Body>
50
- <Flex gap="s" padding="xxs" marginTop="xxs">
50
+ <Flex gap="s" padding="xxs">
51
51
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
52
52
  Delete
53
53
  </Popup.CloseButton>
@@ -47,7 +47,7 @@ export default () => {
47
47
  Are you sure you'd like to delete the item titled 'My Item'?
48
48
  </Box>
49
49
  </Popup.Body>
50
- <Flex gap="s" padding="xxs" marginTop="xxs">
50
+ <Flex gap="s" padding="xxs">
51
51
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
52
52
  Delete
53
53
  </Popup.CloseButton>
@@ -33,7 +33,7 @@ export default () => {
33
33
  Your message has been sent!
34
34
  </Box>
35
35
  </Popup.Body>
36
- <Flex gap="s" padding="xxs" marginTop="xxs">
36
+ <Flex gap="s" padding="xxs">
37
37
  <Popup.CloseButton ref={initialFocusRef} aria-describedby="popup-message">
38
38
  OK
39
39
  </Popup.CloseButton>
@@ -38,7 +38,7 @@ export default () => {
38
38
  <Popup.Body>
39
39
  <p style={{marginTop: 0, marginBottom: 0}}>Contents of Popup 1</p>
40
40
  </Popup.Body>
41
- <Flex gap="s" padding="xxs" marginTop="xxs">
41
+ <Flex gap="s" padding="xxs">
42
42
  <Popup model={popup2}>
43
43
  <Popup.Target>Open Popup 2</Popup.Target>
44
44
  <Popup.Popper>
@@ -47,7 +47,7 @@ export default () => {
47
47
  <Popup.Body>
48
48
  <p style={{marginTop: 0, marginBottom: 0}}>Contents of Popup 2</p>
49
49
  </Popup.Body>
50
- <Flex gap="s" padding="xxs" marginTop="xxs">
50
+ <Flex gap="s" padding="xxs">
51
51
  <Popup.CloseButton as={Popup.CloseButton} model={popup1}>
52
52
  Close Both (as)
53
53
  </Popup.CloseButton>
@@ -61,7 +61,7 @@ export default () => {
61
61
  <Popup.CloseIcon aria-label="Close" />
62
62
  <Popup.Heading paddingTop="m">This is Popup heading</Popup.Heading>
63
63
  <Popup.Body>Are you sure you'd like to delete the item titled 'My Item'?</Popup.Body>
64
- <Flex gap="s" padding="xxs" marginTop="xxs">
64
+ <Flex gap="s" padding="xxs">
65
65
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
66
66
  Delete
67
67
  </Popup.CloseButton>
@@ -79,7 +79,7 @@ export default () => {
79
79
  <Popup.CloseIcon aria-label="Close" />
80
80
  <Popup.Heading paddingTop="m">This is Popup heading</Popup.Heading>
81
81
  <Popup.Body>Are you sure you'd like to delete the item titled 'My Item'?</Popup.Body>
82
- <Flex gap="s" padding="xxs" marginTop="xxs">
82
+ <Flex gap="s" padding="xxs">
83
83
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
84
84
  Delete
85
85
  </Popup.CloseButton>
@@ -97,7 +97,7 @@ export default () => {
97
97
  <Popup.CloseIcon aria-label="Close" />
98
98
  <Popup.Heading paddingTop="m">This is Popup heading</Popup.Heading>
99
99
  <Popup.Body>Are you sure you'd like to delete the item titled 'My Item'?</Popup.Body>
100
- <Flex gap="s" padding="xxs" marginTop="xxs">
100
+ <Flex gap="s" padding="xxs">
101
101
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
102
102
  Delete
103
103
  </Popup.CloseButton>
@@ -115,7 +115,7 @@ export default () => {
115
115
  <Popup.CloseIcon aria-label="Close" />
116
116
  <Popup.Heading paddingTop="m">This is Popup heading</Popup.Heading>
117
117
  <Popup.Body>Are you sure you'd like to delete the item titled 'My Item'?</Popup.Body>
118
- <Flex gap="s" padding="xxs" marginTop="xxs">
118
+ <Flex gap="s" padding="xxs">
119
119
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
120
120
  Delete
121
121
  </Popup.CloseButton>
@@ -16,7 +16,7 @@ export default () => {
16
16
  האם ברצונך למחוק פריט זה
17
17
  </Box>
18
18
  </Popup.Body>
19
- <Flex gap="s" padding="xxs" marginTop="xxs">
19
+ <Flex gap="s" padding="xxs">
20
20
  <DeleteButton>לִמְחוֹק</DeleteButton>
21
21
  <SecondaryButton>לְבַטֵל</SecondaryButton>
22
22
  </Flex>
@@ -6,6 +6,7 @@ import {createStyles} from '@workday/canvas-kit-styling';
6
6
  import {system} from '@workday/canvas-tokens-web';
7
7
 
8
8
  const placementCardStyles = createStyles({
9
+ boxShadow: system.depth[2],
9
10
  display: 'flex',
10
11
  width: 100,
11
12
  height: 100,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "14.0.0-alpha.1147-next.0",
3
+ "version": "14.0.0-alpha.1149-next.0",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -45,10 +45,10 @@
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@stackblitz/sdk": "^1.11.0",
47
47
  "@storybook/csf": "0.0.1",
48
- "@workday/canvas-kit-labs-react": "^14.0.0-alpha.1147-next.0",
49
- "@workday/canvas-kit-preview-react": "^14.0.0-alpha.1147-next.0",
50
- "@workday/canvas-kit-react": "^14.0.0-alpha.1147-next.0",
51
- "@workday/canvas-kit-styling": "^14.0.0-alpha.1147-next.0",
48
+ "@workday/canvas-kit-labs-react": "^14.0.0-alpha.1149-next.0",
49
+ "@workday/canvas-kit-preview-react": "^14.0.0-alpha.1149-next.0",
50
+ "@workday/canvas-kit-react": "^14.0.0-alpha.1149-next.0",
51
+ "@workday/canvas-kit-styling": "^14.0.0-alpha.1149-next.0",
52
52
  "@workday/canvas-system-icons-web": "^3.0.0",
53
53
  "@workday/canvas-tokens-web": "3.0.0-alpha.5",
54
54
  "markdown-to-jsx": "^7.2.0",
@@ -61,5 +61,5 @@
61
61
  "mkdirp": "^1.0.3",
62
62
  "typescript": "5.0"
63
63
  },
64
- "gitHead": "de1260613697f1f525bc62614967f81521594356"
64
+ "gitHead": "ef6d229e302c293a16da98a7b36b1409877a1ac8"
65
65
  }
@@ -1,105 +0,0 @@
1
- import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
2
- import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
3
- import Basic from './examples/Basic';
4
- import ContextMenu from './examples/ContextMenu';
5
- import CustomMenuItem from './examples/CustomMenuItem';
6
- import Icons from './examples/Icons';
7
- import Headers from './examples/Headers';
8
- import ManyItems from './examples/ManyItems';
9
-
10
-
11
- # Canvas Kit Menu
12
-
13
- <StatusIndicator variant="red">
14
- <StatusIndicator.Label>Deprecated</StatusIndicator.Label>
15
- </StatusIndicator>
16
-
17
- `Menu` in Preview been deprecated and will be removed in a future major version. Please use
18
- [Menu in Main](https://workday.github.io/canvas-kit/?path=/docs/components-popups-menu--basic)
19
- instead.
20
-
21
- `DeprecatedMenu` displays a list of options when triggered by an action or UI element like an icon
22
- or button.
23
-
24
- [> Workday Design Reference](https://design.workday.com/components/popups/menus)
25
-
26
- ## Installation
27
-
28
- ```sh
29
- yarn add @workday/canvas-kit-preview-react
30
- ```
31
-
32
- ## Usage
33
-
34
- ### Basic Example
35
-
36
- `DeprecatedMenu` is typically triggered by an action such as pressing a button. Here's an example of
37
- how you might implement that behavior using a [`Popup`](/components/popups/popup/).
38
-
39
- <ExampleCodeBlock code={Basic} />
40
-
41
- `DeprecatedMenu` will automatically assign focus to itself when it appears provided you set the
42
- `isOpen` prop correctly, so you do **not** need to use the `useInitialFocus` `Popup` hook. You
43
- **will**, however, need to use `useReturnFocus` to return focus back to the triggering button after
44
- closing the `DeprecatedMenu`.
45
-
46
- `DeprecatedMenu` follows the
47
- [Actions Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
48
- using `aria-activedescendant`. Below is table of supported keyboard shortcuts and associated
49
- actions.
50
-
51
- | Key | Action |
52
- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
53
- | `Enter` or `Space` | Activates the menu item and then closes the menu |
54
- | `Escape` | Closes the menu |
55
- | `Up Arrow` | Moves focus to the previous menu item – if focus is on first menu item, it moves focus to the last menu item |
56
- | `Down Arrow` | Moves focus to the next menu item – if focus is on last menu item, it moves focus to the first menu item |
57
- | `Home` | Moves focus to the first menu item |
58
- | `End` | Moves focus to the last menu item |
59
- | `A-Z / a-z` | Moves focus to the next menu item with a label that starts with the typed character if such an menu item exists – otherwise, focus does not move |
60
-
61
- Note that although `DeprecatedMenu` includes support for keyboard shortcuts for the menu itself,
62
- you'll need to add your own keyboard handling and aria attributes to the triggering button.
63
-
64
- ### Context Menu
65
-
66
- <ExampleCodeBlock code={ContextMenu} />
67
-
68
- ### Custom Menu Item
69
-
70
- `DeprecatedMenu` renders a styled `<ul>` element with a role of `menu`, and `DeprecatedMenuItem`s
71
- are `<li>` elements with the correct attributes to ensure they are accessible. If you choose to
72
- implement your own custom menu items, be sure to use semantic `<li>` elements with the following
73
- attributes:
74
-
75
- - `role="menuitem"`
76
- - `tabindex={-1}`
77
-
78
- Below is an example:
79
-
80
- <ExampleCodeBlock code={CustomMenuItem} />
81
-
82
- ### Icons
83
-
84
- <ExampleCodeBlock code={Icons} />
85
-
86
- ### Headers
87
-
88
- You can group menu items logically by adding a `isHeader` attribute on your `<MenuItems>`. To make
89
- your new items screen reader friendly add an `aria-label` around each grouped item.
90
-
91
- <ExampleCodeBlock code={Headers} />
92
-
93
- ### Many Items
94
-
95
- <ExampleCodeBlock code={ManyItems} />
96
-
97
- ## Component API
98
-
99
- ### DeprecatedMenu
100
-
101
- <SymbolDoc name="DeprecatedMenu" fileName="/preview-react/" />
102
-
103
- ### DeprecatedMenuItem
104
-
105
- <SymbolDoc name="DeprecatedMenuItem" fileName="/preview-react/" />
@@ -1,74 +0,0 @@
1
- import React from 'react';
2
- import {DeprecatedMenu, DeprecatedMenuItem} from '@workday/canvas-kit-preview-react/menu';
3
- import {SecondaryButton} from '@workday/canvas-kit-react/button';
4
- import {
5
- Popup,
6
- usePopupModel,
7
- useAlwaysCloseOnOutsideClick,
8
- useReturnFocus,
9
- useCloseOnEscape,
10
- } from '@workday/canvas-kit-react/popup';
11
-
12
- const menuId = 'basic-menu';
13
-
14
- export default () => {
15
- const model = usePopupModel();
16
-
17
- useAlwaysCloseOnOutsideClick(model);
18
- useCloseOnEscape(model);
19
- useReturnFocus(model);
20
-
21
- const isOpen = model.state.visibility !== 'hidden';
22
-
23
- const handleButtonKeyDown = (event: React.KeyboardEvent) => {
24
- let isShortcut = false;
25
- if (event.key === `Spacebar` || event.key === ` ` || event.key === `Enter`) {
26
- isShortcut = true;
27
- if (isOpen) {
28
- model.events.hide();
29
- } else {
30
- model.events.show();
31
- }
32
- } else if (event.key === `ArrowDown` || event.key === `ArrowUp`) {
33
- isShortcut = true;
34
- model.events.show();
35
- }
36
-
37
- if (isShortcut) {
38
- // Prevent ArrowDown and ArrowUp keys from scrolling the entire page
39
- event.preventDefault();
40
- }
41
- };
42
-
43
- return (
44
- <Popup model={model}>
45
- <Popup.Target
46
- as={SecondaryButton}
47
- onKeyDown={handleButtonKeyDown}
48
- aria-expanded={isOpen}
49
- aria-haspopup={true}
50
- aria-controls={isOpen ? menuId : undefined}
51
- >
52
- Open Menu
53
- </Popup.Target>
54
- <Popup.Popper placement="bottom-start">
55
- {/*
56
- isOpen must be set for focus to be properly assigned to the DeprecatedMenu;
57
- onClose must be set in order to the DeprecatedMenu to close properly after
58
- selecting a DeprecatedMenuItem
59
- */}
60
- <DeprecatedMenu id={menuId} isOpen={isOpen} onClose={model.events.hide}>
61
- <DeprecatedMenuItem>First Item</DeprecatedMenuItem>
62
- <DeprecatedMenuItem>
63
- Second Item (with a really really really long label)
64
- </DeprecatedMenuItem>
65
- <DeprecatedMenuItem isDisabled>Third Item (disabled)</DeprecatedMenuItem>
66
- <DeprecatedMenuItem>
67
- Fourth Item (<b>with markup</b>)
68
- </DeprecatedMenuItem>
69
- <DeprecatedMenuItem hasDivider>Fifth Item (with divider)</DeprecatedMenuItem>
70
- </DeprecatedMenu>
71
- </Popup.Popper>
72
- </Popup>
73
- );
74
- };