@workday/canvas-kit-docs 7.0.0-alpha.95-next.21 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/lib/specs.js +70 -0
- package/dist/es6/lib/specs.js +70 -0
- package/dist/mdx/{4.0-MIGRATION-GUIDE.mdx → 4.0-UPGRADE-GUIDE.mdx} +1 -1
- package/dist/mdx/{5.0-MIGRATION-GUIDE.mdx → 5.0-UPGRADE-GUIDE.mdx} +3 -3
- package/dist/mdx/{6.0-MIGRATION-GUIDE.mdx → 6.0-UPGRADE-GUIDE.mdx} +4 -4
- package/dist/mdx/{7.0-MIGRATION-GUIDE.mdx → 7.0-UPGRADE-GUIDE.mdx} +128 -12
- package/dist/mdx/TESTING.mdx +1 -1
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +2 -2
- package/dist/mdx/preview-react/pill/Pill.mdx +241 -0
- package/dist/mdx/preview-react/pill/examples/Basic.tsx +18 -0
- package/dist/mdx/preview-react/pill/examples/WithAvatar.tsx +21 -0
- package/dist/mdx/preview-react/pill/examples/WithCount.tsx +9 -0
- package/dist/mdx/preview-react/pill/examples/WithList.tsx +31 -0
- package/dist/mdx/preview-react/pill/examples/WithReadOnly.tsx +15 -0
- package/dist/mdx/preview-react/pill/examples/WithRemovable.tsx +25 -0
- package/dist/mdx/preview-react/pill/examples/test-avatar.png +0 -0
- package/dist/mdx/react/action-bar/ActionBar.mdx +123 -10
- package/dist/mdx/react/action-bar/examples/Basic.tsx +8 -7
- package/dist/mdx/react/action-bar/examples/Icons.tsx +18 -0
- package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +59 -0
- package/dist/mdx/react/button/button/Hyperlink.mdx +72 -0
- package/dist/mdx/react/button/button/examples/ExternalHyperlink.tsx +7 -0
- package/dist/mdx/react/button/button/examples/ExternalHyperlinkInverse.tsx +12 -0
- package/dist/mdx/react/button/button/examples/Hyperlink.tsx +5 -0
- package/dist/mdx/react/button/button/examples/HyperlinkInverse.tsx +12 -0
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +0 -2
- package/dist/mdx/react/layout/Stack.mdx +1 -1
- package/dist/mdx/react/popup/examples/FocusRedirect.tsx +2 -1
- package/dist/mdx/react/tabs/Tabs.mdx +3 -3
- package/package.json +3 -3
|
@@ -1299,6 +1299,46 @@ module.exports = {specifications: [
|
|
|
1299
1299
|
}
|
|
1300
1300
|
]
|
|
1301
1301
|
},
|
|
1302
|
+
{
|
|
1303
|
+
"type": "file",
|
|
1304
|
+
"name": "Hyperlink.spec.ts",
|
|
1305
|
+
"children": [
|
|
1306
|
+
{
|
|
1307
|
+
"type": "describe",
|
|
1308
|
+
"name": "Button",
|
|
1309
|
+
"children": [
|
|
1310
|
+
{
|
|
1311
|
+
"type": "describe",
|
|
1312
|
+
"name": "given internal hyperlinks are rendered",
|
|
1313
|
+
"children": [
|
|
1314
|
+
{
|
|
1315
|
+
"type": "it",
|
|
1316
|
+
"name": "should not have any axe errors"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"type": "it",
|
|
1320
|
+
"name": "should render the correct text"
|
|
1321
|
+
}
|
|
1322
|
+
]
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
"type": "describe",
|
|
1326
|
+
"name": "given external hyperlinks are rendered",
|
|
1327
|
+
"children": [
|
|
1328
|
+
{
|
|
1329
|
+
"type": "it",
|
|
1330
|
+
"name": "should not have any axe errors"
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
"type": "it",
|
|
1334
|
+
"name": "should render the correct text"
|
|
1335
|
+
}
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
]
|
|
1341
|
+
},
|
|
1302
1342
|
{
|
|
1303
1343
|
"type": "file",
|
|
1304
1344
|
"name": "Menu.spec.ts",
|
|
@@ -2635,6 +2675,36 @@ module.exports = {specifications: [
|
|
|
2635
2675
|
]
|
|
2636
2676
|
}
|
|
2637
2677
|
]
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
"type": "describe",
|
|
2681
|
+
"name": "given the [Components/Popups/Popup/React, FocusRedirect] example is rendered",
|
|
2682
|
+
"children": [
|
|
2683
|
+
{
|
|
2684
|
+
"type": "describe",
|
|
2685
|
+
"name": "when the \"Delete Item\" button is clicked",
|
|
2686
|
+
"children": [
|
|
2687
|
+
{
|
|
2688
|
+
"type": "it",
|
|
2689
|
+
"name": "should show the popup"
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
"type": "describe",
|
|
2693
|
+
"name": "when the \"Delete\" button has focus and the tab key is pressed",
|
|
2694
|
+
"children": [
|
|
2695
|
+
{
|
|
2696
|
+
"type": "it",
|
|
2697
|
+
"name": "should hide the popup"
|
|
2698
|
+
},
|
|
2699
|
+
{
|
|
2700
|
+
"type": "it",
|
|
2701
|
+
"name": "should redirect focus to the \"Next Focusable Button\" button"
|
|
2702
|
+
}
|
|
2703
|
+
]
|
|
2704
|
+
}
|
|
2705
|
+
]
|
|
2706
|
+
}
|
|
2707
|
+
]
|
|
2638
2708
|
}
|
|
2639
2709
|
]
|
|
2640
2710
|
}
|
package/dist/es6/lib/specs.js
CHANGED
|
@@ -1299,6 +1299,46 @@ module.exports = {specifications: [
|
|
|
1299
1299
|
}
|
|
1300
1300
|
]
|
|
1301
1301
|
},
|
|
1302
|
+
{
|
|
1303
|
+
"type": "file",
|
|
1304
|
+
"name": "Hyperlink.spec.ts",
|
|
1305
|
+
"children": [
|
|
1306
|
+
{
|
|
1307
|
+
"type": "describe",
|
|
1308
|
+
"name": "Button",
|
|
1309
|
+
"children": [
|
|
1310
|
+
{
|
|
1311
|
+
"type": "describe",
|
|
1312
|
+
"name": "given internal hyperlinks are rendered",
|
|
1313
|
+
"children": [
|
|
1314
|
+
{
|
|
1315
|
+
"type": "it",
|
|
1316
|
+
"name": "should not have any axe errors"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"type": "it",
|
|
1320
|
+
"name": "should render the correct text"
|
|
1321
|
+
}
|
|
1322
|
+
]
|
|
1323
|
+
},
|
|
1324
|
+
{
|
|
1325
|
+
"type": "describe",
|
|
1326
|
+
"name": "given external hyperlinks are rendered",
|
|
1327
|
+
"children": [
|
|
1328
|
+
{
|
|
1329
|
+
"type": "it",
|
|
1330
|
+
"name": "should not have any axe errors"
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
"type": "it",
|
|
1334
|
+
"name": "should render the correct text"
|
|
1335
|
+
}
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
]
|
|
1339
|
+
}
|
|
1340
|
+
]
|
|
1341
|
+
},
|
|
1302
1342
|
{
|
|
1303
1343
|
"type": "file",
|
|
1304
1344
|
"name": "Menu.spec.ts",
|
|
@@ -2635,6 +2675,36 @@ module.exports = {specifications: [
|
|
|
2635
2675
|
]
|
|
2636
2676
|
}
|
|
2637
2677
|
]
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
"type": "describe",
|
|
2681
|
+
"name": "given the [Components/Popups/Popup/React, FocusRedirect] example is rendered",
|
|
2682
|
+
"children": [
|
|
2683
|
+
{
|
|
2684
|
+
"type": "describe",
|
|
2685
|
+
"name": "when the \"Delete Item\" button is clicked",
|
|
2686
|
+
"children": [
|
|
2687
|
+
{
|
|
2688
|
+
"type": "it",
|
|
2689
|
+
"name": "should show the popup"
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
"type": "describe",
|
|
2693
|
+
"name": "when the \"Delete\" button has focus and the tab key is pressed",
|
|
2694
|
+
"children": [
|
|
2695
|
+
{
|
|
2696
|
+
"type": "it",
|
|
2697
|
+
"name": "should hide the popup"
|
|
2698
|
+
},
|
|
2699
|
+
{
|
|
2700
|
+
"type": "it",
|
|
2701
|
+
"name": "should redirect focus to the \"Next Focusable Button\" button"
|
|
2702
|
+
}
|
|
2703
|
+
]
|
|
2704
|
+
}
|
|
2705
|
+
]
|
|
2706
|
+
}
|
|
2707
|
+
]
|
|
2638
2708
|
}
|
|
2639
2709
|
]
|
|
2640
2710
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Canvas Kit 5.0
|
|
1
|
+
# Canvas Kit 5.0 Upgrade Guide
|
|
2
2
|
|
|
3
3
|
Below are the breaking changes made in Canvas Kit v5. Please
|
|
4
4
|
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
@@ -28,7 +28,7 @@ any questions about the update.
|
|
|
28
28
|
|
|
29
29
|
We've introduced a
|
|
30
30
|
[new codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod) you can use
|
|
31
|
-
to automatically update your code to work with a majority of the breaking changes in the
|
|
31
|
+
to automatically update your code to work with a majority of the breaking changes in the upgrade
|
|
32
32
|
from Canvas Kit v4 to v5. Simply run:
|
|
33
33
|
|
|
34
34
|
```sh
|
|
@@ -49,7 +49,7 @@ rollback more easily if necessary.**
|
|
|
49
49
|
|
|
50
50
|
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
51
51
|
encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
|
|
52
|
-
help us maintain additional codemod transforms to make future
|
|
52
|
+
help us maintain additional codemod transforms to make future upgrades easier.
|
|
53
53
|
|
|
54
54
|
## General Changes
|
|
55
55
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Canvas Kit 6.0
|
|
1
|
+
# Canvas Kit 6.0 Upgrade Guide
|
|
2
2
|
|
|
3
3
|
Below are the breaking changes made in Canvas Kit v6. Please
|
|
4
4
|
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
@@ -39,7 +39,7 @@ any questions about the update.
|
|
|
39
39
|
## Codemod
|
|
40
40
|
|
|
41
41
|
Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
|
|
42
|
-
to automatically update your code to work with a majority of the breaking changes in the
|
|
42
|
+
to automatically update your code to work with a majority of the breaking changes in the upgrade
|
|
43
43
|
from Canvas Kit v5 to v6:
|
|
44
44
|
|
|
45
45
|
```sh
|
|
@@ -60,7 +60,7 @@ rollback more easily if necessary.**
|
|
|
60
60
|
|
|
61
61
|
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
62
62
|
encounter any issues or use cases that we've missed. The `@workday/canvas-kit-codemod` package will
|
|
63
|
-
help us maintain additional codemod transforms to make future
|
|
63
|
+
help us maintain additional codemod transforms to make future upgrades easier.
|
|
64
64
|
|
|
65
65
|
## Component Deprecations
|
|
66
66
|
|
|
@@ -80,7 +80,7 @@ warning.
|
|
|
80
80
|
#### Hard Deprecation
|
|
81
81
|
|
|
82
82
|
A hard-deprecated component or package is no longer available. You will need to follow the method
|
|
83
|
-
prescribed in our
|
|
83
|
+
prescribed in our upgrade guide to update your application. Please reach out to our team directly
|
|
84
84
|
if you need additional help.
|
|
85
85
|
|
|
86
86
|
### Cookie Banner
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Canvas Kit 7.0
|
|
1
|
+
# Canvas Kit 7.0 Upgrade Guide
|
|
2
2
|
|
|
3
3
|
This guide contains breaking changes in Canvas Kit v7. Please
|
|
4
4
|
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
@@ -27,7 +27,7 @@ any questions.
|
|
|
27
27
|
## Codemod
|
|
28
28
|
|
|
29
29
|
Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
|
|
30
|
-
to automatically update your code to work with many of the breaking changes as you
|
|
30
|
+
to automatically update your code to work with many of the breaking changes as you upgrade from
|
|
31
31
|
Canvas Kit v6 to v7:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
@@ -383,7 +383,7 @@ warning.
|
|
|
383
383
|
##### Hard Deprecation
|
|
384
384
|
|
|
385
385
|
A hard-deprecated component or package is no longer available. You will need to follow the method
|
|
386
|
-
prescribed in our
|
|
386
|
+
prescribed in our upgrade guide to update your application. Please
|
|
387
387
|
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) to our team
|
|
388
388
|
directly if you need additional help.
|
|
389
389
|
|
|
@@ -431,17 +431,74 @@ The APIs for these promoted components remain unchanged.
|
|
|
431
431
|
|
|
432
432
|
### Action Bar
|
|
433
433
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
[
|
|
438
|
-
|
|
439
|
-
|
|
434
|
+
The ActionBar API changed to model API to support more generic behaviors to allow for other
|
|
435
|
+
components to support responsive layouts using the same models and behaviors. It also allows to
|
|
436
|
+
implement a responsive layout based on a container width
|
|
437
|
+
([#1585](https://github.com/Workday/canvas-kit/pull/1585)).
|
|
438
|
+
|
|
439
|
+
```tsx
|
|
440
|
+
const model = useActionBarModel({
|
|
441
|
+
items: [
|
|
442
|
+
{
|
|
443
|
+
id: 'first',
|
|
444
|
+
text: 'First Action',
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
<ActionBar model={model} />;
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
The ActionBar component can now handle responsive containers, but the support is not automatic. You
|
|
453
|
+
must use the dynamic API and provide an overflow menu subcomponent. The dynamic API doesn't know the
|
|
454
|
+
shape of your object, so render props must be used to instruct React how to render each item.
|
|
440
455
|
|
|
441
|
-
|
|
442
|
-
|
|
456
|
+
```tsx
|
|
457
|
+
const [items] = React.useState<MyActionItem[]>([
|
|
458
|
+
{
|
|
459
|
+
id: 'first',
|
|
460
|
+
text: 'First Action',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
id: 'second',
|
|
464
|
+
text: 'Second Action',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
id: 'third',
|
|
468
|
+
text: 'Third Action',
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
id: 'fourth',
|
|
472
|
+
text: 'Fourth Action',
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
id: 'fifth',
|
|
476
|
+
text: 'Fifth Action',
|
|
477
|
+
},
|
|
478
|
+
]);
|
|
479
|
+
|
|
480
|
+
const model = useActionBarModel({items});
|
|
481
|
+
|
|
482
|
+
<ActionBar model={model}>
|
|
483
|
+
<ActionBar.List>
|
|
484
|
+
{item => <ActionBar.Item onClick={() => console.log(item.id)}>{item.text}</ActionBar.Item>}
|
|
485
|
+
</ActionBar.List>
|
|
486
|
+
<ActionBar.Menu.Popper>
|
|
487
|
+
<ActionBar.Menu.Card maxWidth={300} maxHeight={200}>
|
|
488
|
+
<ActionBar.Menu.List>
|
|
489
|
+
{item => (
|
|
490
|
+
<ActionBar.Menu.Item onClick={() => console.log(item.id)}>
|
|
491
|
+
{item.text}
|
|
492
|
+
</ActionBar.Menu.Item>
|
|
493
|
+
)}
|
|
494
|
+
</ActionBar.Menu.List>
|
|
495
|
+
</ActionBar.Menu.Card>
|
|
496
|
+
</ActionBar.Menu.Popper>
|
|
497
|
+
</ActionBar>;
|
|
498
|
+
```
|
|
443
499
|
|
|
444
|
-
🤖 The codemod will remove uses of the `fixed` prop from `ActionBar
|
|
500
|
+
🤖 The codemod will remove uses of the `fixed` prop from `ActionBar` and restructure component by
|
|
501
|
+
creating `ActionBar.List` subcomponent and replacing all `ActionBar` children to it.
|
|
445
502
|
|
|
446
503
|
---
|
|
447
504
|
|
|
@@ -785,6 +842,65 @@ anyway since the buttons will no longer scroll with overflowed `Body` content.
|
|
|
785
842
|
</Modal.Card>
|
|
786
843
|
```
|
|
787
844
|
|
|
845
|
+
#### Popup Model
|
|
846
|
+
|
|
847
|
+
In addition to the other [Model Changes](#model-changes), the `show` and `hide` events of all
|
|
848
|
+
disclosure-type models have been updated to remove the extra event wrapper. This change allows
|
|
849
|
+
developers to directly attach the `show` and `hide` events to React event handlers.
|
|
850
|
+
|
|
851
|
+
The following models were affected:
|
|
852
|
+
|
|
853
|
+
- `useDisclosureModel`
|
|
854
|
+
- `usePopupModel`
|
|
855
|
+
- `useModalModel`
|
|
856
|
+
- `useDisclosureModel`
|
|
857
|
+
|
|
858
|
+
```tsx
|
|
859
|
+
// v6
|
|
860
|
+
<button onClick={() => model.events.show()} /> // most use-cases look like this
|
|
861
|
+
<button onClick={event => model.events.show({event})} />
|
|
862
|
+
|
|
863
|
+
// v7
|
|
864
|
+
<button onClick={model.events.show} />
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
Removing the object wrapper around the `event` allows us to directly pass the `show` or `hide` event
|
|
868
|
+
to the `onClick` handler which is much more convenient. We couldn't find many uses of the `event` in
|
|
869
|
+
the wild, so the impact will be minimal. Most usage of `show` or `hide` events are called without
|
|
870
|
+
`event`, so this change will not impact most people. There is **no** codemod for this change,
|
|
871
|
+
because the usage is very difficult to detect since most people pass a callback that doesn't take
|
|
872
|
+
parameters.
|
|
873
|
+
|
|
874
|
+
Guards and callback signatures have also changed to remove the object wrapper around the `event`.
|
|
875
|
+
The following v6 example includes the [Model Changes](#model-changes) which this change compounds
|
|
876
|
+
upon.
|
|
877
|
+
|
|
878
|
+
```tsx
|
|
879
|
+
// v6
|
|
880
|
+
const model = usePopupModel({
|
|
881
|
+
shouldShow({data: {event}, state}) {
|
|
882
|
+
console.log(event, state);
|
|
883
|
+
},
|
|
884
|
+
onShow({data: {event}, prevState}) {
|
|
885
|
+
console.log(event, prevState);
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
// v7
|
|
890
|
+
const model = usePopupModel({
|
|
891
|
+
shouldShow(event, state) {
|
|
892
|
+
console.log(event, state);
|
|
893
|
+
},
|
|
894
|
+
onShow(event, prevState) {
|
|
895
|
+
console.log(event, prevState);
|
|
896
|
+
},
|
|
897
|
+
});
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
🤖 The codemod will update all inline guards and callbacks defined like they are in this example. If
|
|
901
|
+
a guard or callback was defined outside the model config block, it will not be covered by the
|
|
902
|
+
codemod.
|
|
903
|
+
|
|
788
904
|
---
|
|
789
905
|
|
|
790
906
|
### Segmented Control
|
package/dist/mdx/TESTING.mdx
CHANGED
|
@@ -162,7 +162,7 @@ different, but this will prevent snapshot tests that don't have any changes from
|
|
|
162
162
|
|
|
163
163
|
## Functional tests
|
|
164
164
|
|
|
165
|
-
Canvas Kit uses [Cypress]
|
|
165
|
+
Canvas Kit uses [Cypress](https://cypress.io) for browser-based behavior testing (additional info:
|
|
166
166
|
[Why Cypress?](https://github.com/Workday/canvas-kit/tree/master/cypress/WHY_CYPRESS.md)).
|
|
167
167
|
Functional tests ensure the code meets functional specifications from a user's perspective. All
|
|
168
168
|
functional tests are written against a Storybook Story. Specifications can come from many different
|
|
@@ -19,9 +19,9 @@ const ContextMenuTarget = createComponent('div')({
|
|
|
19
19
|
|
|
20
20
|
const onContextMenu = (event: React.MouseEvent) => {
|
|
21
21
|
if (model.state.visibility === 'visible') {
|
|
22
|
-
model.events.hide(
|
|
22
|
+
model.events.hide(event);
|
|
23
23
|
} else if (model.state.visibility === 'hidden') {
|
|
24
|
-
model.events.show(
|
|
24
|
+
model.events.show(event);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Prevent the default context menu from showing to avoid double menus
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import WithReadOnly from './examples/WithReadOnly';
|
|
6
|
+
import WithAvatar from './examples/WithAvatar';
|
|
7
|
+
import Basic from './examples/Basic';
|
|
8
|
+
import WithCount from './examples/WithCount';
|
|
9
|
+
import WithRemovable from './examples/WithRemovable';
|
|
10
|
+
import WithList from './examples/WithList';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Canvas Kit Pill
|
|
14
|
+
|
|
15
|
+
`Pill`s are static or interactive indicators that allow users to input, filter, or label
|
|
16
|
+
information.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
yarn add @workday/canvas-kit-preview-react
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
`Pill`s are used to visually label objects on a page for quick recognition. They’re offered as both
|
|
27
|
+
static (read-only) and interactive elements. They allow users to filter a list or table, or label
|
|
28
|
+
information to help with scanning and organization.
|
|
29
|
+
|
|
30
|
+
### Basic Pills
|
|
31
|
+
|
|
32
|
+
By default a Pill is considered interactive, therefore it's default variant is `default`.All leading
|
|
33
|
+
elements (icons or avatars) are intended to be descriptive, helping support the label. Do not rely
|
|
34
|
+
on the leading element to indicate the interaction behavior.
|
|
35
|
+
|
|
36
|
+
#### Icon
|
|
37
|
+
|
|
38
|
+
You can render an icon inside the `Pill` with `Pill.Icon`. It will render a `plusIcon` by default,
|
|
39
|
+
but it can be customized by providing an icon to the `icon` prop. Because it uses `SystemIcon` under
|
|
40
|
+
the hood, you also have to all `SystemIconProps`.
|
|
41
|
+
|
|
42
|
+
<ExampleCodeBlock code={Basic} />
|
|
43
|
+
|
|
44
|
+
#### Avatar
|
|
45
|
+
|
|
46
|
+
You can render an avatar image inside the `Pill` with `Pill.Avatar`. It should appear before the
|
|
47
|
+
`Pill` text. Because it uses `Avatar` under the hood, you also have access to all `AvatarProps`.
|
|
48
|
+
|
|
49
|
+
<ExampleCodeBlock code={WithAvatar} />
|
|
50
|
+
|
|
51
|
+
#### Count
|
|
52
|
+
|
|
53
|
+
The count appears after the label. It is usually associated with the label. If you have a category,
|
|
54
|
+
the count will dirrectly correlate to that category.
|
|
55
|
+
|
|
56
|
+
<ExampleCodeBlock code={WithCount} />
|
|
57
|
+
|
|
58
|
+
### Read Only
|
|
59
|
+
|
|
60
|
+
If the `Pill` has `variant='readOnly'`, it will look like a read-only `Pill`. This is a
|
|
61
|
+
non-interactive element that is used to display information.
|
|
62
|
+
|
|
63
|
+
> **_NOTE:_** `maxWidth` measures the width of the `Pill.Label` (or text) and not the width of the
|
|
64
|
+
> entire `Pill`. By default, this `maxWidth` is set to `200px` and the text will be truncated with
|
|
65
|
+
> an ellipsis and render an OverflowTooltip on hover and focus. This max width can be changed by
|
|
66
|
+
> providing a `maxWidth` prop on the Pill.
|
|
67
|
+
|
|
68
|
+
<ExampleCodeBlock code={WithReadOnly} />
|
|
69
|
+
|
|
70
|
+
### Removable Pills
|
|
71
|
+
|
|
72
|
+
Removable `Pill`s display an `X` icon after the label. They have a smaller, more specific focus
|
|
73
|
+
state and click target to be more intentional about their actions and to avoid unintended removal.
|
|
74
|
+
|
|
75
|
+
You can define a removable `Pill` by providing a `variant='removable'` prop.
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
<Pill variant="removable">
|
|
79
|
+
Pink Shirts
|
|
80
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
81
|
+
</Pill>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
In this case, we use a `Pill.IconButton` because the `X` becomes the focusable and clickable
|
|
85
|
+
element.
|
|
86
|
+
|
|
87
|
+
The default icon for `Pill.IconButton` is `xSmallIcon` but this can also be overwritten by passing
|
|
88
|
+
an `icon` prop to `Pill.IconButton`
|
|
89
|
+
|
|
90
|
+
<ExampleCodeBlock code={WithRemovable} />
|
|
91
|
+
|
|
92
|
+
### List of Pills
|
|
93
|
+
|
|
94
|
+
`Pill`s can often represent multiple pieces of information such as a filtered list of categories or
|
|
95
|
+
skills.
|
|
96
|
+
|
|
97
|
+
In order to achieve this, use our `HStack` component to wrap each `Pill` and space them out
|
|
98
|
+
accordingly.
|
|
99
|
+
|
|
100
|
+
<ExampleCodeBlock code={WithList} />
|
|
101
|
+
|
|
102
|
+
## Components
|
|
103
|
+
|
|
104
|
+
### Pill
|
|
105
|
+
|
|
106
|
+
By default, a `Pill` renders an interactive element that accepts subcomponents. By "interactive" we
|
|
107
|
+
mean that the Pill container is a focusable element (a `<button>`). All leading elements (icons or
|
|
108
|
+
avatars) are intended to be descriptive, helping support the label. They should not receive focus.
|
|
109
|
+
|
|
110
|
+
`Pill` is the container component. It also provides a React context model for its subcomponents.
|
|
111
|
+
Based on the `variant` prop this component will render different styled `Pill`s.
|
|
112
|
+
|
|
113
|
+
#### Usage
|
|
114
|
+
|
|
115
|
+
Example of read only:
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<Pill variant="readOnly">This is a read only</Pill>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Example of interactive:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<Pill onClick={() => console.log('clicked')}>
|
|
125
|
+
<Pill.Avatar /> Regina Skeltor
|
|
126
|
+
</Pill>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Example of removable:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
<Pill variant="removable">
|
|
133
|
+
<Pill.Avatar /> Regina Skeltor
|
|
134
|
+
<Pill.IconButton onClick={() => console.log('clicked')} />
|
|
135
|
+
</Pill>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
If you set the `Pill` `variant` to `removable`, it will render a `<span>` element. You can then
|
|
139
|
+
provide a `Pill.IconButton` that acts as the focus target. This creates a smaller, more intentional
|
|
140
|
+
click target that prevents users from accidentally deleting an item.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<Pill variant="removable">
|
|
144
|
+
Shoes
|
|
145
|
+
<Pill.IconButton onClick={() => console.log('handle remove')} />
|
|
146
|
+
</Pill>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Props
|
|
150
|
+
|
|
151
|
+
<ArgsTable of={Pill} />
|
|
152
|
+
|
|
153
|
+
### Pill.Avatar
|
|
154
|
+
|
|
155
|
+
This component renders an avatar. It supports all props of the `Avatar` component.
|
|
156
|
+
|
|
157
|
+
#### Usage
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<Pill variant="removable">
|
|
161
|
+
<Pill.Avatar url={avatarUrl} />
|
|
162
|
+
Regina Skeltor
|
|
163
|
+
<Pill.IconButton onClick={() => console.log('handle remove')} />
|
|
164
|
+
</Pill>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### Props
|
|
168
|
+
|
|
169
|
+
<ArgsTable of={Pill.Avatar} />
|
|
170
|
+
|
|
171
|
+
### Pill.Count
|
|
172
|
+
|
|
173
|
+
This component renders its `children` as the count.
|
|
174
|
+
|
|
175
|
+
#### Usage
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
179
|
+
Shoes
|
|
180
|
+
<Pill.Count>30</Pill.Count>
|
|
181
|
+
</Pill>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Props
|
|
185
|
+
|
|
186
|
+
<ArgsTable of={Pill.Count} />
|
|
187
|
+
|
|
188
|
+
### Pill.Icon
|
|
189
|
+
|
|
190
|
+
This component renders an `icon`. It not be used with the `default` styling – not `readOnly` or
|
|
191
|
+
`removable` variants. By default it renders a `plusIcon` but it can be overridden by providing an
|
|
192
|
+
icon to the `icon` prop.
|
|
193
|
+
|
|
194
|
+
#### Usage
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
198
|
+
<Pill.Icon />
|
|
199
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
200
|
+
</Pill>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Props
|
|
204
|
+
|
|
205
|
+
<ArgsTable of={Pill.Icon} />
|
|
206
|
+
|
|
207
|
+
### Pill.IconButton
|
|
208
|
+
|
|
209
|
+
This component renders a custom icon button. It is only intended to be used with the `removable`
|
|
210
|
+
variant. By default, it renders a `xSmallIcon` but can be overridden by providing an icon to the
|
|
211
|
+
`icon` prop.
|
|
212
|
+
|
|
213
|
+
#### Usage
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
<Pill variant="removable">
|
|
217
|
+
Pink Shirts
|
|
218
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
219
|
+
</Pill>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### Props
|
|
223
|
+
|
|
224
|
+
<ArgsTable of={Pill.IconButton} />
|
|
225
|
+
|
|
226
|
+
### Pill.Label
|
|
227
|
+
|
|
228
|
+
This component renders a `<span>` that automatically handles overflow by rendering a tooltip.
|
|
229
|
+
There's no need to use this component directly since the overflow is handled for you automatically.
|
|
230
|
+
|
|
231
|
+
#### Usage
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<Pill variant="readOnly">
|
|
235
|
+
<Pill.Label>Read-only</Pill.Label>
|
|
236
|
+
</Pill>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Props
|
|
240
|
+
|
|
241
|
+
<ArgsTable of={Pill.Label} />
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="xxs">
|
|
9
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
10
|
+
<Pill.Icon />
|
|
11
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
12
|
+
</Pill>
|
|
13
|
+
<Pill onClick={() => console.warn('clicked')} disabled>
|
|
14
|
+
<Pill.Icon />
|
|
15
|
+
<Pill.Label>Regina Skeltor</Pill.Label>
|
|
16
|
+
</Pill>
|
|
17
|
+
</HStack>
|
|
18
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
// @ts-ignore: Cannot find module error
|
|
5
|
+
import testAvatar from './test-avatar.png';
|
|
6
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
return (
|
|
10
|
+
<HStack spacing="xxs">
|
|
11
|
+
<Pill onClick={() => console.warn('clicked')}>
|
|
12
|
+
<Pill.Avatar url={testAvatar} />
|
|
13
|
+
Regina Skeltor
|
|
14
|
+
</Pill>
|
|
15
|
+
<Pill onClick={() => console.warn('clicked')} disabled maxWidth={50}>
|
|
16
|
+
<Pill.Avatar url={testAvatar} />
|
|
17
|
+
Regina Skeltor
|
|
18
|
+
</Pill>
|
|
19
|
+
</HStack>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react';
|
|
5
|
+
|
|
6
|
+
const data = [
|
|
7
|
+
'Shoes',
|
|
8
|
+
'Pants',
|
|
9
|
+
'Dress Shoes',
|
|
10
|
+
'Color',
|
|
11
|
+
'Accessories',
|
|
12
|
+
'Luxury',
|
|
13
|
+
'Casual',
|
|
14
|
+
'Hats',
|
|
15
|
+
'Beanies',
|
|
16
|
+
'Glasses',
|
|
17
|
+
'Jewelry',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
export default () => (
|
|
21
|
+
<Flex flexWrap="wrap">
|
|
22
|
+
{data.map((cat, index) => {
|
|
23
|
+
return (
|
|
24
|
+
<Pill key={index} variant="removable" marginBottom="xxs" marginInlineEnd="xxs">
|
|
25
|
+
<Pill.Label>{cat}</Pill.Label>
|
|
26
|
+
<Pill.IconButton onClick={() => console.log(`delete ${cat}`)} />
|
|
27
|
+
</Pill>
|
|
28
|
+
);
|
|
29
|
+
})}
|
|
30
|
+
</Flex>
|
|
31
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
|
|
5
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="xxs">
|
|
9
|
+
<Pill variant="readOnly">Read-only</Pill>
|
|
10
|
+
<Pill variant="readOnly" maxWidth={250}>
|
|
11
|
+
Read-only but with super long text in case you want to read a paragraph in a Pill which we
|
|
12
|
+
don't recommend
|
|
13
|
+
</Pill>
|
|
14
|
+
</HStack>
|
|
15
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Pill} from '@workday/canvas-kit-preview-react/pill';
|
|
4
|
+
// @ts-ignore: Cannot find module error
|
|
5
|
+
import testAvatar from './test-avatar.png';
|
|
6
|
+
import {HStack} from '@workday/canvas-kit-react';
|
|
7
|
+
|
|
8
|
+
export default () => (
|
|
9
|
+
<HStack spacing="xxs">
|
|
10
|
+
<Pill variant="removable">
|
|
11
|
+
Pink Shirts
|
|
12
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
13
|
+
</Pill>
|
|
14
|
+
<Pill variant="removable">
|
|
15
|
+
<Pill.Avatar url={testAvatar} />
|
|
16
|
+
Carolyn Grimaldi
|
|
17
|
+
<Pill.IconButton onClick={() => console.warn('clicked')} />
|
|
18
|
+
</Pill>
|
|
19
|
+
|
|
20
|
+
<Pill variant="removable" disabled>
|
|
21
|
+
<Pill.Label>This is a category that should not exist because it is too long</Pill.Label>
|
|
22
|
+
<Pill.IconButton />
|
|
23
|
+
</Pill>
|
|
24
|
+
</HStack>
|
|
25
|
+
);
|
|
Binary file
|
|
@@ -2,11 +2,16 @@ import {ActionBar} from '@workday/canvas-kit-react/action-bar';
|
|
|
2
2
|
import {Specifications} from '@workday/canvas-kit-docs';
|
|
3
3
|
|
|
4
4
|
import Basic from './examples/Basic';
|
|
5
|
+
import Icons from './examples/Icons';
|
|
6
|
+
import OverflowActionBar from './examples/OverflowActionBar';
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
# Canvas Kit Action Bar
|
|
8
10
|
|
|
9
|
-
Action Bar
|
|
11
|
+
Action Bar is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
12
|
+
that contains primary and secondary actions related to a page or task.
|
|
13
|
+
|
|
14
|
+
[> Workday Design Reference](https://design.workday.com/components/buttons/action-bar)
|
|
10
15
|
|
|
11
16
|
## Installation
|
|
12
17
|
|
|
@@ -18,21 +23,129 @@ yarn add @workday/canvas-kit-react
|
|
|
18
23
|
|
|
19
24
|
### Basic Example
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
`ActionBar` includes a container `ActionBar` component and the following subcomponent:
|
|
27
|
+
`ActionBar.List` which should contains `ActionBar.Item`.
|
|
28
|
+
|
|
29
|
+
In a basic example of an `ActionBar` there are two buttons. The primary action button should be used
|
|
30
|
+
only once and left aligned if content is left to right, followed by secondary buttons. Tertiary
|
|
31
|
+
buttons should not be used in the Action Bar.
|
|
24
32
|
|
|
25
33
|
<ExampleCodeBlock code={Basic} />
|
|
26
34
|
|
|
27
|
-
|
|
35
|
+
### Icons Example
|
|
36
|
+
|
|
37
|
+
`ActionBar.Item` renders a `PrimaryButton` or `SecondaryButton`, so it's possible to use other
|
|
38
|
+
Button props with `ActionBar.Item` such as `icon` or `size`.
|
|
39
|
+
|
|
40
|
+
<ExampleCodeBlock code={Icons} />
|
|
41
|
+
|
|
42
|
+
### Overflow Example
|
|
43
|
+
|
|
44
|
+
`ActionBar` container can contain up to 3 actions and an Overflow Menu if there are more than 3
|
|
45
|
+
actions, the other remaining actions should be placed into an Overflow Menu that is launched by
|
|
46
|
+
clicking the Overflow Button.
|
|
47
|
+
|
|
48
|
+
Also, ActionBar is a responsive component based on the width of its container. If the rendered
|
|
49
|
+
actions exceed the width of the `ActionBar.List`, an overflow menu will be rendered. This only works
|
|
50
|
+
against the dynamic API where you give the `ActionBarModel` an array of items to be rendered. The
|
|
51
|
+
dynamic API handles the React `key` for you based on the item's identifier. The dynamic API requires
|
|
52
|
+
either an `id` on each item object or a `getId` function that returns an identifier based on the
|
|
53
|
+
item. The below example uses an `id` property on each item.
|
|
54
|
+
|
|
55
|
+
The dynamic API takes in any object, but since nothing is known about your object, a
|
|
56
|
+
[render prop](https://reactjs.org/docs/render-props.html) is necessary to instruct a list how it
|
|
57
|
+
should render.
|
|
58
|
+
|
|
59
|
+
<ExampleCodeBlock code={OverflowActionBar} />
|
|
60
|
+
|
|
61
|
+
## Components
|
|
62
|
+
|
|
63
|
+
### ActionBar
|
|
28
64
|
|
|
29
|
-
|
|
65
|
+
#### Usage
|
|
30
66
|
|
|
31
|
-
|
|
32
|
-
|
|
67
|
+
`ActionBar` is a container component that is responsible for creating a `ActionBarModel` and sharing
|
|
68
|
+
it with its subcomponents using React context. It does not represent a real element.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<ActionBar items={[]}>{/* Child components */}</ActionBar>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Alternatively, you may pass in a model using the hoisted model pattern.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
const model = useActionBarModel({
|
|
78
|
+
items: [],
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
<ActionBar model={model}>{/* Child components */}</ActionBar>;
|
|
82
|
+
```
|
|
33
83
|
|
|
34
84
|
## Props
|
|
35
85
|
|
|
36
|
-
|
|
86
|
+
Note that if you pass in a `model` configured with `useActionBarModel`, configuration props passed
|
|
87
|
+
to `ActionBar` will be ignored.
|
|
88
|
+
|
|
89
|
+
<ArgsTable of={ActionBar} />
|
|
90
|
+
|
|
91
|
+
### ActionBar.List
|
|
92
|
+
|
|
93
|
+
#### Usage
|
|
94
|
+
|
|
95
|
+
`ActionBar.List` is a `HStack` element. It is a container for `ActionBar.Item` subcomponents. To
|
|
96
|
+
apply an overflow behavior for ActionBar `showOverflowButton` prop shold be true.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<ActionBar.List>{/* ActionBar.Items */}</ActionBar.List>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### Props
|
|
103
|
+
|
|
104
|
+
Undocumented props are spread to the underlying `HStack` element.
|
|
105
|
+
|
|
106
|
+
<ArgsTable of={ActionBar.List} />
|
|
107
|
+
|
|
108
|
+
### ActionBar.Item
|
|
109
|
+
|
|
110
|
+
#### Usage
|
|
111
|
+
|
|
112
|
+
`ActionBar.Item` is a `button` element, by default it's a `SecondaryButton` unless an `as` prop
|
|
113
|
+
passed.
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<ActionBar.Item as={PrimaryButton} onClick={() => console.log('first action')}>
|
|
117
|
+
First Action
|
|
118
|
+
</ActionBar.Item>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Props
|
|
122
|
+
|
|
123
|
+
Undocumented props are spread to the underlying `SecondaryButton` component.
|
|
124
|
+
|
|
125
|
+
<ArgsTable of={ActionBar.Item} />
|
|
126
|
+
|
|
127
|
+
## Model
|
|
128
|
+
|
|
129
|
+
If `ActionBar` was stripped of all its markup, attributes, and styling, what would remain is the
|
|
130
|
+
[model](/getting-started/for-developers/resources/compound-components/#models). The model is an
|
|
131
|
+
object composed of two parts: `state` which describes the current snapshot in time of the component
|
|
132
|
+
and `events` which describes events that can be sent to the model.
|
|
133
|
+
|
|
134
|
+
By default, `ActionBar` will create a model and share it internally with its subcomponents using
|
|
135
|
+
React context. Alternatively, if you need direct access to the model's `state` and `events` outside
|
|
136
|
+
of the `ActionBar` component, you may configure your own model with `useActionBarModel` and pass it
|
|
137
|
+
to `ActionBar` via a pattern called
|
|
138
|
+
[hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
const model = useActionBarModel({
|
|
142
|
+
items: [],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
<ActionBar model={model}>{/* Child components */}</ActionBar>;
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Config
|
|
37
149
|
|
|
38
|
-
|
|
150
|
+
`useActionBarModel` accepts a configuration object with the following properties and returns a
|
|
151
|
+
`ActionBarModel` with `state` and `events` properties.
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
2
|
import {ActionBar} from '@workday/canvas-kit-react/action-bar';
|
|
4
|
-
import {PrimaryButton
|
|
5
|
-
import {relatedActionsIcon} from '@workday/canvas-system-icons-web';
|
|
3
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
6
4
|
|
|
7
5
|
export default () => (
|
|
8
|
-
<ActionBar
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
<ActionBar>
|
|
7
|
+
<ActionBar.List position="relative">
|
|
8
|
+
<ActionBar.Item as={PrimaryButton} onClick={() => console.log('first action')}>
|
|
9
|
+
First Action
|
|
10
|
+
</ActionBar.Item>
|
|
11
|
+
<ActionBar.Item>Second Action</ActionBar.Item>
|
|
12
|
+
</ActionBar.List>
|
|
12
13
|
</ActionBar>
|
|
13
14
|
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {ActionBar} from '@workday/canvas-kit-react/action-bar';
|
|
4
|
+
import {notificationsIcon, alarmClockIcon} from '@workday/canvas-system-icons-web';
|
|
5
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
return (
|
|
9
|
+
<ActionBar>
|
|
10
|
+
<ActionBar.List position="relative">
|
|
11
|
+
<ActionBar.Item as={PrimaryButton} icon={notificationsIcon}>
|
|
12
|
+
First Action
|
|
13
|
+
</ActionBar.Item>
|
|
14
|
+
<ActionBar.Item icon={alarmClockIcon}>Second Action</ActionBar.Item>
|
|
15
|
+
</ActionBar.List>
|
|
16
|
+
</ActionBar>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {ActionBar, useActionBarModel} from '@workday/canvas-kit-react/action-bar';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import {PrimaryButton, SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
+
|
|
7
|
+
type MyActionItem = {
|
|
8
|
+
id: string;
|
|
9
|
+
text: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default () => {
|
|
13
|
+
const [items] = React.useState<MyActionItem[]>([
|
|
14
|
+
{id: 'first', text: 'First Action'},
|
|
15
|
+
{id: 'second', text: 'Second Action'},
|
|
16
|
+
{id: 'third', text: 'Third Action'},
|
|
17
|
+
{id: 'fourth', text: 'Fourth Action'},
|
|
18
|
+
{id: 'fifth', text: 'Fifth Action'},
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const model = useActionBarModel({items});
|
|
22
|
+
const [containerWidth, setContainerWidth] = React.useState('100%');
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div style={{width: containerWidth}}>
|
|
26
|
+
<ActionBar model={model}>
|
|
27
|
+
<ActionBar.List position="relative">
|
|
28
|
+
{(item: MyActionItem, index) => (
|
|
29
|
+
<ActionBar.Item
|
|
30
|
+
as={index === 0 ? PrimaryButton : undefined}
|
|
31
|
+
onClick={() => console.log(item.id)}
|
|
32
|
+
>
|
|
33
|
+
{item.text}
|
|
34
|
+
</ActionBar.Item>
|
|
35
|
+
)}
|
|
36
|
+
</ActionBar.List>
|
|
37
|
+
<ActionBar.Menu.Popper>
|
|
38
|
+
<ActionBar.Menu.Card maxWidth={300} maxHeight={200}>
|
|
39
|
+
<ActionBar.Menu.List>
|
|
40
|
+
{(item: MyActionItem) => (
|
|
41
|
+
<ActionBar.Menu.Item onClick={() => console.log(item.id)}>
|
|
42
|
+
{item.text}
|
|
43
|
+
</ActionBar.Menu.Item>
|
|
44
|
+
)}
|
|
45
|
+
</ActionBar.Menu.List>
|
|
46
|
+
</ActionBar.Menu.Card>
|
|
47
|
+
</ActionBar.Menu.Popper>
|
|
48
|
+
</ActionBar>
|
|
49
|
+
<hr />
|
|
50
|
+
<h4>Change action bar container size</h4>
|
|
51
|
+
<HStack spacing="xs">
|
|
52
|
+
<SecondaryButton onClick={() => setContainerWidth('100%')}>100%</SecondaryButton>
|
|
53
|
+
<SecondaryButton onClick={() => setContainerWidth('1023px')}>Medium</SecondaryButton>
|
|
54
|
+
<SecondaryButton onClick={() => setContainerWidth('767px')}>Small</SecondaryButton>
|
|
55
|
+
<SecondaryButton onClick={() => setContainerWidth('320px')}>Extra Small</SecondaryButton>
|
|
56
|
+
</HStack>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {Hyperlink, ExternalHyperlink} from '@workday/canvas-kit-react/button';
|
|
2
|
+
import {Specifications} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
import Link from './examples/Hyperlink';
|
|
5
|
+
import LinkInverse from './examples/HyperlinkInverse';
|
|
6
|
+
import ExternalLink from './examples/ExternalHyperlink';
|
|
7
|
+
import ExternalLinkInverse from './examples/ExternalHyperlinkInverse';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Canvas Kit Hyperlinks
|
|
11
|
+
|
|
12
|
+
Clickable anchor elements that extend the native `<a>` element with Canvas styling.
|
|
13
|
+
|
|
14
|
+
[> Workday Design Reference](https://design.workday.com/components/buttons/buttons)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
yarn add @workday/canvas-kit-react
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### Hyperlink
|
|
25
|
+
|
|
26
|
+
`Hyperlink`s should be used when you want to navigate away from the current page or to an anchor on
|
|
27
|
+
the current page.
|
|
28
|
+
|
|
29
|
+
<ExampleCodeBlock code={Link} />
|
|
30
|
+
|
|
31
|
+
#### Inverse
|
|
32
|
+
|
|
33
|
+
`Hyperlink`s also have an `inverse` variant. Use this variant when you need to place a `Hyperlink` on a
|
|
34
|
+
dark or colorful background such as `blueberry400`.
|
|
35
|
+
|
|
36
|
+
<ExampleCodeBlock code={LinkInverse} />
|
|
37
|
+
|
|
38
|
+
#### Props
|
|
39
|
+
|
|
40
|
+
Undocumented props are spread to the underlying `<a>` element.
|
|
41
|
+
|
|
42
|
+
<ArgsTable of={Hyperlink} />
|
|
43
|
+
|
|
44
|
+
### ExternalHyperlink
|
|
45
|
+
|
|
46
|
+
If your link should open in a new tab or window use the `ExternalHyperlink` component. It will let
|
|
47
|
+
users know about the behavior by adding an icon, `extLinkIcon`. By default, the icon has a label of
|
|
48
|
+
"Opens link in new window". You can override `aria-label` of the icon by using the `iconLabel`
|
|
49
|
+
prop. This override will be needed for translations.
|
|
50
|
+
|
|
51
|
+
<ExampleCodeBlock code={ExternalLink} />
|
|
52
|
+
|
|
53
|
+
`ExternalHyperlink`s also have an `inverse` variant. Use this variant when you need to place the link on a dark or colorful background such as `blueberry400`.
|
|
54
|
+
|
|
55
|
+
<ExampleCodeBlock code={ExternalLinkInverse} />
|
|
56
|
+
|
|
57
|
+
#### Props
|
|
58
|
+
|
|
59
|
+
Undocumented props are spread to the underlying `<a>` element.
|
|
60
|
+
|
|
61
|
+
<ArgsTable of={ExternalHyperlink} />
|
|
62
|
+
|
|
63
|
+
### Accessible Use of the `as` Prop
|
|
64
|
+
|
|
65
|
+
Like many of our components, `Hyperlink` and `ExternalHyperlink` accept an `as` prop, which lets you change the underlying
|
|
66
|
+
semantic element - usually an `<a>`, or a `<button>`. This should be done with caution to ensure the
|
|
67
|
+
best accessibility. Generally, `<button>` elements should be used for actions, and `<a>` elements
|
|
68
|
+
should be used for navigation.
|
|
69
|
+
|
|
70
|
+
## Specifications
|
|
71
|
+
|
|
72
|
+
<Specifications file="Hyperlink.spec.ts" name="Hyperlink" />
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {ExternalHyperlink} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {Box} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
|
|
6
|
+
export default () => (
|
|
7
|
+
<Box backgroundColor="blueberry400" padding="s">
|
|
8
|
+
<ExternalHyperlink href="https://workday.com" variant="inverse">
|
|
9
|
+
Hyperlink
|
|
10
|
+
</ExternalHyperlink>
|
|
11
|
+
</Box>
|
|
12
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Hyperlink} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {Box} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
|
|
6
|
+
export default () => (
|
|
7
|
+
<Box backgroundColor="blueberry400" padding="s">
|
|
8
|
+
<Hyperlink href="#hyperlink" variant="inverse">
|
|
9
|
+
Hyperlink
|
|
10
|
+
</Hyperlink>
|
|
11
|
+
</Box>
|
|
12
|
+
);
|
|
@@ -99,7 +99,7 @@ hatches for when the default behavior becomes forced. Should you find none of th
|
|
|
99
99
|
for your use case, we recommend using `Flex` instead of `Stack`, which will provide you with more
|
|
100
100
|
flexibility.
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
### Valid Children
|
|
103
103
|
|
|
104
104
|
Because `Stack` applies styles to children, it requires its immediate children to be valid child
|
|
105
105
|
elements. For example, text outside of an HTML tag would not render if it was an immediate `Stack`
|
|
@@ -49,7 +49,8 @@ export default () => {
|
|
|
49
49
|
<Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
|
|
50
50
|
Delete
|
|
51
51
|
</Popup.CloseButton>
|
|
52
|
-
|
|
52
|
+
{/* Disabled elements should not be focusable and focus should move to the next focusable element */}
|
|
53
|
+
<Popup.CloseButton disabled>Cancel</Popup.CloseButton>
|
|
53
54
|
</HStack>
|
|
54
55
|
</Popup.Card>
|
|
55
56
|
</Popup.Popper>
|
|
@@ -75,9 +75,9 @@ trigger an event to change the active tab.
|
|
|
75
75
|
|
|
76
76
|
### Named Tabs
|
|
77
77
|
|
|
78
|
-
`Tabs.Item` and `Tabs.Panel` both take an optional `
|
|
79
|
-
`onActivate` callback. This example is identical to the Basic Example, but with
|
|
80
|
-
`Tabs.Item` and `Tabs.Panel` subcomponents.
|
|
78
|
+
`Tabs.Item` and `Tabs.Panel` both take an optional `data-id` attribute that is used for the
|
|
79
|
+
`onActivate` callback. This example is identical to the Basic Example, but with tabs named using
|
|
80
|
+
`data-id` for the `Tabs.Item` and `Tabs.Panel` subcomponents.
|
|
81
81
|
|
|
82
82
|
<ExampleCodeBlock code={NamedTabs} />
|
|
83
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@storybook/csf": "0.0.1",
|
|
44
|
-
"@workday/canvas-kit-react": "^7.0.0
|
|
44
|
+
"@workday/canvas-kit-react": "^7.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"fs-extra": "^10.0.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"mkdirp": "^1.0.3",
|
|
50
50
|
"typescript": "4.1"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "5f2a5c83ce927fa64ac24447f5391e467f51a406"
|
|
53
53
|
}
|