@workday/canvas-kit-docs 6.3.3 → 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.
- package/dist/commonjs/lib/specs.js +56 -0
- package/dist/es6/lib/specs.js +56 -0
- package/dist/mdx/7.0-MIGRATION-GUIDE.mdx +47 -0
- package/dist/mdx/react/action-bar/ActionBar.mdx +7 -25
- package/dist/mdx/react/action-bar/examples/Basic.tsx +3 -3
- package/dist/mdx/react/banner/Banner.mdx +203 -19
- package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
- package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
- package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
- package/dist/mdx/react/banner/examples/Error.tsx +8 -1
- package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
- package/dist/mdx/react/banner/examples/Sticky.tsx +15 -7
- package/dist/mdx/react/banner/examples/StickyAnimation.tsx +62 -0
- package/dist/mdx/react/banner/examples/StickyRTL.tsx +38 -0
- package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
- package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
- package/package.json +3 -3
|
@@ -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",
|
package/dist/es6/lib/specs.js
CHANGED
|
@@ -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",
|
|
@@ -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.
|
|
@@ -6,7 +6,7 @@ import Basic from './examples/Basic';
|
|
|
6
6
|
|
|
7
7
|
# Canvas Kit Action Bar
|
|
8
8
|
|
|
9
|
-
|
|
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
|
|
23
|
-
aligned followed by secondary buttons.
|
|
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
|
|
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
|
-
|
|
50
|
-
|
|
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
|
|
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>
|
|
9
|
-
<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
|
-
|
|
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
|
-
###
|
|
42
|
+
### Action Text
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
33
|
-
- `Banner.ErrorType.Error`
|
|
47
|
+
<ExampleCodeBlock code={ActionText} />
|
|
34
48
|
|
|
35
|
-
|
|
49
|
+
### Error Type
|
|
36
50
|
|
|
37
|
-
|
|
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
|
-
|
|
54
|
+
<ExampleCodeBlock code={Error} />
|
|
40
55
|
|
|
41
|
-
|
|
42
|
-
- `Banner.Variant.Sticky`
|
|
56
|
+
### Sticky
|
|
43
57
|
|
|
44
|
-
|
|
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
|
-
|
|
64
|
+
You can use keyframes to animate the `Banner` in.
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
only available in the `Full` variant and has a default value of `View All`.
|
|
66
|
+
<ExampleCodeBlock code={StickyAnimation} />
|
|
52
67
|
|
|
53
|
-
|
|
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
|
-
|
|
238
|
+
### Config
|
|
56
239
|
|
|
57
|
-
|
|
240
|
+
`useBannerModel` accepts a configuration object with the following properties and returns a
|
|
241
|
+
`BannerModel` with a `state` property.
|
|
58
242
|
|
|
59
|
-
<ArgsTable of={
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "
|
|
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": "^
|
|
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": "
|
|
61
|
+
"gitHead": "69f28d82a0291ed45c2c9d3ef92e437d69033471"
|
|
62
62
|
}
|