@workday/canvas-kit-docs 5.3.0-next.3 → 5.3.1

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 (40) hide show
  1. package/LICENSE +1 -1
  2. package/dist/commonjs/lib/specs.js +30 -14
  3. package/dist/es6/lib/specs.js +30 -14
  4. package/dist/mdx/CONTRIBUTING.mdx +90 -63
  5. package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
  6. package/dist/mdx/preview-react/menu/Menu.mdx +17 -9
  7. package/dist/mdx/preview-react/menu/examples/Basic.tsx +65 -10
  8. package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +45 -29
  9. package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +2 -2
  10. package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
  11. package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +2 -2
  12. package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
  13. package/dist/mdx/react/button/button/Button.mdx +7 -7
  14. package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
  15. package/dist/mdx/react/pagination/PropTables.splitprops.tsx +47 -0
  16. package/dist/mdx/react/pagination/examples/{StepControls.tsx → Basic.tsx} +1 -1
  17. package/dist/mdx/react/pagination/examples/GoToForm.tsx +1 -1
  18. package/dist/mdx/react/pagination/examples/HoistedModel.tsx +36 -22
  19. package/dist/mdx/react/pagination/examples/RTL.tsx +1 -1
  20. package/dist/mdx/react/pagination/pagination.mdx +225 -474
  21. package/dist/mdx/react/popup/Popup.mdx +34 -36
  22. package/dist/mdx/react/radio/examples/Alert.tsx +3 -3
  23. package/dist/mdx/react/radio/examples/Basic.tsx +3 -3
  24. package/dist/mdx/react/radio/examples/Disabled.tsx +3 -3
  25. package/dist/mdx/react/radio/examples/Error.tsx +3 -3
  26. package/dist/mdx/react/radio/examples/LabelPosition.tsx +3 -3
  27. package/dist/mdx/react/radio/examples/NoValue.tsx +3 -3
  28. package/dist/mdx/react/radio/examples/RefForwarding.tsx +3 -3
  29. package/dist/mdx/react/radio/examples/Required.tsx +3 -3
  30. package/dist/mdx/react/segmented-control/SegmentedControl.mdx +1 -1
  31. package/dist/mdx/react/tabs/Tabs.mdx +37 -32
  32. package/dist/mdx/react/tabs/examples/HoistedModel.tsx +1 -1
  33. package/dist/mdx/react/toast/toast.mdx +1 -17
  34. package/dist/mdx/react/tooltip/Tooltip.mdx +1 -1
  35. package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
  36. package/package.json +3 -3
  37. package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
  38. package/dist/mdx/preview-react/menu/examples/ContextMenuTarget.tsx +0 -33
  39. package/dist/mdx/preview-react/menu/examples/ControlButton.tsx +0 -84
  40. package/dist/mdx/react/pagination/examples/ShowAdditionalDetails.tsx +0 -52
package/LICENSE CHANGED
@@ -43,7 +43,7 @@ While redistributing the Work or Derivative Works thereof, You may choose to off
43
43
 
44
44
  END OF TERMS AND CONDITIONS
45
45
 
46
- ©2020. Workday, Inc. All rights reserved. Workday and the Workday logo are registered trademarks of Workday, Inc. All other brand and product names are trademarks or registered trademarks of their respective holders.
46
+ ©2021 Workday, Inc. All rights reserved. Workday and the Workday logo are registered trademarks of Workday, Inc. All other brand and product names are trademarks or registered trademarks of their respective holders.
47
47
 
48
48
 
49
49
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
@@ -1253,7 +1253,7 @@ module.exports = {specifications: [
1253
1253
  "children": [
1254
1254
  {
1255
1255
  "type": "describe",
1256
- "name": "given the [Preview/Menu/React, Control Button] example is rendered",
1256
+ "name": "given the [Preview/Menu/React, Basic] example is rendered",
1257
1257
  "children": [
1258
1258
  {
1259
1259
  "type": "it",
@@ -2471,21 +2471,21 @@ module.exports = {specifications: [
2471
2471
  },
2472
2472
  {
2473
2473
  "type": "describe",
2474
- "name": "when the \"Gluten Free\" radio button is clicked",
2474
+ "name": "when the \"Gluten free\" radio button is clicked",
2475
2475
  "children": [
2476
2476
  {
2477
2477
  "type": "it",
2478
- "name": "the \"Gluten Free\" radio button should be checked"
2478
+ "name": "the \"Gluten free\" radio button should be checked"
2479
2479
  }
2480
2480
  ]
2481
2481
  },
2482
2482
  {
2483
2483
  "type": "describe",
2484
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2484
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2485
2485
  "children": [
2486
2486
  {
2487
2487
  "type": "it",
2488
- "name": "the \"Gluten Free\" radio button should not be checked"
2488
+ "name": "the \"Gluten free\" radio button should not be checked"
2489
2489
  },
2490
2490
  {
2491
2491
  "type": "it",
@@ -2505,21 +2505,21 @@ module.exports = {specifications: [
2505
2505
  },
2506
2506
  {
2507
2507
  "type": "describe",
2508
- "name": "when the \"Gluten Free\" radio button is clicked",
2508
+ "name": "when the \"Gluten free\" radio button is clicked",
2509
2509
  "children": [
2510
2510
  {
2511
2511
  "type": "it",
2512
- "name": "the \"Gluten Free\" radio button should be checked"
2512
+ "name": "the \"Gluten free\" radio button should be checked"
2513
2513
  }
2514
2514
  ]
2515
2515
  },
2516
2516
  {
2517
2517
  "type": "describe",
2518
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2518
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2519
2519
  "children": [
2520
2520
  {
2521
2521
  "type": "it",
2522
- "name": "the \"Gluten Free\" radio button should not be checked"
2522
+ "name": "the \"Gluten free\" radio button should not be checked"
2523
2523
  },
2524
2524
  {
2525
2525
  "type": "it",
@@ -2539,21 +2539,21 @@ module.exports = {specifications: [
2539
2539
  },
2540
2540
  {
2541
2541
  "type": "describe",
2542
- "name": "when the \"Gluten Free\" radio button is clicked",
2542
+ "name": "when the \"Gluten free\" radio button is clicked",
2543
2543
  "children": [
2544
2544
  {
2545
2545
  "type": "it",
2546
- "name": "the \"Gluten Free\" radio button should be checked"
2546
+ "name": "the \"Gluten free\" radio button should be checked"
2547
2547
  }
2548
2548
  ]
2549
2549
  },
2550
2550
  {
2551
2551
  "type": "describe",
2552
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2552
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2553
2553
  "children": [
2554
2554
  {
2555
2555
  "type": "it",
2556
- "name": "the \"Gluten Free\" radio button should not be checked"
2556
+ "name": "the \"Gluten free\" radio button should not be checked"
2557
2557
  },
2558
2558
  {
2559
2559
  "type": "it",
@@ -2573,7 +2573,7 @@ module.exports = {specifications: [
2573
2573
  },
2574
2574
  {
2575
2575
  "type": "it",
2576
- "name": "the \"Gluten Free (Sold Out)\" radio button should be disabled"
2576
+ "name": "the \"Gluten free (sold out)\" radio button should be disabled"
2577
2577
  }
2578
2578
  ]
2579
2579
  }
@@ -5754,6 +5754,22 @@ module.exports = {specifications: [
5754
5754
  ]
5755
5755
  }
5756
5756
  ]
5757
+ },
5758
+ {
5759
+ "type": "describe",
5760
+ "name": "given the [Testing/React/Popups/Tooltip, Overflow] example is rendered",
5761
+ "children": [
5762
+ {
5763
+ "type": "describe",
5764
+ "name": "when the = button is hovered",
5765
+ "children": [
5766
+ {
5767
+ "type": "it",
5768
+ "name": "should open the tooltip"
5769
+ }
5770
+ ]
5771
+ }
5772
+ ]
5757
5773
  }
5758
5774
  ]
5759
5775
  }
@@ -1253,7 +1253,7 @@ module.exports = {specifications: [
1253
1253
  "children": [
1254
1254
  {
1255
1255
  "type": "describe",
1256
- "name": "given the [Preview/Menu/React, Control Button] example is rendered",
1256
+ "name": "given the [Preview/Menu/React, Basic] example is rendered",
1257
1257
  "children": [
1258
1258
  {
1259
1259
  "type": "it",
@@ -2471,21 +2471,21 @@ module.exports = {specifications: [
2471
2471
  },
2472
2472
  {
2473
2473
  "type": "describe",
2474
- "name": "when the \"Gluten Free\" radio button is clicked",
2474
+ "name": "when the \"Gluten free\" radio button is clicked",
2475
2475
  "children": [
2476
2476
  {
2477
2477
  "type": "it",
2478
- "name": "the \"Gluten Free\" radio button should be checked"
2478
+ "name": "the \"Gluten free\" radio button should be checked"
2479
2479
  }
2480
2480
  ]
2481
2481
  },
2482
2482
  {
2483
2483
  "type": "describe",
2484
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2484
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2485
2485
  "children": [
2486
2486
  {
2487
2487
  "type": "it",
2488
- "name": "the \"Gluten Free\" radio button should not be checked"
2488
+ "name": "the \"Gluten free\" radio button should not be checked"
2489
2489
  },
2490
2490
  {
2491
2491
  "type": "it",
@@ -2505,21 +2505,21 @@ module.exports = {specifications: [
2505
2505
  },
2506
2506
  {
2507
2507
  "type": "describe",
2508
- "name": "when the \"Gluten Free\" radio button is clicked",
2508
+ "name": "when the \"Gluten free\" radio button is clicked",
2509
2509
  "children": [
2510
2510
  {
2511
2511
  "type": "it",
2512
- "name": "the \"Gluten Free\" radio button should be checked"
2512
+ "name": "the \"Gluten free\" radio button should be checked"
2513
2513
  }
2514
2514
  ]
2515
2515
  },
2516
2516
  {
2517
2517
  "type": "describe",
2518
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2518
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2519
2519
  "children": [
2520
2520
  {
2521
2521
  "type": "it",
2522
- "name": "the \"Gluten Free\" radio button should not be checked"
2522
+ "name": "the \"Gluten free\" radio button should not be checked"
2523
2523
  },
2524
2524
  {
2525
2525
  "type": "it",
@@ -2539,21 +2539,21 @@ module.exports = {specifications: [
2539
2539
  },
2540
2540
  {
2541
2541
  "type": "describe",
2542
- "name": "when the \"Gluten Free\" radio button is clicked",
2542
+ "name": "when the \"Gluten free\" radio button is clicked",
2543
2543
  "children": [
2544
2544
  {
2545
2545
  "type": "it",
2546
- "name": "the \"Gluten Free\" radio button should be checked"
2546
+ "name": "the \"Gluten free\" radio button should be checked"
2547
2547
  }
2548
2548
  ]
2549
2549
  },
2550
2550
  {
2551
2551
  "type": "describe",
2552
- "name": "when clicking the \"Gluten Free\" radio button and then clicking the \"Thin\" radio button",
2552
+ "name": "when clicking the \"Gluten free\" radio button and then clicking the \"Thin\" radio button",
2553
2553
  "children": [
2554
2554
  {
2555
2555
  "type": "it",
2556
- "name": "the \"Gluten Free\" radio button should not be checked"
2556
+ "name": "the \"Gluten free\" radio button should not be checked"
2557
2557
  },
2558
2558
  {
2559
2559
  "type": "it",
@@ -2573,7 +2573,7 @@ module.exports = {specifications: [
2573
2573
  },
2574
2574
  {
2575
2575
  "type": "it",
2576
- "name": "the \"Gluten Free (Sold Out)\" radio button should be disabled"
2576
+ "name": "the \"Gluten free (sold out)\" radio button should be disabled"
2577
2577
  }
2578
2578
  ]
2579
2579
  }
@@ -5754,6 +5754,22 @@ module.exports = {specifications: [
5754
5754
  ]
5755
5755
  }
5756
5756
  ]
5757
+ },
5758
+ {
5759
+ "type": "describe",
5760
+ "name": "given the [Testing/React/Popups/Tooltip, Overflow] example is rendered",
5761
+ "children": [
5762
+ {
5763
+ "type": "describe",
5764
+ "name": "when the = button is hovered",
5765
+ "children": [
5766
+ {
5767
+ "type": "it",
5768
+ "name": "should open the tooltip"
5769
+ }
5770
+ ]
5771
+ }
5772
+ ]
5757
5773
  }
5758
5774
  ]
5759
5775
  }
@@ -5,42 +5,37 @@ part of the community. Before you contribute, please take a moment and look thro
5
5
  sections:
6
6
 
7
7
  - [Code of Conduct](#code-of-conduct)
8
- - [Contributor License Agreement](#contributor-license-agreement)
9
- - [Contributing Guidelines](#contributing-guidelines)
10
- - [How to Contribute](#how-to-contribute)
8
+ - [How to Contribute](#how-to-contribute)
9
+ - [Communicate on Issues](#communicate-on-issues)
11
10
  - [Git Guidelines](#git-guidelines)
12
- - [Getting Started](#getting-started)
11
+ - [Branches](#branches)
12
+ - [Commit Message Format](#commit-message-format)
13
+ - [Commit Descriptions](#commit-descriptions)
14
+ - [Pull Requests](#pull-requests)
15
+ - [Developer Experience](#developer-experience)
16
+ - [Yarn and Workspaces](#yarn-and-workspaces)
17
+ - [Storybook](#storybook)
18
+ - [Testing](#testing)
19
+ - [Automation on Commit](#automation-on-commit)
20
+ - [Releases](#releases)
21
+ - [Getting Started Developing](#getting-started-developing)
13
22
  - [Creating a Module](#creating-a-module)
14
23
  - [Exporting a Module](#exporting-a-module)
15
24
  - [Building Modules](#building-modules)
16
25
  - [Testing Modules](#testing-modules)
17
26
  - [Code Style Guide](#code-style-guide)
18
- - [Canvas Kit Labs & Preview](#canvas-kit-labs-preview)
27
+ - [Canvas Kit Labs & Preview](#canvas-kit-labs--preview)
19
28
  - [Editors](#editors)
29
+ - [Contributor License Agreement](#contributor-license-agreement)
20
30
 
21
31
  ## Code of Conduct
22
32
 
23
33
  At Workday, we are committed to a culture of integrity, innovation, and fun. That culture extends to
24
34
  the community that we are building here through Canvas. By participating in it, you are expected to
25
- uphold this [code of conduct](https://github.com/Workday/canvas-kit/tree/master/CODE_OF_CONDUCT.md)
26
- and agree to our CLA.
35
+ uphold our [Code of Conduct](https://github.com/Workday/canvas-kit/blob/master/CODE_OF_CONDUCT.md)
36
+ and agree to our [Contributor License Agreement](#contributor-license-agreement).
27
37
 
28
- ## Contributor License Agreement
29
-
30
- Each Contributor (“You”) represents that such You are legally entitled to submit any Contributions
31
- in accordance with these terms and by posting a Contribution, you represent that each of Your
32
- Contribution is Your original creation.
33
-
34
- You are not expected to provide support for Your Contributions, except to the extent You desire to
35
- provide support. You may provide support for free, for a fee, or not at all. Unless required by
36
- applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT
37
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any
38
- warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
39
- PURPOSE.
40
-
41
- ## Contributing Guidelines
42
-
43
- ### How to Contribute
38
+ ## How to Contribute
44
39
 
45
40
  **Don't hesitate to contribute!** Canvas Kit thrives on open discussion and contribution by anyone
46
41
  in the Workday community. Contribution doesn't have to be code-based. Anyone can suggest changes to
@@ -50,38 +45,25 @@ If you are contributing code, please take a look at the following sections to fa
50
45
  with how the Canvas Kit repo is organized and run. This will help streamline the pull request
51
46
  process. If you have any questions, please reach out!
52
47
 
53
- If your contribution is visual or UI-based, please ensure you consult with a designer so the
54
- contribution can be evaluated as an end-to-end process.
55
-
56
- #### Automation on Commit
57
-
58
- Upon commit, [lint-staged](https://github.com/okonet/lint-staged) will run your staged code through
59
- [Prettier](https://prettier.io) and [eslint](https://eslint.org).
48
+ If your contribution is visual or UI-based, please ensure you consult with a designer or request a
49
+ maintainer's help so the contribution can be evaluated as an end-to-end process.
60
50
 
61
- #### Storybook
51
+ ### Communicate on Issues
62
52
 
63
- Canvas Kit uses [Storybook](https://storybook.js.org/) for the component development environment.
64
-
65
- #### Yarn and Workspaces
66
-
67
- Canvas Kit uses Yarn for package management and takes advantage of its support for
68
- [Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) to connect all of its different modules
69
- within a single repository.
70
-
71
- #### Testing
72
-
73
- Canvas Kit uses [Jest](https://jestjs.io/) and
74
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) to unit test
75
- our React components. For more information about our testing strategy and how we write unit tests,
76
- visit our [Testing Readme](/getting-started/for-developers/resources/testing/)
77
-
78
- Canvas Kit uses [Cypress](https://cypress.io) for UI tests. For info on why we chose Cypress, visit
79
- [Why Cypress?](https://github.com/Workday/canvas-kit/tree/master/cypress/WHY_CYPRESS.md) For more
80
- information about how to write Cypress tests, visit
81
- [Writing Cypress Tests](https://github.com/Workday/canvas-kit/tree/master/cypress/README.md)
53
+ - Create or identify [an issue](https://github.com/Workday/canvas-kit/issues) to work on
54
+ - New contributors are recommended to start with a
55
+ [good first issue](https://github.com/Workday/canvas-kit/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
56
+ - Ask our team if the issue is relevant or has attention from other developers
57
+ - Communicate if you'd like to work on the issue
58
+ - Ask questions! You have our support, and you will always need more information than what is in the
59
+ issue.
82
60
 
83
61
  ### Git Guidelines
84
62
 
63
+ All development should happen on a personal fork (including maintainers). Fork the
64
+ [repo](https://github.com/Workday/canvas-kit) to your personal account, and create a feature branch
65
+ for each contribution.
66
+
85
67
  #### Branches
86
68
 
87
69
  - Create branches for each feature you develop
@@ -127,18 +109,50 @@ fix: Add missing static class variable to IconButton and Avatar
127
109
 
128
110
  #### Pull Requests
129
111
 
130
- - All development should happen on a personal fork (including maintainers). This allows us to keep
131
- the project tree clean and easy to follow, while ensuring everyone has the same developer
132
- experience.
133
- - Project maintainers are able to push commits to fork PRs, but other contributors will need to open
134
- PRs to the personal fork to collaborate with others on a feature.
112
+ - We support creating a Draft Pull Request as soon as you have figured out a working implementation,
113
+ for early feedback. It can later be marked Ready for Review.
114
+ - Open a pull request from a feature branch on your fork against the master branch on the main
115
+ repository
135
116
  - When a pull request passes all checks and reviews, a core maintainer merges via Squash and Merge
136
- with a link back to the PR.
117
+ with a link back to the PR
137
118
  - The branch will automatically be deleted on merge, but its commits and the branch reference are
138
- still available via the PR.
119
+ still available via the PR
120
+ - When multiple developers collaborate on a PR, project maintainers are able to push commits to fork
121
+ PRs, but other contributors will need to open their own PRs against the personal fork and the
122
+ appropriate feature branch.
139
123
  - If you have questions about the above policies, please ask :)
140
124
 
141
- #### Releases
125
+ ## Developer Experience
126
+
127
+ ### Storybook
128
+
129
+ Canvas Kit uses [Storybook](https://storybook.js.org/) for the component development environment.
130
+
131
+ ### Yarn and Workspaces
132
+
133
+ Canvas Kit uses Yarn for package management and takes advantage of its support for
134
+ [Workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) to connect all of its different modules
135
+ within a single repository. It is recommended but not required over `npm`, unless you are updating
136
+ dependencies, then it's required.
137
+
138
+ ### Testing
139
+
140
+ Canvas Kit uses [Jest](https://jestjs.io/) and
141
+ [React Testing Library](https://testing-library.com/docs/react-testing-library/intro) to unit test
142
+ our React components. For more information about our testing strategy and how we write unit tests,
143
+ visit our [Testing Readme](/getting-started/for-developers/resources/testing/).
144
+
145
+ Canvas Kit uses [Cypress](https://cypress.io) for UI tests. For info on why we chose Cypress, visit
146
+ [Why Cypress?](https://github.com/Workday/canvas-kit/tree/master/cypress/WHY_CYPRESS.md) For more
147
+ information about how to write Cypress tests, visit
148
+ [Writing Cypress Tests](https://github.com/Workday/canvas-kit/tree/master/cypress/README.md).
149
+
150
+ ### Automation on Commit
151
+
152
+ Upon commit, [lint-staged](https://github.com/okonet/lint-staged) will run your staged code through
153
+ [Prettier](https://prettier.io) and [eslint](https://eslint.org).
154
+
155
+ ### Releases
142
156
 
143
157
  - Releases are prepared by updating package versions with `lerna version`, and updating the
144
158
  [changelog](./CHANGELOG.md)
@@ -148,9 +162,9 @@ fix: Add missing static class variable to IconButton and Avatar
148
162
  - The GitHub release automatically tags master with the new version, and deploys the new version to
149
163
  NPM.
150
164
 
151
- ## Getting Started
165
+ ## Getting Started Developing
152
166
 
153
- 1. Clone the repository and run `yarn`
167
+ 1. Clone the repository from your fork and run `yarn`
154
168
  2. Run `yarn start` to start [Storybook](https://storybook.js.org/)
155
169
  3. Visit [http://localhost:9001/](http://localhost:9001/)
156
170
 
@@ -220,8 +234,8 @@ Canvas Kit Preview is for beta components.
220
234
 
221
235
  ### Editors
222
236
 
223
- VSCode is our preferred IDE. Install the Prettier and ESLint plugins for quicker and easier
224
- formatting.
237
+ Visual Studio Code is our preferred IDE. Install the Prettier and ESLint plugins for quicker and
238
+ easier formatting.
225
239
 
226
240
  #### Visual Studio Code
227
241
 
@@ -230,4 +244,17 @@ Install [prettier-vscode](https://github.com/prettier/prettier-vscode) and
230
244
 
231
245
  Consider adding the following options:
232
246
 
233
- - [Format on save](https://github.com/prettier/prettier-vscode#format-on-save)
247
+ - [Format on save](https://github.com/prettier/prettier-vscode#format-on-save)
248
+
249
+ ## Contributor License Agreement
250
+
251
+ Each Contributor (“You”) represents that such You are legally entitled to submit any Contributions
252
+ in accordance with these terms and by posting a Contribution, you represent that each of Your
253
+ Contribution is Your original creation.
254
+
255
+ You are not expected to provide support for Your Contributions, except to the extent You desire to
256
+ provide support. You may provide support for free, for a fee, or not at all. Unless required by
257
+ applicable law or agreed to in writing, You provide Your Contributions on an "AS IS" BASIS, WITHOUT
258
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any
259
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
260
+ PURPOSE.
@@ -46,7 +46,7 @@ you'll need to add `buttonAriaLabel` to `Breadcrumbs.CollapsibleList`.
46
46
 
47
47
  <ExampleCodeBlock code={CollapsibleList} />
48
48
 
49
- ### Right-to-Left Example
49
+ ### Right-to-Left (RTL)
50
50
 
51
51
  Breadcrumbs has bidirectional support out of the box. That means outside of setting the content
52
52
  direction in your application's Canvas theme, you don't need to do anything else to make it work.
@@ -3,7 +3,6 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
3
3
 
4
4
  import Basic from './examples/Basic';
5
5
  import ContextMenu from './examples/ContextMenu';
6
- import ControlButton from './examples/ControlButton';
7
6
  import CustomMenuItem from './examples/CustomMenuItem';
8
7
  import Icons from './examples/Icons';
9
8
  import ManyItems from './examples/ManyItems';
@@ -11,7 +10,7 @@ import ManyItems from './examples/ManyItems';
11
10
 
12
11
  # Canvas Kit Menu
13
12
 
14
- Menus display a list of options when triggered by an action or UI element like an icon or button.
13
+ `Menu` displays a list of options when triggered by an action or UI element like an icon or button.
15
14
 
16
15
  [> Workday Design Reference](https://design.workday.com/components/popups/menus)
17
16
 
@@ -25,8 +24,15 @@ yarn add @workday/canvas-kit-preview-react
25
24
 
26
25
  ### Basic Example
27
26
 
27
+ `Menu` is typically triggered by an action such as pressing a button. Here's an example of how you
28
+ might implement that behavior using a [`Popup`](/components/popups/popup/).
29
+
28
30
  <ExampleCodeBlock code={Basic} />
29
31
 
32
+ `Menu` will automatically assign focus to itself when it appears provided you set the `isOpen` prop
33
+ correctly, so you do **not** need to use the `useInitialFocus` `Popup` hook. You **will**, however,
34
+ need to use `useReturnFocus` to return focus back to the triggering button after closing the `Menu`.
35
+
30
36
  `Menu` follows the
31
37
  [Actions Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
32
38
  using `aria-activedescendant`. Below is table of supported keyboard shortcuts and associated
@@ -42,10 +48,8 @@ actions.
42
48
  | `End` | Moves focus to the last menu item |
43
49
  | `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 |
44
50
 
45
- If you're using a menu button, you will need to add your own keyboard shortcuts, aria attributes,
46
- and focus management. See the example below.
47
-
48
- <ExampleCodeBlock code={ControlButton} />
51
+ Note that although `Menu` includes support for keyboard shortcuts for the menu itself, you'll need
52
+ to add your own keyboard handling and aria attributes to the triggering button.
49
53
 
50
54
  ### Context Menu
51
55
 
@@ -59,7 +63,6 @@ custom menu items, be sure to use semantic `<li>` elements with the following at
59
63
 
60
64
  - `role="menuitem"`
61
65
  - `tabindex={-1}`
62
- - `id`s following this pattern: `${MenuId}-${index}`
63
66
 
64
67
  Below is an example:
65
68
 
@@ -79,19 +82,22 @@ Below is an example:
79
82
 
80
83
  #### Usage
81
84
 
82
- `Menu` renders a styled `<ul>` element with a role of `menu` and follows the
85
+ `Menu` renders a styled `<ul role="menu">` element within a [`Card`](/components/containers/card/)
86
+ and follows the
83
87
  [Active Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
84
88
  using `aria-activedescendant`.
85
89
 
86
90
  #### Props
87
91
 
92
+ Undocumented props are spread to the underlying `<ul>` element.
93
+
88
94
  <ArgsTable of={Menu} />
89
95
 
90
96
  ### MenuItem
91
97
 
92
98
  #### Usage
93
99
 
94
- `MenuItem` renders a `<li>` element with the correct attributes to ensure it is accessible. If you
100
+ `MenuItem` renders an `<li>` element with the correct attributes to ensure it is accessible. If you
95
101
  choose to implement your own custom menu items, be sure to use semantic `<li>` elements with the
96
102
  following attributes:
97
103
 
@@ -101,6 +107,8 @@ following attributes:
101
107
 
102
108
  #### Props
103
109
 
110
+ Undocumented props are spread to the underlying `<li>` element.
111
+
104
112
  <ArgsTable of={MenuItem} />
105
113
 
106
114
  ## Specifications
@@ -1,17 +1,72 @@
1
1
  import React from 'react';
2
-
3
2
  import {Menu, MenuItem} 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';
4
13
 
5
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
+
6
43
  return (
7
- <Menu title="Menu Title">
8
- <MenuItem>First Item</MenuItem>
9
- <MenuItem>Second Item (with a really really really long label)</MenuItem>
10
- <MenuItem isDisabled>Third Item (disabled)</MenuItem>
11
- <MenuItem>
12
- Fourth Item (<b>with markup</b>)
13
- </MenuItem>
14
- <MenuItem hasDivider>Fifth Item (with divider)</MenuItem>
15
- </Menu>
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 Menu;
57
+ onClose must be set in order to the Menu to close properly after
58
+ selecting a MenuItem
59
+ */}
60
+ <Menu id={menuId} isOpen={isOpen} onClose={model.events.hide}>
61
+ <MenuItem>First Item</MenuItem>
62
+ <MenuItem>Second Item (with a really really really long label)</MenuItem>
63
+ <MenuItem isDisabled>Third Item (disabled)</MenuItem>
64
+ <MenuItem>
65
+ Fourth Item (<b>with markup</b>)
66
+ </MenuItem>
67
+ <MenuItem hasDivider>Fifth Item (with divider)</MenuItem>
68
+ </Menu>
69
+ </Popup.Popper>
70
+ </Popup>
16
71
  );
17
72
  };