@workday/canvas-kit-docs 6.0.0-alpha.0-next.31 → 6.0.0-alpha.0-next.37
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/LICENSE +1 -1
- package/dist/commonjs/lib/specs.js +351 -33
- package/dist/es6/lib/specs.js +351 -33
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +76 -12
- package/dist/mdx/7.0-MIGRATION-GUIDE.mdx +33 -0
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +31 -30
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
- package/dist/mdx/preview-react/form-field/FormField.mdx +27 -0
- package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +1 -1
- package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +31 -0
- package/dist/mdx/preview-react/text-area/examples/Basic.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Error.tsx +40 -0
- package/dist/mdx/preview-react/text-area/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +21 -0
- package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +28 -0
- package/dist/mdx/preview-react/text-area/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +22 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/TextInput.mdx +40 -18
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
- package/dist/mdx/{labs-react/text-input/examples/HiddenLabel.tsx → preview-react/text-input/examples/Basic.tsx} +3 -3
- package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/Error.tsx +6 -9
- package/dist/mdx/preview-react/text-input/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/LoginForm.tsx +10 -5
- package/dist/mdx/preview-react/text-input/examples/Password.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/RefForwarding.tsx +7 -6
- package/dist/mdx/preview-react/text-input/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +46 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/ThemedError.tsx +8 -11
- package/dist/mdx/react/_examples/GlobalHeader.mdx +9 -0
- package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
- package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +66 -0
- package/dist/mdx/react/_examples/examples/PageHeader.tsx +63 -0
- package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
- 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 +7 -7
- package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
- package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
- package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
- package/dist/mdx/react/pagination/PropTables.splitprops.tsx +47 -0
- package/dist/mdx/react/pagination/examples/{StepControls.tsx → Basic.tsx} +1 -1
- package/dist/mdx/react/pagination/examples/GoToForm.tsx +1 -1
- package/dist/mdx/react/pagination/examples/HoistedModel.tsx +36 -22
- package/dist/mdx/react/pagination/examples/RTL.tsx +1 -1
- package/dist/mdx/react/pagination/pagination.mdx +225 -474
- package/dist/mdx/react/popup/Popup.mdx +34 -36
- package/dist/mdx/react/radio/examples/Alert.tsx +3 -3
- package/dist/mdx/react/radio/examples/Basic.tsx +3 -3
- package/dist/mdx/react/radio/examples/Disabled.tsx +3 -3
- package/dist/mdx/react/radio/examples/Error.tsx +3 -3
- package/dist/mdx/react/radio/examples/LabelPosition.tsx +3 -3
- package/dist/mdx/react/radio/examples/NoValue.tsx +3 -3
- package/dist/mdx/react/radio/examples/RefForwarding.tsx +3 -3
- package/dist/mdx/react/radio/examples/Required.tsx +3 -3
- package/dist/mdx/react/segmented-control/SegmentedControl.mdx +1 -1
- package/dist/mdx/react/tabs/Tabs.mdx +67 -36
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +41 -13
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
- package/dist/mdx/react/tabs/examples/Icons.tsx +36 -0
- package/dist/mdx/react/tabs/examples/{NamedKeys.tsx → NamedTabs.tsx} +0 -0
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +58 -0
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/toast/toast.mdx +1 -17
- package/dist/mdx/react/tooltip/Tooltip.mdx +9 -1
- package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
- package/package.json +5 -4
- package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
- package/dist/mdx/react/pagination/examples/ShowAdditionalDetails.tsx +0 -52
|
@@ -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
|
+
};
|
|
@@ -51,7 +51,7 @@ when you need to place a Primary Button on a dark or colorful background such as
|
|
|
51
51
|
|
|
52
52
|
#### Props
|
|
53
53
|
|
|
54
|
-
Undocumented props are spread to the underlying
|
|
54
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
55
55
|
|
|
56
56
|
<ArgsTable of={PrimaryButton} />
|
|
57
57
|
|
|
@@ -73,7 +73,7 @@ a dark or colorful background such as `blueberry400`.
|
|
|
73
73
|
|
|
74
74
|
#### Props
|
|
75
75
|
|
|
76
|
-
Undocumented props are spread to the underlying
|
|
76
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
77
77
|
|
|
78
78
|
<ArgsTable of={SecondaryButton} />
|
|
79
79
|
|
|
@@ -97,7 +97,7 @@ a dark or colorful background such as `blueberry400`.
|
|
|
97
97
|
|
|
98
98
|
#### Props
|
|
99
99
|
|
|
100
|
-
Undocumented props are spread to the underlying
|
|
100
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
101
101
|
|
|
102
102
|
<ArgsTable of={TertiaryButton} />
|
|
103
103
|
|
|
@@ -111,16 +111,16 @@ before deleting.
|
|
|
111
111
|
|
|
112
112
|
#### Props
|
|
113
113
|
|
|
114
|
-
Undocumented props are spread to the underlying
|
|
114
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
115
115
|
|
|
116
116
|
<ArgsTable of={DeleteButton} />
|
|
117
117
|
|
|
118
118
|
### Accessible Use of the `as` Prop
|
|
119
119
|
|
|
120
120
|
Like many of our components, Buttons accept an `as` prop, which lets you change the underlying
|
|
121
|
-
semantic element - usually an
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
semantic element - usually an `<a>`, or a `<button>`. This should be done with caution to ensure the
|
|
122
|
+
best accessibility. Generally, `<button>` elements should be used for actions, and `<a>` elements
|
|
123
|
+
should be used for navigation.
|
|
124
124
|
|
|
125
125
|
## Specifications
|
|
126
126
|
|
|
@@ -98,6 +98,6 @@ The `toggle` prop can be used to make icon buttons toggleable.
|
|
|
98
98
|
|
|
99
99
|
## Props
|
|
100
100
|
|
|
101
|
-
Undocumented props are spread to the underlying
|
|
101
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
102
102
|
|
|
103
103
|
<ArgsTable of={IconButton} />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {LoadingAnimation} from '@workday/canvas-kit-react/loading-animation';
|
|
2
2
|
|
|
3
3
|
import Basic from './examples/Basic';
|
|
4
|
+
import RTL from './examples/RTL';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
# Canvas Kit Loading Animation
|
|
@@ -22,6 +23,10 @@ yarn add @workday/canvas-kit-react
|
|
|
22
23
|
|
|
23
24
|
<ExampleCodeBlock code={Basic} />
|
|
24
25
|
|
|
26
|
+
### Right-to-Left (RTL)
|
|
27
|
+
|
|
28
|
+
<ExampleCodeBlock code={RTL} />
|
|
29
|
+
|
|
25
30
|
## Props
|
|
26
31
|
|
|
27
32
|
Loading Animation does not have any documented props. Undocumented props are spread to its outermost
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {LoadingAnimation} from '@workday/canvas-kit-react/loading-animation';
|
|
3
|
+
import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
const theme = {
|
|
7
|
+
canvas: {
|
|
8
|
+
direction: ContentDirection.RTL,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
return (
|
|
12
|
+
<CanvasProvider theme={theme}>
|
|
13
|
+
<LoadingAnimation />
|
|
14
|
+
</CanvasProvider>
|
|
15
|
+
);
|
|
16
|
+
};
|