@workday/canvas-kit-docs 6.0.0-beta.0-next.15 → 6.0.2
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 +263 -33
- package/dist/es6/lib/specs.js +263 -33
- package/dist/mdx/4.0-MIGRATION-GUIDE.mdx +1 -1
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +554 -0
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +31 -30
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +64 -0
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +61 -0
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +72 -0
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +62 -0
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +4 -0
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +70 -0
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +64 -0
- package/dist/mdx/labs-react/text-input/TextInput.mdx +123 -0
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +46 -0
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Error.tsx +43 -0
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/HiddenLabel.tsx +17 -0
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/LoginForm.tsx +100 -0
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/RefForwarding.tsx +27 -0
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +20 -0
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +51 -0
- package/dist/mdx/labs-react/text-input/examples/ThemedError.tsx +40 -0
- package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
- package/dist/mdx/preview-react/menu/Menu.mdx +17 -9
- package/dist/mdx/preview-react/menu/examples/Basic.tsx +65 -10
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +45 -29
- package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +2 -2
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +2 -2
- package/dist/mdx/preview-react/side-panel/SidePanel.mdx +1 -1
- package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
- package/dist/mdx/react/button/button/Button.mdx +34 -9
- package/dist/mdx/react/button/button/examples/Primary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Secondary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +14 -0
- package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
- package/dist/mdx/react/card/card.mdx +1 -1
- 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 +160 -88
- package/dist/mdx/react/tabs/TabsModel.splitprops.tsx +5 -0
- package/dist/mdx/react/tabs/examples/{Simple.tsx → Basic.tsx} +0 -0
- 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/text-area/TextArea.mdx +1 -1
- package/dist/mdx/react/toast/toast.mdx +1 -17
- package/dist/mdx/react/tooltip/Tooltip.mdx +1 -1
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
- package/package.json +3 -3
- package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
- package/dist/mdx/preview-react/menu/examples/ContextMenuTarget.tsx +0 -33
- package/dist/mdx/preview-react/menu/examples/ControlButton.tsx +0 -84
- package/dist/mdx/react/pagination/examples/ShowAdditionalDetails.tsx +0 -52
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
+
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
4
|
+
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {CanvasProvider, PartialEmotionCanvasTheme, styled} from '@workday/canvas-kit-react/common';
|
|
6
|
+
import {colors, CSSProperties, space} from '@workday/canvas-kit-react/tokens';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const theme: PartialEmotionCanvasTheme = {
|
|
10
|
+
canvas: {
|
|
11
|
+
palette: {
|
|
12
|
+
common: {
|
|
13
|
+
focusOutline: colors.grapeSoda300,
|
|
14
|
+
},
|
|
15
|
+
alert: {
|
|
16
|
+
main: colors.kiwi500,
|
|
17
|
+
darkest: colors.kiwi600,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
return (
|
|
23
|
+
<CanvasProvider theme={theme}>
|
|
24
|
+
<AlertInput />
|
|
25
|
+
</CanvasProvider>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const StyledField = styled(TextInput.Field)<{alertStyles?: CSSProperties}>(
|
|
30
|
+
({alertStyles}) => alertStyles
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const AlertInput = () => {
|
|
34
|
+
const [value, setValue] = React.useState('invalid@email');
|
|
35
|
+
|
|
36
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
37
|
+
setValue(event.target.value);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const alertStyles = useThemedRing('alert');
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<VStack spacing="xxxs" alignItems="flex-start">
|
|
44
|
+
<TextInput>
|
|
45
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
46
|
+
<StyledField alertStyles={alertStyles} onChange={handleChange} value={value} />
|
|
47
|
+
<TextInput.Hint paddingTop={space.xxs}>Please enter a valid email.</TextInput.Hint>
|
|
48
|
+
</TextInput>
|
|
49
|
+
</VStack>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {TextInput} from '@workday/canvas-kit-labs-react/text-input';
|
|
3
|
+
import {VStack} from '@workday/canvas-kit-labs-react/layout';
|
|
4
|
+
import {CanvasProvider, PartialEmotionCanvasTheme} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {colors, space} from '@workday/canvas-kit-react/tokens';
|
|
6
|
+
|
|
7
|
+
export default () => {
|
|
8
|
+
const [value, setValue] = React.useState('');
|
|
9
|
+
|
|
10
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
11
|
+
setValue(event.target.value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const theme: PartialEmotionCanvasTheme = {
|
|
15
|
+
canvas: {
|
|
16
|
+
palette: {
|
|
17
|
+
common: {
|
|
18
|
+
focusOutline: colors.grapeSoda300,
|
|
19
|
+
},
|
|
20
|
+
error: {
|
|
21
|
+
main: colors.islandPunch400,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<CanvasProvider theme={theme}>
|
|
29
|
+
<VStack spacing="xxxs" alignItems="flex-start">
|
|
30
|
+
<TextInput hasError={!value} isRequired={true}>
|
|
31
|
+
<TextInput.Label>Email</TextInput.Label>
|
|
32
|
+
<TextInput.Field onChange={handleChange} value={value} />
|
|
33
|
+
<TextInput.Hint paddingTop={space.xxs}>
|
|
34
|
+
{!value && 'Please enter an email.'}
|
|
35
|
+
</TextInput.Hint>
|
|
36
|
+
</TextInput>
|
|
37
|
+
</VStack>
|
|
38
|
+
</CanvasProvider>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -46,7 +46,7 @@ you'll need to add `buttonAriaLabel` to `Breadcrumbs.CollapsibleList`.
|
|
|
46
46
|
|
|
47
47
|
<ExampleCodeBlock code={CollapsibleList} />
|
|
48
48
|
|
|
49
|
-
### Right-to-Left
|
|
49
|
+
### Right-to-Left (RTL)
|
|
50
50
|
|
|
51
51
|
Breadcrumbs has bidirectional support out of the box. That means outside of setting the content
|
|
52
52
|
direction in your application's Canvas theme, you don't need to do anything else to make it work.
|
|
@@ -3,7 +3,6 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
3
3
|
|
|
4
4
|
import Basic from './examples/Basic';
|
|
5
5
|
import ContextMenu from './examples/ContextMenu';
|
|
6
|
-
import ControlButton from './examples/ControlButton';
|
|
7
6
|
import CustomMenuItem from './examples/CustomMenuItem';
|
|
8
7
|
import Icons from './examples/Icons';
|
|
9
8
|
import ManyItems from './examples/ManyItems';
|
|
@@ -11,7 +10,7 @@ import ManyItems from './examples/ManyItems';
|
|
|
11
10
|
|
|
12
11
|
# Canvas Kit Menu
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
`Menu` displays a list of options when triggered by an action or UI element like an icon or button.
|
|
15
14
|
|
|
16
15
|
[> Workday Design Reference](https://design.workday.com/components/popups/menus)
|
|
17
16
|
|
|
@@ -25,8 +24,15 @@ yarn add @workday/canvas-kit-preview-react
|
|
|
25
24
|
|
|
26
25
|
### Basic Example
|
|
27
26
|
|
|
27
|
+
`Menu` is typically triggered by an action such as pressing a button. Here's an example of how you
|
|
28
|
+
might implement that behavior using a [`Popup`](/components/popups/popup/).
|
|
29
|
+
|
|
28
30
|
<ExampleCodeBlock code={Basic} />
|
|
29
31
|
|
|
32
|
+
`Menu` will automatically assign focus to itself when it appears provided you set the `isOpen` prop
|
|
33
|
+
correctly, so you do **not** need to use the `useInitialFocus` `Popup` hook. You **will**, however,
|
|
34
|
+
need to use `useReturnFocus` to return focus back to the triggering button after closing the `Menu`.
|
|
35
|
+
|
|
30
36
|
`Menu` follows the
|
|
31
37
|
[Actions Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
|
|
32
38
|
using `aria-activedescendant`. Below is table of supported keyboard shortcuts and associated
|
|
@@ -42,10 +48,8 @@ actions.
|
|
|
42
48
|
| `End` | Moves focus to the last menu item |
|
|
43
49
|
| `A-Z / a-z` | Moves focus to the next menu item with a label that starts with the typed character if such an menu item exists – otherwise, focus does not move |
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
and
|
|
47
|
-
|
|
48
|
-
<ExampleCodeBlock code={ControlButton} />
|
|
51
|
+
Note that although `Menu` includes support for keyboard shortcuts for the menu itself, you'll need
|
|
52
|
+
to add your own keyboard handling and aria attributes to the triggering button.
|
|
49
53
|
|
|
50
54
|
### Context Menu
|
|
51
55
|
|
|
@@ -59,7 +63,6 @@ custom menu items, be sure to use semantic `<li>` elements with the following at
|
|
|
59
63
|
|
|
60
64
|
- `role="menuitem"`
|
|
61
65
|
- `tabindex={-1}`
|
|
62
|
-
- `id`s following this pattern: `${MenuId}-${index}`
|
|
63
66
|
|
|
64
67
|
Below is an example:
|
|
65
68
|
|
|
@@ -79,19 +82,22 @@ Below is an example:
|
|
|
79
82
|
|
|
80
83
|
#### Usage
|
|
81
84
|
|
|
82
|
-
`Menu` renders a styled `<ul>` element
|
|
85
|
+
`Menu` renders a styled `<ul role="menu">` element within a [`Card`](/components/containers/card/)
|
|
86
|
+
and follows the
|
|
83
87
|
[Active Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
|
|
84
88
|
using `aria-activedescendant`.
|
|
85
89
|
|
|
86
90
|
#### Props
|
|
87
91
|
|
|
92
|
+
Undocumented props are spread to the underlying `<ul>` element.
|
|
93
|
+
|
|
88
94
|
<ArgsTable of={Menu} />
|
|
89
95
|
|
|
90
96
|
### MenuItem
|
|
91
97
|
|
|
92
98
|
#### Usage
|
|
93
99
|
|
|
94
|
-
`MenuItem` renders
|
|
100
|
+
`MenuItem` renders an `<li>` element with the correct attributes to ensure it is accessible. If you
|
|
95
101
|
choose to implement your own custom menu items, be sure to use semantic `<li>` elements with the
|
|
96
102
|
following attributes:
|
|
97
103
|
|
|
@@ -101,6 +107,8 @@ following attributes:
|
|
|
101
107
|
|
|
102
108
|
#### Props
|
|
103
109
|
|
|
110
|
+
Undocumented props are spread to the underlying `<li>` element.
|
|
111
|
+
|
|
104
112
|
<ArgsTable of={MenuItem} />
|
|
105
113
|
|
|
106
114
|
## Specifications
|
|
@@ -1,17 +1,72 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
2
|
import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
3
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {
|
|
5
|
+
Popup,
|
|
6
|
+
usePopupModel,
|
|
7
|
+
useAlwaysCloseOnOutsideClick,
|
|
8
|
+
useReturnFocus,
|
|
9
|
+
useCloseOnEscape,
|
|
10
|
+
} from '@workday/canvas-kit-react/popup';
|
|
11
|
+
|
|
12
|
+
const menuId = 'basic-menu';
|
|
4
13
|
|
|
5
14
|
export default () => {
|
|
15
|
+
const model = usePopupModel();
|
|
16
|
+
|
|
17
|
+
useAlwaysCloseOnOutsideClick(model);
|
|
18
|
+
useCloseOnEscape(model);
|
|
19
|
+
useReturnFocus(model);
|
|
20
|
+
|
|
21
|
+
const isOpen = model.state.visibility !== 'hidden';
|
|
22
|
+
|
|
23
|
+
const handleButtonKeyDown = (event: React.KeyboardEvent) => {
|
|
24
|
+
let isShortcut = false;
|
|
25
|
+
if (event.key === `Spacebar` || event.key === ` ` || event.key === `Enter`) {
|
|
26
|
+
isShortcut = true;
|
|
27
|
+
if (isOpen) {
|
|
28
|
+
model.events.hide();
|
|
29
|
+
} else {
|
|
30
|
+
model.events.show();
|
|
31
|
+
}
|
|
32
|
+
} else if (event.key === `ArrowDown` || event.key === `ArrowUp`) {
|
|
33
|
+
isShortcut = true;
|
|
34
|
+
model.events.show();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isShortcut) {
|
|
38
|
+
// Prevent ArrowDown and ArrowUp keys from scrolling the entire page
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
6
43
|
return (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
44
|
+
<Popup model={model}>
|
|
45
|
+
<Popup.Target
|
|
46
|
+
as={SecondaryButton}
|
|
47
|
+
onKeyDown={handleButtonKeyDown}
|
|
48
|
+
aria-expanded={isOpen}
|
|
49
|
+
aria-haspopup={true}
|
|
50
|
+
aria-controls={isOpen ? menuId : undefined}
|
|
51
|
+
>
|
|
52
|
+
Open Menu
|
|
53
|
+
</Popup.Target>
|
|
54
|
+
<Popup.Popper placement="bottom-start">
|
|
55
|
+
{/*
|
|
56
|
+
isOpen must be set for focus to be properly assigned to the Menu;
|
|
57
|
+
onClose must be set in order to the Menu to close properly after
|
|
58
|
+
selecting a MenuItem
|
|
59
|
+
*/}
|
|
60
|
+
<Menu id={menuId} isOpen={isOpen} onClose={model.events.hide}>
|
|
61
|
+
<MenuItem>First Item</MenuItem>
|
|
62
|
+
<MenuItem>Second Item (with a really really really long label)</MenuItem>
|
|
63
|
+
<MenuItem isDisabled>Third Item (disabled)</MenuItem>
|
|
64
|
+
<MenuItem>
|
|
65
|
+
Fourth Item (<b>with markup</b>)
|
|
66
|
+
</MenuItem>
|
|
67
|
+
<MenuItem hasDivider>Fifth Item (with divider)</MenuItem>
|
|
68
|
+
</Menu>
|
|
69
|
+
</Popup.Popper>
|
|
70
|
+
</Popup>
|
|
16
71
|
);
|
|
17
72
|
};
|
|
@@ -1,49 +1,65 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {createComponent, useForkRef} from '@workday/canvas-kit-react/common';
|
|
4
4
|
import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
5
5
|
import {
|
|
6
6
|
Popup,
|
|
7
|
+
PopupModelContext,
|
|
7
8
|
usePopupModel,
|
|
8
9
|
useAlwaysCloseOnOutsideClick,
|
|
9
10
|
useCloseOnEscape,
|
|
10
11
|
} from '@workday/canvas-kit-react/popup';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const ContextMenuTarget = createComponent('div')({
|
|
14
|
+
displayName: 'Popup.ContextMenuTarget',
|
|
15
|
+
Component: ({children, ...elemProps}, ref, Element) => {
|
|
16
|
+
const model = React.useContext(PopupModelContext);
|
|
17
|
+
const elementRef = useForkRef(ref, model.state.targetRef as any);
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const onContextMenu = (event: React.MouseEvent) => {
|
|
20
|
+
if (model.state.visibility === 'visible') {
|
|
21
|
+
model.events.hide({event});
|
|
22
|
+
} else if (model.state.visibility === 'hidden') {
|
|
23
|
+
model.events.show({event});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Prevent the default context menu from showing to avoid double menus
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
};
|
|
20
29
|
|
|
30
|
+
return (
|
|
31
|
+
<Element ref={elementRef} onContextMenu={onContextMenu} {...elemProps}>
|
|
32
|
+
{children}
|
|
33
|
+
</Element>
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export default () => {
|
|
21
39
|
const model = usePopupModel();
|
|
22
40
|
|
|
23
41
|
useAlwaysCloseOnOutsideClick(model);
|
|
24
42
|
useCloseOnEscape(model);
|
|
25
43
|
|
|
26
44
|
return (
|
|
27
|
-
<
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</Popup>
|
|
47
|
-
</CanvasProvider>
|
|
45
|
+
<Popup model={model}>
|
|
46
|
+
<ContextMenuTarget style={{display: 'inline'}} tabIndex={0}>
|
|
47
|
+
Right click on this text (Context menu target)
|
|
48
|
+
</ContextMenuTarget>
|
|
49
|
+
<Popup.Popper>
|
|
50
|
+
<Menu onClose={model.events.hide}>
|
|
51
|
+
<MenuItem>Back</MenuItem>
|
|
52
|
+
<MenuItem>Forward</MenuItem>
|
|
53
|
+
<MenuItem>Reload</MenuItem>
|
|
54
|
+
<MenuItem hasDivider>Bookmark Page</MenuItem>
|
|
55
|
+
<MenuItem>Save Page As...</MenuItem>
|
|
56
|
+
<MenuItem>Select All</MenuItem>
|
|
57
|
+
<MenuItem hasDivider>Take Screenshot</MenuItem>
|
|
58
|
+
<MenuItem hasDivider>View Page Source</MenuItem>
|
|
59
|
+
<MenuItem>Inspect Accessibility Properties</MenuItem>
|
|
60
|
+
<MenuItem>Inspect</MenuItem>
|
|
61
|
+
</Menu>
|
|
62
|
+
</Popup.Popper>
|
|
63
|
+
</Popup>
|
|
48
64
|
);
|
|
49
65
|
};
|
|
@@ -4,10 +4,10 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
return (
|
|
7
|
-
<Menu
|
|
7
|
+
<Menu>
|
|
8
8
|
<MenuItem>First Item</MenuItem>
|
|
9
9
|
<MenuItem>Second Item</MenuItem>
|
|
10
|
-
<li role="
|
|
10
|
+
<li role="menuitem" tabIndex={-1} style={{listStyle: 'none'}}>
|
|
11
11
|
Third Item (custom)
|
|
12
12
|
</li>
|
|
13
13
|
</Menu>
|
|
@@ -10,7 +10,7 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
12
|
return (
|
|
13
|
-
<Menu
|
|
13
|
+
<Menu>
|
|
14
14
|
<MenuItem icon={uploadCloudIcon}>First Item</MenuItem>
|
|
15
15
|
<MenuItem icon={setupIcon}>Second Item (with a really really really long label)</MenuItem>
|
|
16
16
|
<MenuItem isDisabled icon={uploadCloudIcon} secondaryIcon={taskContactIcon}>
|
|
@@ -4,11 +4,11 @@ import {Menu, MenuItem} from '@workday/canvas-kit-preview-react/menu';
|
|
|
4
4
|
|
|
5
5
|
export default () => {
|
|
6
6
|
return (
|
|
7
|
-
<Menu
|
|
7
|
+
<Menu>
|
|
8
8
|
{'One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen'
|
|
9
9
|
.split(' ')
|
|
10
10
|
.map(item => {
|
|
11
|
-
return <MenuItem>Item {item}</MenuItem>;
|
|
11
|
+
return <MenuItem key={item}>Item {item}</MenuItem>;
|
|
12
12
|
})}
|
|
13
13
|
</Menu>
|
|
14
14
|
);
|
|
@@ -143,7 +143,7 @@ Below is an example:
|
|
|
143
143
|
```tsx
|
|
144
144
|
import {useSidePanel} from '@workday/canvas-kit-preview-react/side-panel';
|
|
145
145
|
|
|
146
|
-
const {expanded,
|
|
146
|
+
const {expanded, setExpanded, panelProps, labelProps, controlProps} = useSidePanel({
|
|
147
147
|
initialExpanded: false,
|
|
148
148
|
panelId: 'custom-panel-id',
|
|
149
149
|
labelId: 'custom-label-id',
|
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
import {Specifications} from '@workday/canvas-kit-docs';
|
|
8
8
|
|
|
9
9
|
import Primary from './examples/Primary';
|
|
10
|
+
import PrimaryInverse from './examples/PrimaryInverse';
|
|
10
11
|
import Secondary from './examples/Secondary';
|
|
12
|
+
import SecondaryInverse from './examples/SecondaryInverse';
|
|
11
13
|
import Tertiary from './examples/Tertiary';
|
|
14
|
+
import TertiaryInverse from './examples/TertiaryInverse';
|
|
12
15
|
import Delete from './examples/Delete';
|
|
13
16
|
|
|
14
17
|
|
|
@@ -35,11 +38,20 @@ Primary Buttons are high emphasis. Use once per screen to draw attention to the
|
|
|
35
38
|
action. Multiple primary buttons make it confusing for the user to understand what action they
|
|
36
39
|
should take. Not all screens require a Primary Button.
|
|
37
40
|
|
|
41
|
+
Primary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are supported
|
|
42
|
+
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
43
|
+
|
|
38
44
|
<ExampleCodeBlock code={Primary} />
|
|
39
45
|
|
|
46
|
+
Primary Buttons also have an `inverse` variant. While it looks similar to the default Secondary
|
|
47
|
+
Button, the default outline as well as the hover and focus states are different. Use this variant
|
|
48
|
+
when you need to place a Primary Button on a dark or colorful background such as `blueberry400`.
|
|
49
|
+
|
|
50
|
+
<ExampleCodeBlock code={PrimaryInverse} />
|
|
51
|
+
|
|
40
52
|
#### Props
|
|
41
53
|
|
|
42
|
-
Undocumented props are spread to the underlying
|
|
54
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
43
55
|
|
|
44
56
|
<ArgsTable of={PrimaryButton} />
|
|
45
57
|
|
|
@@ -49,13 +61,19 @@ Secondary Buttons have a medium level of emphasis. Use them for non-critical act
|
|
|
49
61
|
Buttons can be used on most pages without restrictions and work well for multiple actions of equal
|
|
50
62
|
weight. They can be used in conjunction with a Primary Button or independently.
|
|
51
63
|
|
|
52
|
-
|
|
64
|
+
Secondary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are supported
|
|
65
|
+
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
53
66
|
|
|
54
67
|
<ExampleCodeBlock code={Secondary} />
|
|
55
68
|
|
|
69
|
+
Secondary Buttons also have an `inverse` variant. Use this when you need to place a Secondary Button on
|
|
70
|
+
a dark or colorful background such as `blueberry400`.
|
|
71
|
+
|
|
72
|
+
<ExampleCodeBlock code={SecondaryInverse} />
|
|
73
|
+
|
|
56
74
|
#### Props
|
|
57
75
|
|
|
58
|
-
Undocumented props are spread to the underlying
|
|
76
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
59
77
|
|
|
60
78
|
<ArgsTable of={SecondaryButton} />
|
|
61
79
|
|
|
@@ -66,13 +84,20 @@ the user may not often be looking to do. Tertiary Buttons have lower prominence
|
|
|
66
84
|
not visible until it is interacted with. Use Tertiary Buttons for supplemental actions such as “View
|
|
67
85
|
More”, “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
Tertiary Buttons have three sizes: `extraSmall`, `small`, and `medium`. Icons are supported
|
|
88
|
+
for every size and can be positioned to the `left` or `right` with the `iconPosition` prop.
|
|
70
89
|
|
|
71
90
|
<ExampleCodeBlock code={Tertiary} />
|
|
72
91
|
|
|
92
|
+
Tertiary Buttons also have an `inverse` variant. Use this when you need to place a Tertiary Button on
|
|
93
|
+
a dark or colorful background such as `blueberry400`.
|
|
94
|
+
|
|
95
|
+
<ExampleCodeBlock code={TertiaryInverse} />
|
|
96
|
+
|
|
97
|
+
|
|
73
98
|
#### Props
|
|
74
99
|
|
|
75
|
-
Undocumented props are spread to the underlying
|
|
100
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
76
101
|
|
|
77
102
|
<ArgsTable of={TertiaryButton} />
|
|
78
103
|
|
|
@@ -86,16 +111,16 @@ before deleting.
|
|
|
86
111
|
|
|
87
112
|
#### Props
|
|
88
113
|
|
|
89
|
-
Undocumented props are spread to the underlying
|
|
114
|
+
Undocumented props are spread to the underlying `<button>` element.
|
|
90
115
|
|
|
91
116
|
<ArgsTable of={DeleteButton} />
|
|
92
117
|
|
|
93
118
|
### Accessible Use of the `as` Prop
|
|
94
119
|
|
|
95
120
|
Like many of our components, Buttons accept an `as` prop, which lets you change the underlying
|
|
96
|
-
semantic element - usually an
|
|
97
|
-
|
|
98
|
-
|
|
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.
|
|
99
124
|
|
|
100
125
|
## Specifications
|
|
101
126
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
4
6
|
|
|
5
|
-
export default () =>
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" padding="s">
|
|
9
|
+
<PrimaryButton>Primary</PrimaryButton>
|
|
10
|
+
<PrimaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
+
Primary
|
|
12
|
+
</PrimaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
+
<PrimaryButton variant="inverse">Primary</PrimaryButton>
|
|
10
|
+
<PrimaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
+
Primary
|
|
12
|
+
</PrimaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
4
6
|
|
|
5
|
-
export default () =>
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" padding="s">
|
|
9
|
+
<SecondaryButton>Secondary</SecondaryButton>
|
|
10
|
+
<SecondaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
+
Secondary
|
|
12
|
+
</SecondaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
+
<SecondaryButton variant="inverse">Secondary</SecondaryButton>
|
|
10
|
+
<SecondaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
+
Secondary
|
|
12
|
+
</SecondaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
4
6
|
|
|
5
|
-
export default () =>
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" padding="s">
|
|
9
|
+
<TertiaryButton>Tertiary</TertiaryButton>
|
|
10
|
+
<TertiaryButton icon={plusIcon} iconPosition="right">
|
|
11
|
+
Tertiary
|
|
12
|
+
</TertiaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {HStack} from '@workday/canvas-kit-labs-react/layout';
|
|
5
|
+
import {plusIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
+
|
|
7
|
+
export default () => (
|
|
8
|
+
<HStack spacing="s" backgroundColor="blueberry400" padding="s">
|
|
9
|
+
<TertiaryButton variant="inverse">Tertiary</TertiaryButton>
|
|
10
|
+
<TertiaryButton icon={plusIcon} iconPosition="right" variant="inverse">
|
|
11
|
+
Tertiary
|
|
12
|
+
</TertiaryButton>
|
|
13
|
+
</HStack>
|
|
14
|
+
);
|
|
@@ -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} />
|
|
@@ -8,7 +8,7 @@ import Padding from './examples/Padding';
|
|
|
8
8
|
# Canvas Kit Card
|
|
9
9
|
|
|
10
10
|
A Card is a preview that serves as an entry point to more detailed information. Card is a
|
|
11
|
-
presentational [compound component](/getting-started/for-developers/resources/compound-components/
|
|
11
|
+
presentational [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
12
12
|
used as a building block for other components such as [Popup](/components/popups/popup/) and
|
|
13
13
|
[Modal](/components/popups/modal/).
|
|
14
14
|
|