@workday/canvas-kit-docs 6.3.0 → 7.0.0-alpha.0-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.
@@ -41,6 +41,62 @@ module.exports = {specifications: [
41
41
  }
42
42
  ]
43
43
  },
44
+ {
45
+ "type": "file",
46
+ "name": "Banner.spec.ts",
47
+ "children": [
48
+ {
49
+ "type": "describe",
50
+ "name": "Banner",
51
+ "children": [
52
+ {
53
+ "type": "describe",
54
+ "name": "given the [Components/Indicators/Banner/React, Error] story is rendered",
55
+ "children": [
56
+ {
57
+ "type": "it",
58
+ "name": "should pass axe checks"
59
+ },
60
+ {
61
+ "type": "it",
62
+ "name": "should have an element with a role of \"button\""
63
+ },
64
+ {
65
+ "type": "it",
66
+ "name": "should have an \"aria-labelledby\" that matches the action"
67
+ },
68
+ {
69
+ "type": "it",
70
+ "name": "should have an \"aria-describedby\" that matches the label"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "type": "describe",
76
+ "name": "given the [Components/Indicators/Banner/React, Sticky] story is rendered",
77
+ "children": [
78
+ {
79
+ "type": "it",
80
+ "name": "should pass axe checks"
81
+ },
82
+ {
83
+ "type": "it",
84
+ "name": "should have an element with a role of \"button\""
85
+ },
86
+ {
87
+ "type": "it",
88
+ "name": "should have an \"aria-labelledby\" that matches the action"
89
+ },
90
+ {
91
+ "type": "it",
92
+ "name": "should have an \"aria-describedby\" that matches the label"
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ },
44
100
  {
45
101
  "type": "file",
46
102
  "name": "Breadcrumbs.spec.ts",
@@ -41,6 +41,62 @@ module.exports = {specifications: [
41
41
  }
42
42
  ]
43
43
  },
44
+ {
45
+ "type": "file",
46
+ "name": "Banner.spec.ts",
47
+ "children": [
48
+ {
49
+ "type": "describe",
50
+ "name": "Banner",
51
+ "children": [
52
+ {
53
+ "type": "describe",
54
+ "name": "given the [Components/Indicators/Banner/React, Error] story is rendered",
55
+ "children": [
56
+ {
57
+ "type": "it",
58
+ "name": "should pass axe checks"
59
+ },
60
+ {
61
+ "type": "it",
62
+ "name": "should have an element with a role of \"button\""
63
+ },
64
+ {
65
+ "type": "it",
66
+ "name": "should have an \"aria-labelledby\" that matches the action"
67
+ },
68
+ {
69
+ "type": "it",
70
+ "name": "should have an \"aria-describedby\" that matches the label"
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "type": "describe",
76
+ "name": "given the [Components/Indicators/Banner/React, Sticky] story is rendered",
77
+ "children": [
78
+ {
79
+ "type": "it",
80
+ "name": "should pass axe checks"
81
+ },
82
+ {
83
+ "type": "it",
84
+ "name": "should have an element with a role of \"button\""
85
+ },
86
+ {
87
+ "type": "it",
88
+ "name": "should have an \"aria-labelledby\" that matches the action"
89
+ },
90
+ {
91
+ "type": "it",
92
+ "name": "should have an \"aria-describedby\" that matches the label"
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ },
44
100
  {
45
101
  "type": "file",
46
102
  "name": "Breadcrumbs.spec.ts",
@@ -216,8 +216,11 @@ const CustomGlobalHeader = props => {
216
216
  };
217
217
  ```
218
218
 
219
- You may continue to use this component exactly as you did in v5, but note that we plan to hard-deprecate it in Canvas Kit v7.
220
- If you would like to migrate away from this deprecated component now, you can reference [this example](https://workday.github.io/canvas-kit/?path=/story/examples-global-header-react--basic) instead.
219
+ You may continue to use this component exactly as you did in v5, but note that we plan to
220
+ hard-deprecate it in Canvas Kit v7. If you would like to migrate away from this deprecated component
221
+ now, you can reference
222
+ [this example](https://workday.github.io/canvas-kit/?path=/story/examples-global-header-react--basic)
223
+ instead.
221
224
 
222
225
  ### Page Header
223
226
 
@@ -270,8 +273,11 @@ export const CustomPageHeader = (props: CustomPageHeaderProps) => {
270
273
  };
271
274
  ```
272
275
 
273
- You may continue to use this component exactly as you did in v5, but note that we plan to hard-deprecate it in Canvas Kit v7.
274
- If you would like to migrate away from this deprecated component now, you can reference [this example](https://workday.github.io/canvas-kit/?path=/story/examples-page-header-react--basic) instead.
276
+ You may continue to use this component exactly as you did in v5, but note that we plan to
277
+ hard-deprecate it in Canvas Kit v7. If you would like to migrate away from this deprecated component
278
+ now, you can reference
279
+ [this example](https://workday.github.io/canvas-kit/?path=/story/examples-page-header-react--basic)
280
+ instead.
275
281
 
276
282
  ## Component Migrations
277
283
 
@@ -380,7 +386,8 @@ Also for reference, these are our viewport ranges:
380
386
  `max-width: 575px`. They now use `max-width: 767.5px` – the upper limit of the `small` range. This
381
387
  will have two effects for this component:
382
388
 
383
- - Container padding will decrease from `s` (`16px`) to `xxs` (`8px`) on all viewports less than `768px` wide
389
+ - Container padding will decrease from `s` (`16px`) to `xxs` (`8px`) on all viewports less than
390
+ `768px` wide
384
391
  - This was previously happening only on viewports less than `576px` wide
385
392
  - Button order will be reversed on all viewports less than `768px` wide
386
393
  - This was previously happening only on viewports less than `576px` wide
@@ -0,0 +1,47 @@
1
+ # Canvas Kit 7.0 Migration Guide
2
+
3
+ Below are the breaking changes made in Canvas Kit v7. Please
4
+ [reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
5
+ any questions about the update.
6
+
7
+ - [Codemod](#codemod)
8
+ - [ActionBar Component Updates](#actionbar-component-updates)
9
+
10
+ ## Codemod
11
+
12
+ Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
13
+ to automatically update your code to work with a majority of the breaking changes in the migration
14
+ from Canvas Kit v6 to v7:
15
+
16
+ ```sh
17
+ > npx @workday/canvas-kit-codemod v7 [path]
18
+ ```
19
+
20
+ > Note: This codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` extensions. You may need to make
21
+ > some manual changes in other file types (`.json`, `.mdx`, `.md`, etc.).
22
+
23
+ > Note: You may need to run your linter after executing the codemod, as it's resulting formatting
24
+ > (spacing, quotes, etc.) may not match your project's styling.
25
+
26
+ **Breaking changes accounted for by this codemod will be marked with a 🤖.**
27
+
28
+ **Please verify all changes made by the codemod. As a safety precaution, we recommend committing the
29
+ changes from the codemod as a single isolated commit (separate from other changes) so you can
30
+ rollback more easily if necessary.**
31
+
32
+ [Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
33
+ encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
34
+ help us maintain additional codemod transforms to make future migrations easier.
35
+
36
+ ## ActionBar Component Updates
37
+
38
+ We've refactored our ActionBar components to simplify logic.
39
+
40
+ PR: https://github.com/Workday/canvas-kit/pull/1396
41
+
42
+ **Changes:**
43
+
44
+ - Component has been converted to compound component.
45
+ - `fixed` prop has been removed from component.
46
+ - Now ActionBar uses `position` prop to set container position instead `fixed` prop.
47
+ - Fixed position has been set as default if there is not passed `position` prop.
@@ -1,5 +1,4 @@
1
1
  import Changelog from '../../../CHANGELOG.md';
2
2
  import Markdown from '../../../utils/storybook/Markdown.tsx';
3
3
 
4
-
5
4
  <Markdown content={Changelog} />
@@ -170,8 +170,8 @@ wrapping children in `Stack.Item`s. A `Stack.Item` is a `Box` with some preset s
170
170
  overridden if needed.
171
171
 
172
172
  In the example below, we wanted to keep our `li` elements as direct children of the `ul` stack. So
173
- we're wrapping each of the links with `Stack.Item`s, casting them as `li`s and applying custom styles to each.
174
- This would not be possible with `shouldWrapChildren`.
173
+ we're wrapping each of the links with `Stack.Item`s, casting them as `li`s and applying custom
174
+ styles to each. This would not be possible with `shouldWrapChildren`.
175
175
 
176
176
  <ExampleCodeBlock code={StackItems} />
177
177
 
@@ -31,8 +31,7 @@ based on search input.
31
31
 
32
32
  ### Grow
33
33
 
34
- If you'd like `SearchForm` to grow to the width of its container, set the `grow` prop to
35
- `true`.
34
+ If you'd like `SearchForm` to grow to the width of its container, set the `grow` prop to `true`.
36
35
 
37
36
  <ExampleCodeBlock code={Grow} />
38
37
 
@@ -51,7 +50,6 @@ Below is a table of attributes that can be supplied to `SearchForm`:
51
50
 
52
51
  <ArgsTable of={ThemeAttributes} />
53
52
 
54
-
55
53
  ### RTL (Right-To-Left)
56
54
 
57
55
  `SearchForm` provides bidirectional support out of the box. You shouldn't need to provide any
@@ -4,6 +4,9 @@ import Basic from './examples/GlobalHeader';
4
4
  # Canvas Kit Examples
5
5
 
6
6
  ## GlobalHeader
7
- Developers building internal Workday applications will likely not need to create this component. However, if you're building components to be used outside of Workday, this is a helpful reference for building a global navigation header that looks like our internal `GlobalHeader`.
7
+
8
+ Developers building internal Workday applications will likely not need to create this component.
9
+ However, if you're building components to be used outside of Workday, this is a helpful reference
10
+ for building a global navigation header that looks like our internal `GlobalHeader`.
8
11
 
9
12
  <ExampleCodeBlock code={Basic} />
@@ -1,4 +1,4 @@
1
- import {Basic} from "./examples/PageHeader";
1
+ import Basic from './examples/PageHeader';
2
2
 
3
3
 
4
4
  # Canvas Kit Examples
@@ -6,7 +6,7 @@ import Basic from './examples/Basic';
6
6
 
7
7
  # Canvas Kit Action Bar
8
8
 
9
- Full width button toolbar fixed to bottom of screen.
9
+ Action Bar contains primary and secondary actions related to a page or task.
10
10
 
11
11
  ## Installation
12
12
 
@@ -19,38 +19,20 @@ yarn add @workday/canvas-kit-react
19
19
  ### Basic Example
20
20
 
21
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.
22
+ [buttons](../../button) are often used in in action bars. The primary action button should be used
23
+ only once and left aligned followed by secondary buttons.
25
24
 
26
25
  <ExampleCodeBlock code={Basic} />
27
26
 
28
- ### Fixed
29
-
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.
32
-
33
- ```tsx
34
- <ActionBar fixed={true}>
35
- <PrimaryButton>Button</PrimaryButton>
36
- <SecondaryButton>Button</SecondaryButton>
37
- </ActionBar>
38
- ```
39
-
40
27
  ## Responsive Behavior
41
28
 
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.
29
+ At 768px, responsive styles will take effect:
48
30
 
49
- > When on a mobile form factor, the button placement should flip to have the primary button on the
50
- > far right.
31
+ - All primary and secondary buttons will become the same width (`flex: 1`).
32
+ - Container Bar padding will be decreased to small (`16px`) for all sides.
51
33
 
52
34
  ## Props
53
35
 
54
- Undocumented props are spread to the underlying container `<div>` element.
36
+ Undocumented props are spread to the underlying `HStack` component.
55
37
 
56
38
  <ArgsTable of={ActionBar} />
@@ -4,8 +4,8 @@ import {ActionBar} from '@workday/canvas-kit-react/action-bar';
4
4
  import {PrimaryButton, SecondaryButton} from '@workday/canvas-kit-react/button';
5
5
 
6
6
  export default () => (
7
- <ActionBar>
8
- <PrimaryButton>Button</PrimaryButton>
9
- <SecondaryButton>Button</SecondaryButton>
7
+ <ActionBar position="relative">
8
+ <PrimaryButton>First Action</PrimaryButton>
9
+ <SecondaryButton>Second Action</SecondaryButton>
10
10
  </ActionBar>
11
11
  );
@@ -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 '../../..';
6
+ import {VStack} from '@workday/canvas-kit-labs-react';
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
+ };
@@ -1,16 +1,24 @@
1
+ /** @jsx jsx */
2
+ import {jsx} from '@emotion/core';
1
3
  import React from 'react';
4
+
5
+ import {CSSProperties} from '@workday/canvas-kit-react/tokens';
6
+ import {Box, useThemeRTL} from '@workday/canvas-kit-labs-react/common';
2
7
  import {Banner} from '@workday/canvas-kit-react/banner';
3
- import {Box} from '@workday/canvas-kit-labs-react/common';
8
+
9
+ const styles: CSSProperties = {
10
+ position: 'absolute',
11
+ right: 0,
12
+ };
4
13
 
5
14
  export default () => {
6
15
  return (
7
16
  <Box height={64}>
8
- <Banner
9
- error={Banner.ErrorType.Error}
10
- label="3 Errors"
11
- variant={Banner.Variant.Sticky}
12
- style={{position: 'absolute', right: 0}}
13
- />
17
+ <Banner hasError={true} isSticky={true} css={styles}>
18
+ <Banner.Icon />
19
+ <Banner.Label>3 Errors</Banner.Label>
20
+ <Banner.ActionText />
21
+ </Banner>
14
22
  </Box>
15
23
  );
16
24
  };
@@ -0,0 +1,62 @@
1
+ /** @jsx jsx */
2
+ import {jsx, keyframes} from '@emotion/core';
3
+ import React from 'react';
4
+
5
+ import {CSSProperties} from '@workday/canvas-kit-react/tokens';
6
+ import {Box, useThemeRTL} from '@workday/canvas-kit-labs-react/common';
7
+ import {loopIcon} from '@workday/canvas-system-icons-web';
8
+ import {Banner} from '@workday/canvas-kit-react/banner';
9
+
10
+ const containerStyles: CSSProperties = {
11
+ position: 'absolute',
12
+ right: 0,
13
+ overflow: 'hidden',
14
+ };
15
+
16
+ export default () => {
17
+ const {themeRTL, theme} = useThemeRTL();
18
+ const bannerRef = React.useRef<HTMLButtonElement>(null);
19
+ const containerRef = React.useRef<HTMLDivElement>(null);
20
+ const [styles, setStyles] = React.useState<CSSProperties>();
21
+
22
+ const [rerun, setRerun] = React.useState(1); // Only needed for demo purposes
23
+
24
+ React.useLayoutEffect(() => {
25
+ let width = bannerRef.current.offsetWidth;
26
+ if (theme.canvas.direction === 'rtl') {
27
+ width *= -1;
28
+ }
29
+ const slideInKeyframes = keyframes({
30
+ '0%': {
31
+ transform: `translateX(${width}px)`,
32
+ },
33
+ '100%': {
34
+ transform: `translateX(0 * ${rerun})`,
35
+ },
36
+ });
37
+
38
+ setStyles({
39
+ margin: '4px 0px 4px 4px', // Room for focus outline since container is overflow hidden
40
+ animation: `${slideInKeyframes} .3s ease-out forwards`,
41
+ });
42
+ }, [theme.canvas.direction, rerun]);
43
+
44
+ return (
45
+ <Box height={64}>
46
+ <div css={containerStyles} ref={containerRef}>
47
+ <div css={themeRTL(styles)}>
48
+ <Banner
49
+ onClick={() => setRerun(r => r + 1)}
50
+ hasError={true}
51
+ isSticky={true}
52
+ ref={bannerRef}
53
+ >
54
+ <Banner.Icon icon={loopIcon} />
55
+ <Banner.Label>Click to run animation</Banner.Label>
56
+ <Banner.ActionText />
57
+ </Banner>
58
+ </div>
59
+ </div>
60
+ </Box>
61
+ );
62
+ };
@@ -0,0 +1,38 @@
1
+ /** @jsx jsx */
2
+ import {jsx} from '@emotion/core';
3
+ import React from 'react';
4
+
5
+ import {CSSProperties} from '@workday/canvas-kit-react/tokens';
6
+ import {Box, useThemeRTL} from '@workday/canvas-kit-labs-react/common';
7
+ import {
8
+ CanvasProvider,
9
+ ContentDirection,
10
+ PartialEmotionCanvasTheme,
11
+ } from '@workday/canvas-kit-react/common';
12
+ import {Banner} from '@workday/canvas-kit-react/banner';
13
+
14
+ const styles: CSSProperties = {
15
+ position: 'absolute',
16
+ left: 0,
17
+ };
18
+
19
+ const theme: PartialEmotionCanvasTheme = {
20
+ canvas: {
21
+ direction: ContentDirection.RTL,
22
+ },
23
+ };
24
+
25
+ export default () => {
26
+ const {themeRTL} = useThemeRTL();
27
+ return (
28
+ <CanvasProvider theme={theme}>
29
+ <Box height={64}>
30
+ <Banner isSticky={true} css={styles}>
31
+ <Banner.Icon />
32
+ <Banner.Label>3 אזהרות</Banner.Label>
33
+ <Banner.ActionText />
34
+ </Banner>
35
+ </Box>
36
+ </CanvasProvider>
37
+ );
38
+ };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ import {Banner} from '@workday/canvas-kit-react/banner';
4
+ import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ const theme: PartialEmotionCanvasTheme = {
9
+ canvas: {
10
+ palette: {
11
+ alert: {
12
+ main: colors.kiwi200,
13
+ dark: colors.kiwi300,
14
+ },
15
+ },
16
+ },
17
+ };
18
+
19
+ return (
20
+ <CanvasProvider theme={theme}>
21
+ <Banner>
22
+ <Banner.Icon />
23
+ <Banner.Label>3 Items</Banner.Label>
24
+ <Banner.ActionText />
25
+ </Banner>
26
+ </CanvasProvider>
27
+ );
28
+ };
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+
3
+ import {Banner} from '@workday/canvas-kit-react/banner';
4
+ import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ const theme: PartialEmotionCanvasTheme = {
9
+ canvas: {
10
+ palette: {
11
+ error: {
12
+ main: colors.islandPunch500,
13
+ dark: colors.islandPunch600,
14
+ contrast: colors.berrySmoothie100,
15
+ },
16
+ },
17
+ },
18
+ };
19
+
20
+ return (
21
+ <CanvasProvider theme={theme}>
22
+ <Banner hasError={true}>
23
+ <Banner.Icon />
24
+ <Banner.Label>3 Items</Banner.Label>
25
+ <Banner.ActionText />
26
+ </Banner>
27
+ </CanvasProvider>
28
+ );
29
+ };
@@ -66,8 +66,8 @@ for every size and can be positioned to the `left` or `right` with the `iconPosi
66
66
 
67
67
  <ExampleCodeBlock code={Secondary} />
68
68
 
69
- Secondary Buttons also have an `inverse` variant. Use this when you need to place a Secondary Button on
70
- a dark or colorful background such as `blueberry400`.
69
+ Secondary Buttons also have an `inverse` variant. Use this when you need to place a Secondary Button
70
+ on a dark or colorful background such as `blueberry400`.
71
71
 
72
72
  <ExampleCodeBlock code={SecondaryInverse} />
73
73
 
@@ -84,17 +84,16 @@ the user may not often be looking to do. Tertiary Buttons have lower prominence
84
84
  not visible until it is interacted with. Use Tertiary Buttons for supplemental actions such as “View
85
85
  More”, “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
86
86
 
87
- Tertiary Buttons have three sizes: `extraSmall`, `small`, and `medium`. Icons are supported
88
- for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
87
+ Tertiary Buttons have three sizes: `extraSmall`, `small`, and `medium`. Icons are supported for
88
+ every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
89
89
 
90
90
  <ExampleCodeBlock code={Tertiary} />
91
91
 
92
- Tertiary Buttons also have an `inverse` variant. Use this when you need to place a Tertiary Button on
93
- a dark or colorful background such as `blueberry400`.
92
+ Tertiary Buttons also have an `inverse` variant. Use this when you need to place a Tertiary Button
93
+ on a dark or colorful background such as `blueberry400`.
94
94
 
95
95
  <ExampleCodeBlock code={TertiaryInverse} />
96
96
 
97
-
98
97
  #### Props
99
98
 
100
99
  Undocumented props are spread to the underlying `<button>` element.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "6.3.0",
3
+ "version": "7.0.0-alpha.0-next.0+69f28d82",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -50,7 +50,7 @@
50
50
  ],
51
51
  "dependencies": {
52
52
  "@storybook/csf": "0.0.1",
53
- "@workday/canvas-kit-react": "^6.3.0"
53
+ "@workday/canvas-kit-react": "^7.0.0-alpha.0-next.0+69f28d82"
54
54
  },
55
55
  "devDependencies": {
56
56
  "fs-extra": "^10.0.0",
@@ -58,5 +58,5 @@
58
58
  "mkdirp": "^1.0.3",
59
59
  "typescript": "^3.8.3"
60
60
  },
61
- "gitHead": "94d5ae2d79daa43b9c2ef5f8eef572fc89694d5e"
61
+ "gitHead": "69f28d82a0291ed45c2c9d3ef92e437d69033471"
62
62
  }