@workday/canvas-kit-docs 6.3.1 → 7.0.0-alpha.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/lib/specs.js +56 -0
- package/dist/es6/lib/specs.js +56 -0
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +12 -5
- package/dist/mdx/7.0-MIGRATION-GUIDE.mdx +61 -0
- package/dist/mdx/changelog.stories.mdx +0 -1
- package/dist/mdx/labs-react/layout/Stack.mdx +2 -2
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +1 -3
- package/dist/mdx/react/_examples/GlobalHeader.mdx +4 -1
- package/dist/mdx/react/_examples/PageHeader.mdx +1 -1
- 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/dist/mdx/react/button/button/Button.mdx +6 -7
- package/dist/mdx/react/status-indicator/StatusIndicator.mdx +12 -0
- package/dist/mdx/react/status-indicator/examples/MaxWidth.tsx +30 -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",
|
|
@@ -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
|
|
220
|
-
If you would like to migrate away from this deprecated component
|
|
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
|
|
274
|
-
If you would like to migrate away from this deprecated component
|
|
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
|
|
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,61 @@
|
|
|
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
|
+
- [Status Indicator Width](#status-indicator-width)
|
|
10
|
+
|
|
11
|
+
## Codemod
|
|
12
|
+
|
|
13
|
+
Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
|
|
14
|
+
to automatically update your code to work with a majority of the breaking changes in the migration
|
|
15
|
+
from Canvas Kit v6 to v7:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
> npx @workday/canvas-kit-codemod v7 [path]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> Note: This codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` extensions. You may need to make
|
|
22
|
+
> some manual changes in other file types (`.json`, `.mdx`, `.md`, etc.).
|
|
23
|
+
|
|
24
|
+
> Note: You may need to run your linter after executing the codemod, as it's resulting formatting
|
|
25
|
+
> (spacing, quotes, etc.) may not match your project's styling.
|
|
26
|
+
|
|
27
|
+
**Breaking changes accounted for by this codemod will be marked with a 🤖.**
|
|
28
|
+
|
|
29
|
+
**Please verify all changes made by the codemod. As a safety precaution, we recommend committing the
|
|
30
|
+
changes from the codemod as a single isolated commit (separate from other changes) so you can
|
|
31
|
+
rollback more easily if necessary.**
|
|
32
|
+
|
|
33
|
+
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
34
|
+
encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
|
|
35
|
+
help us maintain additional codemod transforms to make future migrations easier.
|
|
36
|
+
|
|
37
|
+
## ActionBar Component Updates
|
|
38
|
+
|
|
39
|
+
We've refactored our ActionBar components to simplify logic.
|
|
40
|
+
|
|
41
|
+
PR: https://github.com/Workday/canvas-kit/pull/1396
|
|
42
|
+
|
|
43
|
+
**Changes:**
|
|
44
|
+
|
|
45
|
+
- Component has been converted to compound component.
|
|
46
|
+
- `fixed` prop has been removed from component.
|
|
47
|
+
- Now ActionBar uses `position` prop to set container position instead `fixed` prop.
|
|
48
|
+
- Fixed position has been set as default if there is not passed `position` prop.
|
|
49
|
+
|
|
50
|
+
## Status Indicator Width
|
|
51
|
+
|
|
52
|
+
Status Indicators currently truncate when they reach their max width of `150px`. After receiving
|
|
53
|
+
requests to increase this, we have upped it by 25% to `200px`.
|
|
54
|
+
|
|
55
|
+
We've also added a prop (`maxWidth`) to configure this if you need to. While this increases
|
|
56
|
+
flexibility, please keep in mind that status text should be short, direct, and preferably a single
|
|
57
|
+
word.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<StatusIndicator label="Slightly Longer Status" type={StatusIndicator.Type.Gray} maxWidth={250} />
|
|
61
|
+
```
|
|
@@ -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
|
|
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
|
-
|
|
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} />
|
|
@@ -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
|
+
};
|
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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.
|
|
@@ -3,6 +3,7 @@ import {StatusIndicator} from '@workday/canvas-kit-react/status-indicator';
|
|
|
3
3
|
import Basic from './examples/Basic';
|
|
4
4
|
import Icon from './examples/Icon';
|
|
5
5
|
import Emphasis from './examples/Emphasis';
|
|
6
|
+
import MaxWidth from './examples/MaxWidth';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
# Canvas Kit Status Indicator
|
|
@@ -54,6 +55,17 @@ label.
|
|
|
54
55
|
|
|
55
56
|
<ExampleCodeBlock code={Icon} />
|
|
56
57
|
|
|
58
|
+
### Max Width
|
|
59
|
+
|
|
60
|
+
By default, the maximum width of a Status Indicator is `200px`. When the text in the StatusIndicator
|
|
61
|
+
exceeds the max width, it will be truncated with an ellipsis. This maxWidth can be customized.
|
|
62
|
+
|
|
63
|
+
Avoid truncation wherever possible by using shorter text in Status Indicators. In the case where
|
|
64
|
+
truncation is necessary, you should use an `OverflowTooltip`. For the full text to be accessible
|
|
65
|
+
when you do this, you should make the tooltip focusable with `tabIndex`.
|
|
66
|
+
|
|
67
|
+
<ExampleCodeBlock code={MaxWidth} />
|
|
68
|
+
|
|
57
69
|
## Props
|
|
58
70
|
|
|
59
71
|
Undocumented props are spread to the outermost element rendered by Status Indicator.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import {StatusIndicator} from '@workday/canvas-kit-react/status-indicator';
|
|
4
|
+
import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
|
|
5
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
6
|
+
|
|
7
|
+
const StatusIndicators = styled('div')({
|
|
8
|
+
'& > *': {
|
|
9
|
+
margin: space.xxs,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default () => {
|
|
14
|
+
return (
|
|
15
|
+
<StatusIndicators>
|
|
16
|
+
<StatusIndicator
|
|
17
|
+
label="Longer Than Normal Ellipsized Status"
|
|
18
|
+
type={StatusIndicator.Type.Blue}
|
|
19
|
+
maxWidth={250}
|
|
20
|
+
/>
|
|
21
|
+
<OverflowTooltip>
|
|
22
|
+
<StatusIndicator
|
|
23
|
+
label="Overflow Tooltip On Hover/Focus Status"
|
|
24
|
+
type={StatusIndicator.Type.Green}
|
|
25
|
+
tabIndex={0}
|
|
26
|
+
/>
|
|
27
|
+
</OverflowTooltip>
|
|
28
|
+
</StatusIndicators>
|
|
29
|
+
);
|
|
30
|
+
};
|
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.1+57471fa0",
|
|
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.1+57471fa0"
|
|
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": "57471fa0c73534126f9ef9a18203d49c5834d21e"
|
|
62
62
|
}
|