@workday/canvas-kit-docs 9.0.0-alpha.382-next.2 → 9.0.0-alpha.385-next.4
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/es6/lib/docs.js +782 -0
- package/dist/mdx/9.0-UPGRADE-GUIDE.mdx +263 -99
- package/dist/mdx/preview-react/table/Table.mdx +60 -0
- package/dist/mdx/preview-react/table/examples/Basic.tsx +36 -0
- package/dist/mdx/preview-react/table/examples/BasicWithHeading.tsx +34 -0
- package/dist/mdx/preview-react/table/examples/FixedColumn.tsx +127 -0
- package/dist/mdx/preview-react/table/examples/TableWithContainer.tsx +48 -0
- package/package.json +5 -5
|
@@ -5,20 +5,28 @@ This guide contains an overview of the changes in Canvas Kit v9. Please
|
|
|
5
5
|
any questions.
|
|
6
6
|
|
|
7
7
|
- [Codemod](#codemod)
|
|
8
|
-
- [
|
|
8
|
+
- [New Components](#new-components)
|
|
9
|
+
- [Table](#table)
|
|
10
|
+
- [Removals](#Removals)
|
|
9
11
|
- [Drawer](#drawer)
|
|
10
12
|
- [Layout and Column](#layout-and-column)
|
|
11
|
-
- [Stack](#stack-hstack-vstack)
|
|
12
|
-
- [Component Updates](#component-updates)
|
|
13
|
-
- [Buttons](#buttons) - [Toast](#toast)
|
|
14
|
-
- [Utility Updates](#utility-updates)
|
|
13
|
+
- [Stack, HStack, and VStack](#stack-hstack-and-vstack)
|
|
15
14
|
- [focusRing](#focusring)
|
|
16
|
-
- [
|
|
17
|
-
|
|
18
|
-
- [
|
|
19
|
-
- [useThemeRTL](#useThemeRTL)
|
|
15
|
+
- [useCanvasTheme and getCanvasTheme](#usecanvastheme-and-getcanvastheme)
|
|
16
|
+
- [Deprecations](#deprecations)
|
|
17
|
+
- [useThemeRTL](#usethemertl)
|
|
20
18
|
- [Token Updates](#token-updates)
|
|
21
19
|
- [Depth](#depth)
|
|
20
|
+
- [Component Updates](#component-updates)
|
|
21
|
+
- [Button](#button)
|
|
22
|
+
- [Toast](#toast)
|
|
23
|
+
- [Utility Updates](#utility-updates)
|
|
24
|
+
- [useTheme and getTheme](#usetheme-and-gettheme)
|
|
25
|
+
- [useThemedRing](#usethemedring)
|
|
26
|
+
- [Glossary](#glossary)
|
|
27
|
+
- [Main](#main)
|
|
28
|
+
- [Preview](#preview)
|
|
29
|
+
- [Labs](#labs)
|
|
22
30
|
|
|
23
31
|
## Codemod
|
|
24
32
|
|
|
@@ -51,157 +59,313 @@ handled by the codemod are marked with 🤖 in the Upgrade Guide.**
|
|
|
51
59
|
the changes from the codemod as a single isolated commit (separate from other changes) so you can
|
|
52
60
|
roll back more easily if necessary.
|
|
53
61
|
|
|
54
|
-
##
|
|
62
|
+
## New Components
|
|
55
63
|
|
|
56
|
-
###
|
|
64
|
+
### Table
|
|
57
65
|
|
|
58
|
-
|
|
66
|
+
We've introduced a new `Table`
|
|
67
|
+
[compound component](/getting-started/for-developers/resources/compound-components/) to the Preview
|
|
68
|
+
package. `Table` is a compound component that is used to present information in a two-dimensional
|
|
69
|
+
[table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) comprised of rows and
|
|
70
|
+
columns of cells containing data.
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
```tsx
|
|
73
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
74
|
+
|
|
75
|
+
export default function App() {
|
|
76
|
+
return (
|
|
77
|
+
<Table>
|
|
78
|
+
<Table.Caption>Table Caption</Table.Caption>
|
|
79
|
+
<Table.Head>
|
|
80
|
+
<Table.Row>
|
|
81
|
+
<Table.Header>Table Header</Table.Header>
|
|
82
|
+
<Table.Header>Table Header</Table.Header>
|
|
83
|
+
</Table.Row>
|
|
84
|
+
</Table.Head>
|
|
85
|
+
<Table.Body>
|
|
86
|
+
<Table.Row>
|
|
87
|
+
<Table.Header>Table Header</Table.Header>
|
|
88
|
+
<Table.Header>Table Header</Table.Header>
|
|
89
|
+
</Table.Row>
|
|
90
|
+
<Table.Divider />
|
|
91
|
+
<Table.Row>
|
|
92
|
+
<Table.Header>Table Header</Table.Header>
|
|
93
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
94
|
+
</Table.Row>
|
|
95
|
+
<Table.Divider />
|
|
96
|
+
<Table.Row>
|
|
97
|
+
<Table.Header>Table Header</Table.Header>
|
|
98
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
99
|
+
</Table.Row>
|
|
100
|
+
</Table.Body>
|
|
101
|
+
<Table.Divider />
|
|
102
|
+
<Table.Footer>
|
|
103
|
+
<Table.Row>
|
|
104
|
+
<Table.Header>Table Header</Table.Header>
|
|
105
|
+
<Table.Cell>Table Data Cell</Table.Cell>
|
|
106
|
+
</Table.Row>
|
|
107
|
+
</Table.Footer>
|
|
108
|
+
</Table>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
63
112
|
|
|
64
|
-
|
|
65
|
-
console warning.
|
|
113
|
+
## Removals
|
|
66
114
|
|
|
67
|
-
|
|
115
|
+
Removals are deletions from our codebase and you can no longer consume this component. We've either
|
|
116
|
+
promoted or replaced a component or utility.
|
|
68
117
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
[
|
|
72
|
-
|
|
118
|
+
### Drawer
|
|
119
|
+
|
|
120
|
+
**PR:** [#1970](https://github.com/Workday/canvas-kit/pull/1970)
|
|
121
|
+
|
|
122
|
+
We've removed the `Drawer` component (for reference, see the
|
|
123
|
+
[`Drawer`](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/labs-drawer--basic) from v8). Please
|
|
124
|
+
use the [`SidePanel`](/components/containers/side-panel/) in [Preview](#preview) instead.
|
|
125
|
+
|
|
126
|
+
> **Note:** The `SidePanel` in Main will eventually be replaced with the `SidePanel` in Preview. We
|
|
127
|
+
> recommend you use the `SidePanel` in Preview until then.
|
|
73
128
|
|
|
74
129
|
---
|
|
75
130
|
|
|
76
|
-
###
|
|
131
|
+
### Layout and Column
|
|
132
|
+
|
|
133
|
+
**PR:** [#2018](https://github.com/Workday/canvas-kit/pull/2018)
|
|
77
134
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
135
|
+
We've removed the `Layout` and `Column` components (for reference, see
|
|
136
|
+
[`Column and Layout`](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-containers-column-and-layout--12-column-layout)
|
|
137
|
+
from v8). Please use [`Grid`](/components/layout/grid/) instead. While `Grid` is not a 1:1
|
|
138
|
+
replacement for `Layout` and `Column`, it can be used to generate the same types of layouts and
|
|
139
|
+
offers a more robust and flexible layout solution.
|
|
81
140
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
[Side Panel](https://workday.github.io/canvas-kit/?path=/story/preview-side-panel--basic). Be Aware
|
|
85
|
-
that `SidePanel` from the Main package is planned to be replaced by the one from Preview. We suggest
|
|
86
|
-
you use the Preview version of `SidePanel` until the one in Main is replaced with it.
|
|
141
|
+
Please refer to our [Layout examples](/examples/layout/) for examples of how to implement common
|
|
142
|
+
layouts using `Grid`.
|
|
87
143
|
|
|
88
144
|
---
|
|
89
145
|
|
|
90
|
-
###
|
|
146
|
+
### Stack, HStack and VStack
|
|
147
|
+
|
|
148
|
+
**PR:** [#2012](https://github.com/Workday/canvas-kit/pull/2012)
|
|
149
|
+
|
|
150
|
+
We've removed the `Stack`, `HStack`, and `VStack` components (for reference, see
|
|
151
|
+
[`Stack`](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-layout-stack--basic-stack)
|
|
152
|
+
from v8). Please use [`Flex`](/components/layout/flex/) instead. `Flex` supports the same consistent
|
|
153
|
+
spacing between its elements via the `gap` prop (analogous to the `spacing` prop from `Stack`).
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
// v8
|
|
157
|
+
<Stack spacing="s">
|
|
158
|
+
...
|
|
159
|
+
</Stack>
|
|
160
|
+
|
|
161
|
+
// v9
|
|
162
|
+
<Flex gap="s">
|
|
163
|
+
...
|
|
164
|
+
</Flex>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The orientation of `VStack` elements can be replicated with `Flex` using `flexDirection`.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
// v8
|
|
171
|
+
<VStack>
|
|
172
|
+
...
|
|
173
|
+
</VStack>
|
|
174
|
+
|
|
175
|
+
// v9
|
|
176
|
+
<Flex flexDirection="column">
|
|
177
|
+
...
|
|
178
|
+
</Flex>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The `StackProps`, `HStackProps`, `VStackProps`, and `StackStyleProps` types have been removed as
|
|
182
|
+
well. All references to these types in your custom components will need to be replaced with
|
|
183
|
+
`FlexProps`.
|
|
184
|
+
|
|
185
|
+
🤖 The codemod will handle all of the changes above for you automatically.
|
|
186
|
+
|
|
187
|
+
> **Note:** If you were consuming `StackProps` previously for a custom component, be sure to change
|
|
188
|
+
> all references to the old `spacing` prop from `StackProps` to the `gap` prop from `FlexProps`.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### focusRing
|
|
193
|
+
|
|
194
|
+
**PR:** [#2034](https://github.com/Workday/canvas-kit/pull/2034)
|
|
195
|
+
|
|
196
|
+
We've removed memoization from `focusRing`. The `memoize` argument passed to `focusRing` is no
|
|
197
|
+
longer valid, and we've removed `memoizedFocusRing`. We were unable to find any examples of
|
|
198
|
+
`memoize` or `memoizedFocusRing` in use by our consumers.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### useCanvasTheme and getCanvasTheme
|
|
91
203
|
|
|
92
|
-
|
|
93
|
-
available in Canvas Kit. Please consider using
|
|
94
|
-
[`Grid`](https://workday.github.io/canvas-kit/?path=/docs/components-containers-grid--basic)
|
|
95
|
-
instead. While the `Grid` component is not a 1:1 replacement for `Layout`, it can be used in the
|
|
96
|
-
same way and offers several benefits over the deprecated components as a more robust and flexible
|
|
97
|
-
layout solution.
|
|
204
|
+
**PR:** [#2120](https://github.com/Workday/canvas-kit/pull/2120)
|
|
98
205
|
|
|
99
|
-
Please
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
206
|
+
We've removed `useCanvasTheme` and `getCanvasTheme`. Please use `useTheme` and `getTheme` instead.
|
|
207
|
+
|
|
208
|
+
## Deprecations
|
|
209
|
+
|
|
210
|
+
We add the [@deprecated](https://jsdoc.app/tags-deprecated.html) from JSDoc to code that we plan to
|
|
211
|
+
deprecate in the near future. Al though you can still consume this code, we want consumers to move
|
|
212
|
+
to a utility or component that is more stable.
|
|
213
|
+
|
|
214
|
+
### useThemeRTL
|
|
215
|
+
|
|
216
|
+
**PR:** [#2119](https://github.com/Workday/canvas-kit/pull/2119)
|
|
217
|
+
|
|
218
|
+
We've deprecated `useThemeRTL` from [Labs](#labs). Although you may still use this utility, we
|
|
219
|
+
recommend using
|
|
220
|
+
[CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties)
|
|
221
|
+
instead.
|
|
104
222
|
|
|
105
223
|
---
|
|
106
224
|
|
|
107
|
-
|
|
225
|
+
## Token Updates
|
|
108
226
|
|
|
109
|
-
|
|
110
|
-
to those components (`StackProps`, `HStackProps`, `VStackProps`, `StackStyleProps`). We recommend
|
|
111
|
-
using the `Flex` component and to replace the `spacing` prop with the `gap` prop. You can also run
|
|
112
|
-
`npx @workday/canvas-kit-codemod v9 [path]`.
|
|
227
|
+
### Depth
|
|
113
228
|
|
|
114
|
-
|
|
115
|
-
|
|
229
|
+
**PR:** [#2091](https://github.com/Workday/canvas-kit/pull/2091)
|
|
230
|
+
|
|
231
|
+
In v7, we released an update to our depth tokens that was too bold and harsh for web applications.
|
|
232
|
+
We've modified the depth token styles to be more subtle and improve visual design. This change
|
|
233
|
+
affects all components which use depth tokens including `Card`, `Toast`, `Dialog`, `Popup`, `Modal`,
|
|
234
|
+
and `Menu`. We have not changed which depth values each component references (i.e., `Card` remains
|
|
235
|
+
at `depth[1]`).
|
|
116
236
|
|
|
117
237
|
## Component Updates
|
|
118
238
|
|
|
119
|
-
###
|
|
239
|
+
### Button
|
|
240
|
+
|
|
241
|
+
**PR:** [#1978](https://github.com/Workday/canvas-kit/pull/1978)
|
|
242
|
+
|
|
243
|
+
We've changed the default `type` attribute for all buttons to `type="button"`. Previously, the
|
|
244
|
+
`type` attribute was not being set which resulted in the buttons
|
|
245
|
+
[defaulting to `type="submit"`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes).
|
|
246
|
+
|
|
247
|
+
This affects all buttons which extend `BaseButton`:
|
|
120
248
|
|
|
121
|
-
|
|
122
|
-
|
|
249
|
+
- `PrimaryButton`
|
|
250
|
+
- `SecondaryButton`
|
|
251
|
+
- `TertiaryButton`
|
|
252
|
+
- `DeleteButton`
|
|
253
|
+
- `ToolbarDropdownButton` and `ToolbarIconButton`
|
|
254
|
+
- `Pill` and `Pill.IconButton`
|
|
255
|
+
- `SegmentedControl.Button` (Main)
|
|
256
|
+
- `SegmentedControl.Item` (Preview)
|
|
257
|
+
- `Pagination.PageButton`
|
|
123
258
|
|
|
124
|
-
|
|
125
|
-
click the first `submit` `button` which in some cases is not a `submit` button.
|
|
259
|
+
Any buttons which extend any of the above are affected as well.
|
|
126
260
|
|
|
127
|
-
|
|
128
|
-
|
|
261
|
+
This resolves an [issue](https://github.com/Workday/canvas-kit/issues/1938) where clicking certain
|
|
262
|
+
buttons within a `form` element would unexpectedly submit the form. Additionally, the default action
|
|
263
|
+
of many form controls such as `input` and `textarea` is to click the first submit button; this led
|
|
264
|
+
to issues if the first submit button in the form was not intended to be a submit button (a common
|
|
265
|
+
mistake when buttons default to `type="submit"`).
|
|
129
266
|
|
|
130
|
-
This change
|
|
131
|
-
|
|
267
|
+
This is a breaking change if you expected a button to submit by default, though we do not anticipate
|
|
268
|
+
this to be the case for most developers. If you _do_ intend for a button to act as a submit button
|
|
269
|
+
within a form, add `type="submit"` to the button.
|
|
132
270
|
|
|
133
|
-
|
|
134
|
-
`type="submit"`.
|
|
271
|
+
---
|
|
135
272
|
|
|
136
273
|
### Toast
|
|
137
274
|
|
|
138
|
-
|
|
139
|
-
|
|
275
|
+
**PR:** [#2044](https://github.com/Workday/canvas-kit/pull/2044)
|
|
276
|
+
|
|
277
|
+
We've promoted `Toast` from [Labs](#labs) to [Main](#main). It replaces the `Toast` that was
|
|
278
|
+
previously in [Main](#main) (for reference, see
|
|
279
|
+
[`Toast`](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-popups-toast--error) in
|
|
280
|
+
[Main](#main) from v8).
|
|
140
281
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
282
|
+
`Toast` is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
283
|
+
which provides a flexible API and access to its internals via its subcomponents. It supports a new
|
|
284
|
+
`mode` prop which applies the proper accessibility features to the component based on the desired
|
|
285
|
+
mode: `status`, `alert`, or `dialog`.
|
|
145
286
|
|
|
146
287
|
```tsx
|
|
147
288
|
// v8
|
|
148
|
-
<Toast actionText="View more details" onClose={handleClose}>
|
|
289
|
+
<Toast actionText="View more details" onActionClick={handleActionClick} onClose={handleClose}>
|
|
290
|
+
Your workbook was successfully processed.
|
|
291
|
+
</Toast>
|
|
149
292
|
|
|
150
293
|
// v9
|
|
151
294
|
<Toast mode="dialog">
|
|
152
295
|
<Toast.Icon icon={checkIcon} color={colors.greenApple400} />
|
|
153
296
|
<Toast.Body>
|
|
154
297
|
<Toast.Message>Your workbook was successfully processed.</Toast.Message>
|
|
155
|
-
<Toast.Link
|
|
298
|
+
<Toast.Link onClick={handleActionClick}>View more details</Toast.Link>
|
|
156
299
|
</Toast.Body>
|
|
157
300
|
<Toast.CloseIcon aria-label="Close" onClick={handleClose} />
|
|
158
301
|
</Toast>
|
|
159
302
|
```
|
|
160
303
|
|
|
161
|
-
🤖 The codemod will
|
|
162
|
-
the
|
|
304
|
+
🤖 The codemod will rewrite your usages of the previous `Toast` in [Main](#main) to use the compound
|
|
305
|
+
component API of the new `Toast` in [Main](#main). `mode` will be set to `dialog` if the `Toast`
|
|
306
|
+
previously used `actionText` or `onActionClick`. The codemod will also update imports from the
|
|
307
|
+
[Labs](#labs) `Toast` to instead import from [Main](#main).
|
|
163
308
|
|
|
164
|
-
> **Note
|
|
165
|
-
>
|
|
309
|
+
> **Note:** You will manually need to set `mode` to `alert` if your `Toast` conveys urgent and
|
|
310
|
+
> important information such as an error.
|
|
166
311
|
|
|
167
312
|
## Utility Updates
|
|
168
313
|
|
|
169
|
-
### focusRing
|
|
170
|
-
|
|
171
|
-
We're removing memoization from focus ring. The `memoize` argument passed to `focusRing` is no
|
|
172
|
-
longer valid and we've removed the exported `memoizedFocusRing`. There is no codemod for this
|
|
173
|
-
change. We couldn't find any example of `memoize` or `memoizedFocusRing` being used.
|
|
174
|
-
|
|
175
314
|
### useTheme and getTheme
|
|
176
315
|
|
|
177
|
-
|
|
178
|
-
component. Also, `getTheme` method has been added to access a theme from `styled` or class
|
|
179
|
-
components instead of `useTheme`.
|
|
180
|
-
|
|
181
|
-
### useCanvasTheme and getCanvasTheme
|
|
316
|
+
**PR:** [#2120](https://github.com/Workday/canvas-kit/pull/2120)
|
|
182
317
|
|
|
183
|
-
|
|
184
|
-
|
|
318
|
+
We've added error handling to `useTheme` if it's been used outside a functional component. We've
|
|
319
|
+
also added `getTheme` to provide access to a theme from `styled` or class components instead of
|
|
320
|
+
`useTheme`.
|
|
185
321
|
|
|
186
322
|
### useThemedRing
|
|
187
323
|
|
|
188
|
-
|
|
189
|
-
|
|
324
|
+
**PR:** [#2119](https://github.com/Workday/canvas-kit/pull/2119)
|
|
325
|
+
|
|
326
|
+
We've promoted `useThemedRing` from [Labs](#labs) to [Main](#main). `useThemedRing` allows you to
|
|
327
|
+
theme focus rings.
|
|
190
328
|
|
|
191
329
|
🤖 The codemod will update the import for this utility.
|
|
192
330
|
|
|
193
|
-
|
|
331
|
+
## Glossary
|
|
194
332
|
|
|
195
|
-
|
|
196
|
-
still use this utility, we encourage consumers to use
|
|
197
|
-
[CSS logical properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties).
|
|
333
|
+
### Main
|
|
198
334
|
|
|
199
|
-
|
|
335
|
+
Our Main package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-react` has
|
|
336
|
+
undergone a full design and a11y review and is approved for use in product.
|
|
200
337
|
|
|
201
|
-
|
|
338
|
+
Breaking changes to code in Main will only occur during major version updates and will always be
|
|
339
|
+
communicated in advance and accompanied by migration strategies.
|
|
202
340
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
at
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
### Preview
|
|
344
|
+
|
|
345
|
+
Our Preview package of Canvas Kit tokens, components, and utilities at
|
|
346
|
+
`@workday/canvas-kit-preview-react` has undergone a full design and a11y review and is approved for
|
|
347
|
+
use in product, but may not be up to the high code standards upheld in the [Main](#main) package.
|
|
348
|
+
Preview is analagous to code in beta.
|
|
349
|
+
|
|
350
|
+
Breaking changes are unlikely, but possible, and can be deployed to Preview at any time without
|
|
351
|
+
triggering a major version update, though such changes will be communicated in advance and
|
|
352
|
+
accompanied by migration strategies.
|
|
353
|
+
|
|
354
|
+
Generally speaking, our goal is to eventually promote code from Preview to [Main](#main).
|
|
355
|
+
Occasionally, a component with the same name will exist in both [Main](#main) and Preview (for
|
|
356
|
+
example, see Segmented Control in [Preview](/components/buttons/segmented-control/) and
|
|
357
|
+
[Main](https://d2krrudi3mmzzw.cloudfront.net/v8/?path=/docs/components-buttons-segmented-control--basic)).
|
|
358
|
+
In these cases, Preview serves as a staging ground for an improved version of the component with a
|
|
359
|
+
different API. The component in [Main](#main) will eventually be replaced with the one in Preview.
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
### Labs
|
|
364
|
+
|
|
365
|
+
Our Labs package of Canvas Kit tokens, components, and utilities at `@workday/canvas-kit-labs-react`
|
|
366
|
+
has **not** undergone a full design and a11y review. Labs serves as an incubator space for new and
|
|
367
|
+
experimental code and is analagous to code in alpha.
|
|
368
|
+
|
|
369
|
+
Breaking changes can be deployed to Labs at any time without triggering a major version update and
|
|
370
|
+
may not be subject to the same rigor in communcation and migration strategies reserved for breaking
|
|
371
|
+
changes in [Preview](#preview) and [Main](#main).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {SymbolDoc, Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
3
|
+
// examples
|
|
4
|
+
import Basic from './examples/Basic';
|
|
5
|
+
import BasicWithHeading from './examples/BasicWithHeading';
|
|
6
|
+
import FixedColumn from './examples/FixedColumn';
|
|
7
|
+
import TableWithContainer from './examples/TableWithContainer';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Canvas Kit Table
|
|
11
|
+
|
|
12
|
+
`Table` is a simple styled compound component that renders a
|
|
13
|
+
[table](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table) element. It is used to
|
|
14
|
+
present information in a two-dimensional table comprised of rows and columns of cells containing
|
|
15
|
+
data.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
yarn add @workday/canvas-kit-preview-react
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Basic Example
|
|
26
|
+
|
|
27
|
+
Users may not want to use a `caption` so they can import
|
|
28
|
+
[Heading](/docs/components-text-heading--basic) or [Text](/docs/components-text-text--basic)
|
|
29
|
+
instead. This will give the user more flexibility around the customization of the title/heading of
|
|
30
|
+
their table.
|
|
31
|
+
|
|
32
|
+
<ExampleCodeBlock code={BasicWithHeading} />
|
|
33
|
+
|
|
34
|
+
### Example with Container
|
|
35
|
+
|
|
36
|
+
Users may want to have some padding around the `table` and have inset dividers for their rows. This
|
|
37
|
+
showcases how a user can achieve this with creating a styled component to wrap the `table`.
|
|
38
|
+
|
|
39
|
+
<ExampleCodeBlock code={TableWithContainer} />
|
|
40
|
+
|
|
41
|
+
### Example with Caption
|
|
42
|
+
|
|
43
|
+
We built a simple table that includes a `caption` without a Heading. A `caption` is not required but
|
|
44
|
+
it is good for
|
|
45
|
+
[accessibility](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table#accessibility_concerns)
|
|
46
|
+
purposes.
|
|
47
|
+
|
|
48
|
+
<ExampleCodeBlock code={Basic} />
|
|
49
|
+
|
|
50
|
+
### Fixed Column with TableContainer
|
|
51
|
+
|
|
52
|
+
Users may want to have some padding surrounding their table and have a fixed column. They can use
|
|
53
|
+
the `TableContainer` to wrap the `Table` component and some styles to make it so that the left
|
|
54
|
+
column is fixed.
|
|
55
|
+
|
|
56
|
+
<ExampleCodeBlock code={FixedColumn} />
|
|
57
|
+
|
|
58
|
+
## Component API
|
|
59
|
+
|
|
60
|
+
<SymbolDoc name="Table" fileName="/preview-react/" />
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
4
|
+
|
|
5
|
+
export default () => {
|
|
6
|
+
return (
|
|
7
|
+
<Table>
|
|
8
|
+
<Table.Caption>Coffee Drinks and Sizes</Table.Caption>
|
|
9
|
+
<Table.Head>
|
|
10
|
+
<Table.Row>
|
|
11
|
+
<Table.Header backgroundColor="soap100">Drink</Table.Header>
|
|
12
|
+
<Table.Header backgroundColor="soap100">Size</Table.Header>
|
|
13
|
+
</Table.Row>
|
|
14
|
+
</Table.Head>
|
|
15
|
+
<Table.Body>
|
|
16
|
+
<Table.Row>
|
|
17
|
+
<Table.Cell>Espresso</Table.Cell>
|
|
18
|
+
<Table.Cell>1 oz</Table.Cell>
|
|
19
|
+
</Table.Row>
|
|
20
|
+
<Table.Row>
|
|
21
|
+
<Table.Cell>Macchiato</Table.Cell>
|
|
22
|
+
<Table.Cell>2 oz Espresso</Table.Cell>
|
|
23
|
+
</Table.Row>
|
|
24
|
+
<Table.Row>
|
|
25
|
+
<Table.Cell>Cortado</Table.Cell>
|
|
26
|
+
<Table.Cell>2 oz Espresso, 1 oz Foamed Milk</Table.Cell>
|
|
27
|
+
</Table.Row>
|
|
28
|
+
<Table.Row></Table.Row>
|
|
29
|
+
<Table.Row>
|
|
30
|
+
<Table.Cell>Cappuccino</Table.Cell>
|
|
31
|
+
<Table.Cell>2 oz Espresso, 2 oz Foamed Milk, 2 oz Steamed Milk</Table.Cell>
|
|
32
|
+
</Table.Row>
|
|
33
|
+
</Table.Body>
|
|
34
|
+
</Table>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Table} from '@workday/canvas-kit-preview-react/table';
|
|
4
|
+
import {Heading} from '@workday/canvas-kit-react/text';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<Heading size="small">Pizza Toppings</Heading>
|
|
10
|
+
<Table>
|
|
11
|
+
<Table.Head>
|
|
12
|
+
<Table.Row>
|
|
13
|
+
<Table.Header backgroundColor="soap100">Toppings</Table.Header>
|
|
14
|
+
<Table.Header backgroundColor="soap100">Amount</Table.Header>
|
|
15
|
+
</Table.Row>
|
|
16
|
+
</Table.Head>
|
|
17
|
+
<Table.Body>
|
|
18
|
+
<Table.Row>
|
|
19
|
+
<Table.Cell>Pepperoni</Table.Cell>
|
|
20
|
+
<Table.Cell>2.5 oz</Table.Cell>
|
|
21
|
+
</Table.Row>
|
|
22
|
+
<Table.Row>
|
|
23
|
+
<Table.Cell>Mozzarella</Table.Cell>
|
|
24
|
+
<Table.Cell>5 oz</Table.Cell>
|
|
25
|
+
</Table.Row>
|
|
26
|
+
<Table.Row>
|
|
27
|
+
<Table.Cell>Basil</Table.Cell>
|
|
28
|
+
<Table.Cell>10 Leaves</Table.Cell>
|
|
29
|
+
</Table.Row>
|
|
30
|
+
</Table.Body>
|
|
31
|
+
</Table>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
34
|
+
};
|