@workday/canvas-kit-docs 6.8.9 → 6.9.0-next.5

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 (188) hide show
  1. package/dist/commonjs/index.js +13 -6
  2. package/dist/commonjs/lib/Specifications.d.ts.map +1 -1
  3. package/dist/commonjs/lib/Specifications.js +3 -1
  4. package/dist/commonjs/lib/docs.js +1 -0
  5. package/dist/commonjs/lib/specs.js +229 -2
  6. package/dist/es6/lib/Specifications.d.ts.map +1 -1
  7. package/dist/es6/lib/specs.js +229 -2
  8. package/dist/mdx/{4.0-MIGRATION-GUIDE.mdx → 4.0-UPGRADE-GUIDE.mdx} +1 -1
  9. package/dist/mdx/{5.0-MIGRATION-GUIDE.mdx → 5.0-UPGRADE-GUIDE.mdx} +3 -3
  10. package/dist/mdx/{6.0-MIGRATION-GUIDE.mdx → 6.0-UPGRADE-GUIDE.mdx} +4 -4
  11. package/dist/mdx/7.0-UPGRADE-GUIDE.mdx +1006 -0
  12. package/dist/mdx/COMPOUND_COMPONENTS.mdx +2 -2
  13. package/dist/mdx/CONTRIBUTING.mdx +2 -2
  14. package/dist/mdx/changelog.stories.mdx +1 -0
  15. package/dist/mdx/labs-react/search-form/examples/Basic.tsx +4 -2
  16. package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +4 -2
  17. package/dist/mdx/labs-react/search-form/examples/Grow.tsx +4 -2
  18. package/dist/mdx/labs-react/search-form/examples/RTL.tsx +4 -2
  19. package/dist/mdx/labs-react/search-form/examples/Theming.tsx +4 -2
  20. package/dist/mdx/preview-react/_examples/SidePanelWithOverlay.mdx +8 -0
  21. package/dist/mdx/preview-react/_examples/examples/SidePanelWithOverlay.tsx +31 -0
  22. package/dist/mdx/preview-react/_examples/examples/TextInputWithFormik.tsx +3 -3
  23. package/dist/mdx/preview-react/form-field/examples/Custom.tsx +4 -5
  24. package/dist/mdx/preview-react/menu/Menu.mdx +1 -1
  25. package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +2 -2
  26. package/dist/mdx/preview-react/menu/examples/Icons.tsx +0 -1
  27. package/dist/mdx/preview-react/pill/Pill.mdx +241 -0
  28. package/dist/mdx/preview-react/pill/examples/Basic.tsx +18 -0
  29. package/dist/mdx/preview-react/pill/examples/WithAvatar.tsx +21 -0
  30. package/dist/mdx/preview-react/pill/examples/WithCount.tsx +9 -0
  31. package/dist/mdx/preview-react/pill/examples/WithList.tsx +31 -0
  32. package/dist/mdx/preview-react/pill/examples/WithReadOnly.tsx +15 -0
  33. package/dist/mdx/preview-react/pill/examples/WithRemovable.tsx +25 -0
  34. package/dist/mdx/preview-react/pill/examples/test-avatar.png +0 -0
  35. package/dist/mdx/preview-react/side-panel/SidePanel.mdx +5 -3
  36. package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +16 -22
  37. package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +9 -14
  38. package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +9 -13
  39. package/dist/mdx/preview-react/side-panel/examples/HiddenName.tsx +1 -1
  40. package/dist/mdx/preview-react/side-panel/examples/OnExpandedChange.tsx +1 -1
  41. package/dist/mdx/preview-react/side-panel/examples/OnStateTransition.tsx +1 -1
  42. package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +17 -24
  43. package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +9 -14
  44. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +2 -1
  45. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +6 -4
  46. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +1 -1
  47. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +2 -1
  48. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +6 -4
  49. package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +1 -1
  50. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +2 -1
  51. package/dist/mdx/react/_examples/SegmentedControlWithText.mdx +12 -0
  52. package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +7 -6
  53. package/dist/mdx/react/_examples/examples/PageHeader.tsx +5 -5
  54. package/dist/mdx/react/_examples/examples/SegmentControlWithText.tsx +119 -0
  55. package/dist/mdx/react/action-bar/ActionBar.mdx +126 -23
  56. package/dist/mdx/react/action-bar/examples/Basic.tsx +7 -4
  57. package/dist/mdx/react/action-bar/examples/DeleteAction.tsx +15 -0
  58. package/dist/mdx/react/action-bar/examples/Icons.tsx +18 -0
  59. package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +59 -0
  60. package/dist/mdx/react/banner/Banner.mdx +203 -19
  61. package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
  62. package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
  63. package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
  64. package/dist/mdx/react/banner/examples/Error.tsx +8 -1
  65. package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
  66. package/dist/mdx/react/banner/examples/Sticky.tsx +12 -7
  67. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +64 -0
  68. package/dist/mdx/react/banner/examples/StickyRTL.tsx +35 -0
  69. package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
  70. package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
  71. package/dist/mdx/react/button/button/Button.mdx +3 -3
  72. package/dist/mdx/react/button/button/Hyperlink.mdx +72 -0
  73. package/dist/mdx/react/button/button/examples/ExternalHyperlink.tsx +7 -0
  74. package/dist/mdx/react/button/button/examples/ExternalHyperlinkInverse.tsx +12 -0
  75. package/dist/mdx/react/button/button/examples/Hyperlink.tsx +5 -0
  76. package/dist/mdx/react/button/button/examples/HyperlinkInverse.tsx +12 -0
  77. package/dist/mdx/react/button/button/examples/Primary.tsx +11 -3
  78. package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +11 -3
  79. package/dist/mdx/react/button/button/examples/Secondary.tsx +11 -3
  80. package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +11 -3
  81. package/dist/mdx/react/button/button/examples/Tertiary.tsx +9 -4
  82. package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +12 -3
  83. package/dist/mdx/react/card/card.mdx +2 -2
  84. package/dist/mdx/react/card/examples/Depth.tsx +1 -1
  85. package/dist/mdx/react/checkbox/Checkbox.mdx +7 -0
  86. package/dist/mdx/react/checkbox/examples/Indeterminate.tsx +1 -1
  87. package/dist/mdx/react/checkbox/examples/Inverse.tsx +22 -0
  88. package/dist/mdx/react/checkbox/examples/RefForwarding.tsx +1 -1
  89. package/dist/mdx/react/collection/Collection.mdx +358 -0
  90. package/dist/mdx/react/collection/Collection.splitprops.tsx +19 -0
  91. package/dist/mdx/react/collection/examples/Basic.tsx +12 -0
  92. package/dist/mdx/react/collection/examples/BasicGrid.tsx +46 -0
  93. package/dist/mdx/react/collection/examples/BasicVirtual.tsx +24 -0
  94. package/dist/mdx/react/collection/examples/DynamicItems.tsx +20 -0
  95. package/dist/mdx/react/collection/examples/IdentifiedItems.tsx +12 -0
  96. package/dist/mdx/react/collection/examples/MultiSelection.tsx +56 -0
  97. package/dist/mdx/react/collection/examples/RovingFocus.tsx +39 -0
  98. package/dist/mdx/react/collection/examples/Selection.tsx +58 -0
  99. package/dist/mdx/react/collection/examples/WrappingGrid.tsx +48 -0
  100. package/dist/mdx/react/color-picker/color-input/ColorInput.mdx +2 -2
  101. package/dist/mdx/react/color-picker/color-preview/ColorPreview.mdx +2 -2
  102. package/dist/mdx/{labs-react/common → react/layout}/Box.mdx +3 -6
  103. package/dist/mdx/{labs-react → react}/layout/Flex.mdx +24 -27
  104. package/dist/mdx/{labs-react → react}/layout/Stack.mdx +98 -146
  105. package/dist/mdx/{labs-react/common → react/layout}/examples/As.tsx +1 -1
  106. package/dist/mdx/{labs-react/common → react/layout}/examples/Border.tsx +1 -1
  107. package/dist/mdx/{labs-react/common → react/layout}/examples/Color.tsx +1 -1
  108. package/dist/mdx/{labs-react/common → react/layout}/examples/Depth.tsx +9 -3
  109. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexCard.tsx +2 -3
  110. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexLayout.tsx +1 -1
  111. package/dist/mdx/{labs-react → react}/layout/examples/Flex/Usage.tsx +2 -3
  112. package/dist/mdx/{labs-react/common → react/layout}/examples/FlexItem.tsx +1 -2
  113. package/dist/mdx/{labs-react/common → react/layout}/examples/Layout.tsx +1 -1
  114. package/dist/mdx/{labs-react/common → react/layout}/examples/Position.tsx +1 -1
  115. package/dist/mdx/{labs-react → react}/layout/examples/PropTables.splitprops.tsx +1 -1
  116. package/dist/mdx/{labs-react/common → react/layout}/examples/Ref.tsx +1 -1
  117. package/dist/mdx/{labs-react/common → react/layout}/examples/Space.tsx +1 -1
  118. package/dist/mdx/{labs-react → react}/layout/examples/Stack/BasicStack.tsx +1 -1
  119. package/dist/mdx/{labs-react → react}/layout/examples/Stack/HStackCards.tsx +2 -3
  120. package/dist/mdx/{labs-react → react}/layout/examples/Stack/NestedStacks.tsx +1 -1
  121. package/dist/mdx/react/layout/examples/Stack/ShouldWrapChildren.tsx +28 -0
  122. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackCard.tsx +2 -2
  123. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackItems.tsx +1 -2
  124. package/dist/mdx/{labs-react → react}/layout/examples/Stack/VStackCards.tsx +2 -2
  125. package/dist/mdx/react/menu/Menu.mdx +123 -0
  126. package/dist/mdx/react/menu/examples/Basic.tsx +26 -0
  127. package/dist/mdx/react/menu/examples/ContextMenu.tsx +25 -0
  128. package/dist/mdx/react/menu/examples/Icons.tsx +41 -0
  129. package/dist/mdx/react/modal/Modal.mdx +34 -11
  130. package/dist/mdx/react/modal/examples/Basic.tsx +4 -2
  131. package/dist/mdx/react/modal/examples/BodyOverflow.tsx +56 -0
  132. package/dist/mdx/react/modal/examples/CustomFocus.tsx +4 -2
  133. package/dist/mdx/react/modal/examples/FullOverflow.tsx +55 -0
  134. package/dist/mdx/react/modal/examples/ReturnFocus.tsx +5 -3
  135. package/dist/mdx/react/modal/examples/WithoutCloseIcon.tsx +4 -2
  136. package/dist/mdx/react/pagination/PropTables.splitprops.tsx +1 -1
  137. package/dist/mdx/react/pagination/pagination.mdx +14 -14
  138. package/dist/mdx/react/popup/Popup.mdx +2 -1
  139. package/dist/mdx/react/popup/examples/Basic.tsx +1 -1
  140. package/dist/mdx/react/popup/examples/FocusRedirect.tsx +1 -1
  141. package/dist/mdx/react/popup/examples/FocusTrap.tsx +1 -1
  142. package/dist/mdx/react/popup/examples/FullScreen.tsx +1 -1
  143. package/dist/mdx/react/popup/examples/InitialFocus.tsx +4 -2
  144. package/dist/mdx/react/popup/examples/MultiplePopups.tsx +1 -1
  145. package/dist/mdx/react/popup/examples/NestedPopups.tsx +18 -18
  146. package/dist/mdx/react/popup/examples/RTL.tsx +6 -3
  147. package/dist/mdx/react/radio/Radio.mdx +7 -0
  148. package/dist/mdx/react/radio/examples/Inverse.tsx +23 -0
  149. package/dist/mdx/react/segmented-control/SegmentedControl.mdx +2 -2
  150. package/dist/mdx/react/segmented-control/examples/Basic.tsx +13 -11
  151. package/dist/mdx/react/skeleton/examples/Basic.tsx +1 -1
  152. package/dist/mdx/react/skeleton/examples/Color.tsx +1 -2
  153. package/dist/mdx/react/skeleton/examples/Simulation.tsx +11 -10
  154. package/dist/mdx/react/status-indicator/StatusIndicator.mdx +12 -0
  155. package/dist/mdx/react/status-indicator/examples/MaxWidth.tsx +30 -0
  156. package/dist/mdx/react/tabs/Tabs.mdx +14 -17
  157. package/dist/mdx/react/tabs/TabsModel.splitprops.tsx +7 -3
  158. package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +6 -13
  159. package/dist/mdx/react/tabs/examples/HoistedModel.tsx +8 -8
  160. package/dist/mdx/react/tabs/examples/Icons.tsx +4 -4
  161. package/dist/mdx/react/tabs/examples/NamedTabs.tsx +10 -10
  162. package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +4 -8
  163. package/dist/mdx/react/tabs/examples/SinglePanel.tsx +3 -3
  164. package/dist/mdx/react/text-input/examples/Basic.tsx +3 -0
  165. package/dist/mdx/react/tooltip/Tooltip.mdx +2 -2
  166. package/dist/mdx/react/tooltip/examples/Default.tsx +2 -2
  167. package/dist/mdx/react/tooltip/examples/UseTooltip.tsx +2 -2
  168. package/package.json +9 -17
  169. package/dist/mdx/labs-react/common/examples/PropTables.splitprops.tsx +0 -91
  170. package/dist/mdx/labs-react/layout/examples/Stack/ShouldWrapChildren.tsx +0 -33
  171. package/dist/mdx/react/button/icon-button/IconButton.mdx +0 -103
  172. package/dist/mdx/react/button/icon-button/examples/Circle.tsx +0 -6
  173. package/dist/mdx/react/button/icon-button/examples/CircleFilled.tsx +0 -8
  174. package/dist/mdx/react/button/icon-button/examples/Inverse.tsx +0 -20
  175. package/dist/mdx/react/button/icon-button/examples/InverseFilled.tsx +0 -20
  176. package/dist/mdx/react/button/icon-button/examples/MirroredIcon.tsx +0 -11
  177. package/dist/mdx/react/button/icon-button/examples/Plain.tsx +0 -8
  178. package/dist/mdx/react/button/icon-button/examples/Square.tsx +0 -8
  179. package/dist/mdx/react/button/icon-button/examples/SquareFilled.tsx +0 -8
  180. package/dist/mdx/react/button/icon-button/examples/Toggleable.tsx +0 -20
  181. package/ts3.5/dist/commonjs/index.d.ts +0 -4
  182. package/ts3.5/dist/commonjs/lib/Specifications.d.ts +0 -6
  183. package/ts3.5/dist/commonjs/lib/docs.d.ts +0 -5
  184. package/ts3.5/dist/commonjs/lib/specs.d.ts +0 -16
  185. package/ts3.5/dist/es6/index.d.ts +0 -4
  186. package/ts3.5/dist/es6/lib/Specifications.d.ts +0 -6
  187. package/ts3.5/dist/es6/lib/docs.d.ts +0 -5
  188. package/ts3.5/dist/es6/lib/specs.d.ts +0 -16
@@ -2,11 +2,17 @@ import {ActionBar} from '@workday/canvas-kit-react/action-bar';
2
2
  import {Specifications} from '@workday/canvas-kit-docs';
3
3
 
4
4
  import Basic from './examples/Basic';
5
+ import Icons from './examples/Icons';
6
+ import DeleteAction from './examples/DeleteAction';
7
+ import OverflowActionBar from './examples/OverflowActionBar';
5
8
 
6
9
 
7
10
  # Canvas Kit Action Bar
8
11
 
9
- Full width button toolbar fixed to bottom of screen.
12
+ Action Bar is a [compound component](/getting-started/for-developers/resources/compound-components/)
13
+ that contains primary and secondary actions related to a page or task.
14
+
15
+ [> Workday Design Reference](https://design.workday.com/components/buttons/action-bar)
10
16
 
11
17
  ## Installation
12
18
 
@@ -18,39 +24,136 @@ yarn add @workday/canvas-kit-react
18
24
 
19
25
  ### Basic Example
20
26
 
21
- Here is a basic example of an `ActionBar` with two buttons. Although not required,
22
- [buttons](../../button) are often used in in action bars. The primary action button should be left
23
- aligned followed by secondary buttons. The primary button is on the right only in "progression-based
24
- UIs" and on mobile devices.
27
+ `ActionBar` includes a container `ActionBar` component and the following subcomponent:
28
+ `ActionBar.List` which should contains `ActionBar.Item`.
29
+
30
+ In a basic example of an `ActionBar` there are two buttons. The primary action button should be used
31
+ only once and left aligned if content is left to right, followed by secondary buttons. Tertiary
32
+ buttons should not be used in the Action Bar.
25
33
 
26
34
  <ExampleCodeBlock code={Basic} />
27
35
 
28
- ### Fixed
36
+ ### Icons Example
37
+
38
+ `ActionBar.Item` renders a `SecondaryButton` as default, so it's possible to use other Button props
39
+ with `ActionBar.Item` such as `icon` or `size`.
40
+
41
+ <ExampleCodeBlock code={Icons} />
42
+
43
+ ### Delete Action Example
44
+
45
+ `ActionBar.Item` is a `SecondaryButton` by default but it's posible to change it to another element,
46
+ such as `DeleteButton`, by using `as` prop.
47
+
48
+ <ExampleCodeBlock code={DeleteAction} />
49
+
50
+ ### Overflow Example
51
+
52
+ `ActionBar` container can contain up to 3 actions and an Overflow Menu if there are more than 3
53
+ actions, the other remaining actions should be placed into an Overflow Menu that is launched by
54
+ clicking the Overflow Button.
55
+
56
+ Also, ActionBar is a responsive component based on the width of its container. If the rendered
57
+ actions exceed the width of the `ActionBar.List`, an overflow menu will be rendered. This only works
58
+ against the dynamic API where you give the `ActionBarModel` an array of items to be rendered. The
59
+ dynamic API handles the React `key` for you based on the item's identifier. The dynamic API requires
60
+ either an `id` on each item object or a `getId` function that returns an identifier based on the
61
+ item. The below example uses an `id` property on each item.
62
+
63
+ The dynamic API takes in any object, but since nothing is known about your object, a
64
+ [render prop](https://reactjs.org/docs/render-props.html) is necessary to instruct a list how it
65
+ should render.
66
+
67
+ <ExampleCodeBlock code={OverflowActionBar} />
29
68
 
30
- The Action Bar generally lives at the bottom of the viewport. If you would like this behavior
31
- automatically (using `position: fixed`), you can use the `fixed` prop.
69
+ ## Components
70
+
71
+ ### ActionBar
72
+
73
+ #### Usage
74
+
75
+ `ActionBar` is a container component that is responsible for creating a `ActionBarModel` and sharing
76
+ it with its subcomponents using React context. It does not represent a real element.
32
77
 
33
78
  ```tsx
34
- <ActionBar fixed={true}>
35
- <PrimaryButton>Button</PrimaryButton>
36
- <SecondaryButton>Button</SecondaryButton>
37
- </ActionBar>
79
+ <ActionBar items={[]}>{/* Child components */}</ActionBar>
38
80
  ```
39
81
 
40
- ## Responsive Behavior
82
+ Alternatively, you may pass in a model using the hoisted model pattern.
41
83
 
42
- At 575px, responsive styles will take effect:
43
-
44
- - Applies a flex box to the buttons
45
- - Makes single-button groups full width
46
- - All buttons will become the same width (`flex: 1`).
47
- - Button order will become reversed, making left-aligned primary buttons right-aligned.
84
+ ```tsx
85
+ const model = useActionBarModel({
86
+ items: [],
87
+ });
48
88
 
49
- > When on a mobile form factor, the button placement should flip to have the primary button on the
50
- > far right.
89
+ <ActionBar model={model}>{/* Child components */}</ActionBar>;
90
+ ```
51
91
 
52
92
  ## Props
53
93
 
54
- Undocumented props are spread to the underlying container `<div>` element.
94
+ Note that if you pass in a `model` configured with `useActionBarModel`, configuration props passed
95
+ to `ActionBar` will be ignored.
96
+
97
+ <ArgsTable of={ActionBar} />
98
+
99
+ ### ActionBar.List
100
+
101
+ #### Usage
102
+
103
+ `ActionBar.List` is a `HStack` element. It is a container for `ActionBar.Item` subcomponents. To
104
+ apply an overflow behavior for ActionBar `showOverflowButton` prop shold be true.
105
+
106
+ ```tsx
107
+ <ActionBar.List>{/* ActionBar.Items */}</ActionBar.List>
108
+ ```
109
+
110
+ #### Props
111
+
112
+ Undocumented props are spread to the underlying `HStack` element.
113
+
114
+ <ArgsTable of={ActionBar.List} />
115
+
116
+ ### ActionBar.Item
117
+
118
+ #### Usage
119
+
120
+ `ActionBar.Item` is a `button` element, by default it's a `SecondaryButton` unless an `as` prop
121
+ passed.
122
+
123
+ ```tsx
124
+ <ActionBar.Item as={PrimaryButton} onClick={() => console.log('first action')}>
125
+ First Action
126
+ </ActionBar.Item>
127
+ ```
128
+
129
+ #### Props
130
+
131
+ Undocumented props are spread to the underlying `SecondaryButton` component.
132
+
133
+ <ArgsTable of={ActionBar.Item} />
134
+
135
+ ## Model
136
+
137
+ If `ActionBar` was stripped of all its markup, attributes, and styling, what would remain is the
138
+ [model](/getting-started/for-developers/resources/compound-components/#models). The model is an
139
+ object composed of two parts: `state` which describes the current snapshot in time of the component
140
+ and `events` which describes events that can be sent to the model.
141
+
142
+ By default, `ActionBar` will create a model and share it internally with its subcomponents using
143
+ React context. Alternatively, if you need direct access to the model's `state` and `events` outside
144
+ of the `ActionBar` component, you may configure your own model with `useActionBarModel` and pass it
145
+ to `ActionBar` via a pattern called
146
+ [hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
147
+
148
+ ```tsx
149
+ const model = useActionBarModel({
150
+ items: [],
151
+ });
152
+
153
+ <ActionBar model={model}>{/* Child components */}</ActionBar>;
154
+ ```
155
+
156
+ ### Config
55
157
 
56
- <ArgsTable of={ActionBar} />
158
+ `useActionBarModel` accepts a configuration object with the following properties and returns a
159
+ `ActionBarModel` with `state` and `events` properties.
@@ -1,11 +1,14 @@
1
1
  import React from 'react';
2
-
3
2
  import {ActionBar} from '@workday/canvas-kit-react/action-bar';
4
- import {PrimaryButton, SecondaryButton} from '@workday/canvas-kit-react/button';
3
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
5
4
 
6
5
  export default () => (
7
6
  <ActionBar>
8
- <PrimaryButton>Button</PrimaryButton>
9
- <SecondaryButton>Button</SecondaryButton>
7
+ <ActionBar.List position="relative">
8
+ <ActionBar.Item as={PrimaryButton} onClick={() => console.log('first action')}>
9
+ First Action
10
+ </ActionBar.Item>
11
+ <ActionBar.Item>Second Action</ActionBar.Item>
12
+ </ActionBar.List>
10
13
  </ActionBar>
11
14
  );
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ import {ActionBar} from '@workday/canvas-kit-react/action-bar';
4
+ import {DeleteButton} from '@workday/canvas-kit-react/button';
5
+
6
+ export default () => {
7
+ return (
8
+ <ActionBar>
9
+ <ActionBar.List position="relative">
10
+ <ActionBar.Item as={DeleteButton}>Delete Action</ActionBar.Item>
11
+ <ActionBar.Item>Second Action</ActionBar.Item>
12
+ </ActionBar.List>
13
+ </ActionBar>
14
+ );
15
+ };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+
3
+ import {ActionBar} from '@workday/canvas-kit-react/action-bar';
4
+ import {notificationsIcon, alarmClockIcon} from '@workday/canvas-system-icons-web';
5
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
6
+
7
+ export default () => {
8
+ return (
9
+ <ActionBar>
10
+ <ActionBar.List position="relative">
11
+ <ActionBar.Item as={PrimaryButton} icon={notificationsIcon}>
12
+ First Action
13
+ </ActionBar.Item>
14
+ <ActionBar.Item icon={alarmClockIcon}>Second Action</ActionBar.Item>
15
+ </ActionBar.List>
16
+ </ActionBar>
17
+ );
18
+ };
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+
3
+ import {ActionBar, useActionBarModel} from '@workday/canvas-kit-react/action-bar';
4
+ import {HStack} from '@workday/canvas-kit-react/layout';
5
+ import {PrimaryButton, SecondaryButton} from '@workday/canvas-kit-react/button';
6
+
7
+ type MyActionItem = {
8
+ id: string;
9
+ text: React.ReactNode;
10
+ };
11
+
12
+ export default () => {
13
+ const [items] = React.useState<MyActionItem[]>([
14
+ {id: 'first', text: 'First Action'},
15
+ {id: 'second', text: 'Second Action'},
16
+ {id: 'third', text: 'Third Action'},
17
+ {id: 'fourth', text: 'Fourth Action'},
18
+ {id: 'fifth', text: 'Fifth Action'},
19
+ ]);
20
+
21
+ const model = useActionBarModel({items});
22
+ const [containerWidth, setContainerWidth] = React.useState('100%');
23
+
24
+ return (
25
+ <div style={{width: containerWidth}}>
26
+ <ActionBar model={model}>
27
+ <ActionBar.List position="relative">
28
+ {(item: MyActionItem, index) => (
29
+ <ActionBar.Item
30
+ as={index === 0 ? PrimaryButton : undefined}
31
+ onClick={() => console.log(item.id)}
32
+ >
33
+ {item.text}
34
+ </ActionBar.Item>
35
+ )}
36
+ </ActionBar.List>
37
+ <ActionBar.Menu.Popper>
38
+ <ActionBar.Menu.Card maxWidth={300} maxHeight={200}>
39
+ <ActionBar.Menu.List>
40
+ {(item: MyActionItem) => (
41
+ <ActionBar.Menu.Item onClick={() => console.log(item.id)}>
42
+ {item.text}
43
+ </ActionBar.Menu.Item>
44
+ )}
45
+ </ActionBar.Menu.List>
46
+ </ActionBar.Menu.Card>
47
+ </ActionBar.Menu.Popper>
48
+ </ActionBar>
49
+ <hr />
50
+ <h4>Change action bar container size</h4>
51
+ <HStack spacing="xs">
52
+ <SecondaryButton onClick={() => setContainerWidth('100%')}>100%</SecondaryButton>
53
+ <SecondaryButton onClick={() => setContainerWidth('1023px')}>Medium</SecondaryButton>
54
+ <SecondaryButton onClick={() => setContainerWidth('767px')}>Small</SecondaryButton>
55
+ <SecondaryButton onClick={() => setContainerWidth('320px')}>Extra Small</SecondaryButton>
56
+ </HStack>
57
+ </div>
58
+ );
59
+ };
@@ -4,11 +4,24 @@ import ActionText from './examples/ActionText';
4
4
  import Basic from './examples/Basic';
5
5
  import Error from './examples/Error';
6
6
  import Sticky from './examples/Sticky';
7
+ import ThemedAlert from './examples/ThemedAlert';
8
+ import ThemedError from './examples/ThemedError';
9
+ import RefForwarding from './examples/RefForwarding';
10
+ import StickyAnimation from './examples/StickyAnimation';
11
+ import StickyRTL from './examples/StickyRTL';
12
+ import {
13
+ BannerHoistedComponent,
14
+ BannerModelConfigComponent,
15
+ BannerIconComponent,
16
+ BannerLabelComponent,
17
+ BannerActionComponent,
18
+ } from './PropTables.splitprops.tsx';
7
19
 
8
20
 
9
21
  # Canvas Kit Banner
10
22
 
11
- Banners surface important information and feedback to the user about a task, action, or state.
23
+ `Banner` is a [compound component](/getting-started/for-developers/resources/compound-components/)
24
+ used surface important information and feedback to the user about a task, action, or state.
12
25
 
13
26
  [> Workday Design Reference](https://design.workday.com/components/indicators/banners)
14
27
 
@@ -22,38 +35,209 @@ yarn add @workday/canvas-kit-react
22
35
 
23
36
  ### Basic Example
24
37
 
38
+ Use the children of `Banner.Label` to set the main text for the `Banner`.
39
+
25
40
  <ExampleCodeBlock code={Basic} />
26
41
 
27
- ### Error Type
42
+ ### Action Text
28
43
 
29
- Set the `error` prop of the Banner to designate the severity of the message presented in the banner.
30
- `error` accepts the following values:
44
+ Use the children of `Banner.ActionText` to customize the action text contained in the `Banner`. The
45
+ text has default value of `View All`.
31
46
 
32
- - `Banner.ErrorType.Alert` (Default)
33
- - `Banner.ErrorType.Error`
47
+ <ExampleCodeBlock code={ActionText} />
34
48
 
35
- <ExampleCodeBlock code={Error} />
49
+ ### Error Type
36
50
 
37
- ### Variant
51
+ Set the `hasError` prop of the `Banner` to designate the severity of the message presented in the
52
+ banner. This will change the defualt icon to `exclamationCircleIcon`.
38
53
 
39
- Banner is available in two variants. `variant` accepts the following values:
54
+ <ExampleCodeBlock code={Error} />
40
55
 
41
- - `Banner.Variant.Full` (Default)
42
- - `Banner.Variant.Sticky`
56
+ ### Sticky
43
57
 
44
- Use the `Sticky` variant if the Banner is to be displayed along the right edge of the page.
58
+ Set the `isSticky` prop of the `Banner` to display it along the right edge of the page. When true,
59
+ the `Banner.ActionText` will be hidden. Some basic styles will be applied, but you will still need
60
+ to manually set the css `position` value.
45
61
 
46
62
  <ExampleCodeBlock code={Sticky} />
47
63
 
48
- #### Action Text
64
+ You can use keyframes to animate the `Banner` in.
49
65
 
50
- Set the `actionText` prop to customize the text of the link contained in the Banner. `actionText` is
51
- only available in the `Full` variant and has a default value of `View All`.
66
+ <ExampleCodeBlock code={StickyAnimation} />
52
67
 
53
- <ExampleCodeBlock code={ActionText} />
68
+ ### RefForwarding
69
+
70
+ `Banner` supports ref forwarding. It will forward ref to its underlying button element.
71
+
72
+ <ExampleCodeBlock code={RefForwarding} />
73
+
74
+ ### Right-to-Left (RTL)
75
+
76
+ Banner supports right-to-left languages when specified in the CanvasProvider theme.
77
+
78
+ <ExampleCodeBlock code={StickyRTL} />
79
+
80
+ ### Themed Banners
81
+
82
+ Banners use the `useThemedPalette` hook for themeing. By default, your alert theme is used. `main`
83
+ will be used for the background, `dark` for the hover background, and `contrast` for the text.
84
+
85
+ <ExampleCodeBlock code={ThemedAlert} />
86
+
87
+ If you set the `hasError` prop, the banner will use your error theme.
88
+
89
+ <ExampleCodeBlock code={ThemedError} />
90
+
91
+ ## Components
92
+
93
+ ### Banner
94
+
95
+ #### Usage
96
+
97
+ `Banner` is a container component rendered as a `<button>` element that is responsible for creating
98
+ a `BannerModel` and sharing it with its subcomponents using React context.
99
+
100
+ ```tsx
101
+ <Banner
102
+ isSticky={true}
103
+ hasError={true} id:
104
+ 'custom-banner-id'
105
+ onClick={() => console.log('clicked banner')}
106
+ >
107
+ {/* Child components */}
108
+ </Banner>
109
+ ```
110
+
111
+ Alternatively, you may pass in a model using the hoisted model pattern.
112
+
113
+ ```tsx
114
+ const model = useBannerModel({
115
+ isSticky: true,
116
+ hasError: true,
117
+ id: 'custom-banner-id',
118
+ });
119
+
120
+ return (
121
+ <Banner onClick={() => console.log('clicked banner')} model={model}>
122
+ {/* Child components */}
123
+ </Banner>
124
+ );
125
+ ```
126
+
127
+ #### Props
128
+
129
+ Undocumented props are spread to the underlying `<button>` element.
130
+
131
+ <ArgsTable of={BannerModelConfigComponent} />
132
+
133
+ If you're using the hoisted model pattern, follow this table instead (refer to the [Model](#model)
134
+ section for more information about `BannerModel`):
135
+
136
+ <ArgsTable of={BannerHoistedComponent} />
137
+
138
+ ### Banner.Icon
139
+
140
+ #### Usage
141
+
142
+ `Banner.Icon` is a styled `<SystemIcon>`. The icon defaults to exclamationTriangleIcon or
143
+ exclamationCircleIcon when the model's hasError is true.
144
+
145
+ ```tsx
146
+ <Banner.Icon />
147
+ ```
148
+
149
+ #### Props
150
+
151
+ You can override the default icon if needed.
152
+
153
+ Undocumented props are spread to the underlying `<SystemIcon>` element.
154
+
155
+ <ArgsTable of={BannerIconComponent} />
156
+
157
+ ### Banner.Label
158
+
159
+ #### Usage
160
+
161
+ `Banner.Label` is a styled `<Flex>`. This component will get an id that will be used for the
162
+ aria-describedby on the top level `<button>`.
163
+
164
+ ```tsx
165
+ <Banner.Label>3 Warnings</Banner.Label>
166
+ ```
167
+
168
+ #### Props
169
+
170
+ The children prop will be used as the Primary text of the Banner.
171
+
172
+ Undocumented props are spread to the underlying `<Flex>` element.
173
+
174
+ <ArgsTable of={BannerLabelComponent} />
175
+
176
+ ### Banner.ActionText
177
+
178
+ #### Usage
179
+
180
+ `Banner.ActionText` is a styled `<Box>`. This component will get an id that will be used for the
181
+ aria-labelledby on the top level `<button>`. This component will be visually hidden when the model's
182
+ `isSticky` prop is set to true.
183
+
184
+ ```tsx
185
+ <Banner.ActionText>Custom call to action</Banner.ActionText>
186
+ ```
187
+
188
+ #### Props
189
+
190
+ The children prop will be used as the 'call to action' text of the Banner.
191
+
192
+ Undocumented props are spread to the underlying `<Box>` element.
193
+
194
+ <ArgsTable of={BannerActionComponent} />
195
+
196
+ ## Model
197
+
198
+ If `Banner` was stripped of all its markup, attributes, and styling, what would remain is the
199
+ [model](/getting-started/for-developers/resources/compound-components/#models). The model is an
200
+ object that holds the `state`, i.e. a description of the current snapshot in time of the component.
201
+
202
+ By default, `Banner` will create a model and share it internally with its subcomponents using React
203
+ context. You may subscribe to `BannerContext` if you wish to create a custom subcomponent for your
204
+ implementation. Here's a simple example.
205
+
206
+ ```tsx
207
+ import * as React from 'react';
208
+ import {Banner, BannerModelContext} from '@workday/canvas-kit-react/banner';
209
+
210
+ const CustomText = (props: React.HTMLAttributes<HTMLSpanElement>) => {
211
+ const model = React.useContext(BannerModelContext);
212
+
213
+ return <span {...props}>{model.state.hasError ? 'Error:' : 'Warning:'}</span>;
214
+ };
215
+
216
+ export const CustomBanner = () => {
217
+ return (
218
+ <Banner>
219
+ <CustomText />
220
+ {/* Other subcomponents */}
221
+ </Banner>
222
+ );
223
+ };
224
+ ```
225
+
226
+ Alternatively, if you need direct access to the model's `state` outside of the `Banner` component,
227
+ you may configure your own model with `useBannerModel` and pass it to `Banner` via a pattern called
228
+ [hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
229
+
230
+ ```tsx
231
+ const model = useBannerModel({
232
+ isError: true,
233
+ });
234
+
235
+ <Banner model={model}>{/* Child components */}</Banner>;
236
+ ```
54
237
 
55
- ## Props
238
+ ### Config
56
239
 
57
- Undocumented props are spread to the outermost element rendered by Banner.
240
+ `useBannerModel` accepts a configuration object with the following properties and returns a
241
+ `BannerModel` with a `state` property.
58
242
 
59
- <ArgsTable of={Banner} />
243
+ <ArgsTable of={BannerModelConfigComponent} />
@@ -0,0 +1,39 @@
1
+ import {BannerModel, BannerModelConfig} from '@workday/canvas-kit-react/banner';
2
+ import {CanvasSystemIcon} from '@workday/design-assets-types';
3
+ import {BannerActionProps} from '../lib/BannerAction';
4
+
5
+ // <ArgsTable of={Banner} /> generates a very large props table given that
6
+ // BannerProps includes FlexProps. Use this dummy component instead to
7
+ // limit the props shown.
8
+ export const BannerHoistedComponent = (_: {model: BannerModel}) => <div />;
9
+
10
+ // <ArgsTable of={Banner.Icon} /> generates a props table with
11
+ // SystemIcon props. Use this dummy component instead to limit the props shown.
12
+ export const BannerIconComponent = (_: {
13
+ /**
14
+ * Icon to show next to label
15
+ * @default `exclamationTriangleIcon` or `exclamationCircleIcon` when hasError is true
16
+ */
17
+ icon?: CanvasSystemIcon;
18
+ }) => <div />;
19
+
20
+ // <ArgsTable of={Banner.Label} /> generates a props table with
21
+ // Flex props. Use this dummy component instead to limit the props shown.
22
+ export const BannerLabelComponent = (_: {
23
+ /**
24
+ * The text of the Banner.
25
+ */
26
+ children: React.ReactNode;
27
+ }) => <div />;
28
+
29
+ // <ArgsTable of={Banner.ActionText} /> generates a props table with
30
+ // Box props. Use this dummy component instead to limit the props shown.
31
+ export const BannerActionComponent = (_: {
32
+ /**
33
+ * The text of the Banner action.
34
+ * @default 'View All'
35
+ */
36
+ children?: React.ReactNode;
37
+ }) => <div />;
38
+
39
+ export const BannerModelConfigComponent = (_: BannerModelConfig) => <div />;
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
+
2
3
  import {Banner} from '@workday/canvas-kit-react/banner';
3
4
 
4
5
  export default () => {
5
- return <Banner actionText="Show Details" label="3 Warnings" />;
6
+ return (
7
+ <Banner>
8
+ <Banner.Icon />
9
+ <Banner.Label>3 Warnings</Banner.Label>
10
+ <Banner.ActionText>Show Details</Banner.ActionText>
11
+ </Banner>
12
+ );
6
13
  };
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
+
2
3
  import {Banner} from '@workday/canvas-kit-react/banner';
3
4
 
4
5
  export default () => {
5
- return <Banner label="3 Warnings" />;
6
+ return (
7
+ <Banner onClick={() => console.log('clicked banner')}>
8
+ <Banner.Icon />
9
+ <Banner.Label>3 Warnings</Banner.Label>
10
+ <Banner.ActionText />
11
+ </Banner>
12
+ );
6
13
  };
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
+
2
3
  import {Banner} from '@workday/canvas-kit-react/banner';
3
4
 
4
5
  export default () => {
5
- return <Banner error={Banner.ErrorType.Error} label="3 Errors" />;
6
+ return (
7
+ <Banner hasError={true}>
8
+ <Banner.Icon />
9
+ <Banner.Label>3 Errors</Banner.Label>
10
+ <Banner.ActionText />
11
+ </Banner>
12
+ );
6
13
  };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ import {changeFocus} from '@workday/canvas-kit-react/common';
4
+ import {Banner} from '@workday/canvas-kit-react/banner';
5
+ import {SecondaryButton} from '@workday/canvas-kit-react/button';
6
+ import {VStack} from '@workday/canvas-kit-react/layout';
7
+
8
+ export default () => {
9
+ const bannerRef = React.useRef<HTMLButtonElement>(null);
10
+
11
+ const focusBanner = () => {
12
+ changeFocus(bannerRef.current);
13
+ };
14
+
15
+ return (
16
+ <VStack spacing="xs" alignItems="flex-start">
17
+ <Banner ref={bannerRef}>
18
+ <Banner.Icon />
19
+ <Banner.Label>3 Warnings</Banner.Label>
20
+ <Banner.ActionText />
21
+ </Banner>
22
+ <SecondaryButton onClick={focusBanner}>Focus Banner</SecondaryButton>
23
+ </VStack>
24
+ );
25
+ };