@workday/canvas-kit-docs 15.0.4 → 15.0.5
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/ExampleCodeBlock.js +1 -1
- package/dist/es6/lib/Table.js +2 -2
- package/dist/es6/lib/docs.js +34 -11
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/es6/lib/widgetUtils.js +1 -1
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/FilterListWithLiveStatus.js +2 -2
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/IconButtonsWithLiveBadges.d.ts.map +1 -1
- package/dist/es6/mdx/accessibility/examples/AriaLiveRegions/IconButtonsWithLiveBadges.js +7 -2
- package/dist/es6/mdx/accessibility/examples/GlobalHeader.js +1 -1
- package/dist/es6/mdx/accessibility/examples/Popups/InlinePopupNoPortal.js +2 -2
- package/dist/es6/mdx/accessibility/examples/SidePanelWithNavigation.js +3 -3
- package/dist/es6/mdx/welcomePage.js +2 -2
- package/dist/mdx/accessibility/InlinePortals.mdx +3 -2
- package/dist/mdx/accessibility/Popups.mdx +1 -0
- package/dist/mdx/accessibility/WindowsHighContrastThemes.mdx +2 -2
- package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +2 -2
- package/dist/mdx/preview-react/multi-select/examples/Controlled.tsx +56 -57
- package/dist/mdx/preview-react/radio/examples/Basic.tsx +1 -1
- package/dist/mdx/preview-react/radio/examples/Custom.tsx +1 -1
- package/dist/mdx/preview-react/radio/examples/StandaloneRadio.tsx +6 -4
- package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +1 -1
- package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +1 -1
- package/dist/mdx/react/_examples/mdx/ContextualHelp.mdx +28 -18
- package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusRedirect.tsx +8 -2
- package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusTrap.tsx +10 -2
- package/dist/mdx/react/_examples/mdx/examples/CookieBanner.tsx +75 -58
- package/dist/mdx/react/_examples/mdx/examples/ListOfUploadedFiles.tsx +10 -10
- package/dist/mdx/react/_examples/mdx/examples/MediaModal.tsx +31 -19
- package/dist/mdx/react/_examples/mdx/examples/SelectWithFormik.tsx +5 -4
- package/dist/mdx/react/_examples/mdx/examples/layout/AreaColumnPositioning.tsx +32 -13
- package/dist/mdx/react/_examples/mdx/examples/layout/CustomColumnPositioning.tsx +37 -25
- package/dist/mdx/react/_examples/mdx/examples/layout/CustomColumnWidth.tsx +29 -13
- package/dist/mdx/react/_examples/mdx/examples/layout/FullWidthWith3Columns.tsx +6 -7
- package/dist/mdx/react/_examples/mdx/examples/layout/FullWidthWith3Columns2Rows.tsx +43 -14
- package/dist/mdx/react/_examples/mdx/examples/layout/Masonry.tsx +33 -32
- package/dist/mdx/react/_examples/mdx/examples/layout/ResponsiveColumns.tsx +16 -7
- package/dist/mdx/react/_examples/mdx/examples/layout/Tiled2and3Columns.tsx +60 -25
- package/dist/mdx/react/_examples/mdx/examples/layout/Tiled4and2Columns.tsx +60 -23
- package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +4 -2
- package/dist/mdx/react/avatar/Avatar.mdx +5 -7
- package/dist/mdx/react/badge/examples/CustomLimit.tsx +1 -1
- package/dist/mdx/react/banner/examples/RefForwarding.tsx +2 -1
- package/dist/mdx/react/banner/examples/Sticky.tsx +6 -5
- package/dist/mdx/react/banner/examples/StickyRTL.tsx +7 -7
- package/dist/mdx/react/breadcrumbs/examples/Overflow.tsx +5 -2
- package/dist/mdx/react/button/button/examples/Grow.tsx +10 -3
- package/dist/mdx/react/checkbox/examples/Indeterminate.tsx +1 -1
- package/dist/mdx/react/collection/mdx/examples/BasicGrid.tsx +25 -12
- package/dist/mdx/react/collection/mdx/examples/DataLoader.tsx +8 -6
- package/dist/mdx/react/collection/mdx/examples/MultiSelection.tsx +18 -6
- package/dist/mdx/react/collection/mdx/examples/OverflowVerticalList.tsx +14 -11
- package/dist/mdx/react/collection/mdx/examples/Selection.tsx +5 -1
- package/dist/mdx/react/collection/mdx/examples/WrappingGrid.tsx +25 -12
- package/dist/mdx/react/combobox/examples/Autocomplete.tsx +3 -4
- package/dist/mdx/react/common/mdx/Responsive.mdx +7 -0
- package/dist/mdx/react/common/mdx/examples/ResponsiveStyles.tsx +1 -0
- package/dist/mdx/react/common/mdx/examples/ResponsiveViewport.tsx +5 -5
- package/dist/mdx/react/dialog/examples/Basic.tsx +8 -2
- package/dist/mdx/react/dialog/examples/DialogWithFallbackPlacements.tsx +32 -8
- package/dist/mdx/react/dialog/examples/Focus.tsx +13 -3
- package/dist/mdx/react/form-field/examples/ThemedErrors.tsx +1 -1
- package/dist/mdx/react/layout/Box.mdx +7 -1
- package/dist/mdx/react/layout/Flex.mdx +6 -0
- package/dist/mdx/react/layout/Grid.mdx +6 -0
- package/dist/mdx/react/layout/examples/Flex/Basic.tsx +28 -39
- package/dist/mdx/react/layout/examples/Grid/GridCard.tsx +1 -1
- package/dist/mdx/react/layout/examples/Grid/GridLayout.tsx +46 -36
- package/dist/mdx/react/layout/examples/Grid/GridLayoutInteractive.tsx +34 -35
- package/dist/mdx/react/menu/examples/Basic.tsx +2 -1
- package/dist/mdx/react/menu/examples/ContextMenu.tsx +2 -1
- package/dist/mdx/react/menu/examples/Grouping.tsx +2 -1
- package/dist/mdx/react/menu/examples/Icons.tsx +2 -1
- package/dist/mdx/react/menu/examples/MenuWithFallbackPlacements.tsx +14 -7
- package/dist/mdx/react/menu/examples/Nested.tsx +2 -1
- package/dist/mdx/react/menu/examples/NestedDynamic.tsx +1 -1
- package/dist/mdx/react/menu/examples/SelectableMenu.tsx +2 -1
- package/dist/mdx/react/modal/examples/Basic.tsx +1 -1
- package/dist/mdx/react/modal/examples/BodyOverflow.tsx +4 -5
- package/dist/mdx/react/modal/examples/CustomFocus.tsx +4 -3
- package/dist/mdx/react/modal/examples/FullOverflow.tsx +5 -6
- package/dist/mdx/react/modal/examples/IframeTest.tsx +2 -1
- package/dist/mdx/react/modal/examples/ModalWithPopup.tsx +3 -2
- package/dist/mdx/react/modal/examples/ModalWithPopupRTL.tsx +3 -2
- package/dist/mdx/react/modal/examples/NoTargetRTL.tsx +1 -1
- package/dist/mdx/react/modal/examples/StackedModals.tsx +3 -2
- package/dist/mdx/react/modal/examples/WithRadioButtons.tsx +1 -0
- package/dist/mdx/react/modal/examples/WithTooltips.tsx +3 -2
- package/dist/mdx/react/modal/examples/WithoutCloseIcon.tsx +1 -1
- package/dist/mdx/react/popup/examples/CloseOnTargetHiddenTest.tsx +31 -17
- package/dist/mdx/react/popup/examples/FullScreen.tsx +6 -6
- package/dist/mdx/react/popup/examples/InlinePopup.tsx +2 -2
- package/dist/mdx/react/popup/examples/MixedPopupTypes.tsx +8 -6
- package/dist/mdx/react/popup/examples/NestedPopups.tsx +5 -6
- package/dist/mdx/react/popup/examples/PopupWithFallbackPlacements.tsx +6 -6
- package/dist/mdx/react/popup/examples/PopupWithNonHidablePopup.tsx +2 -1
- package/dist/mdx/react/popup/examples/ReturnFocusTest.tsx +20 -8
- package/dist/mdx/react/radio/examples/Inverse.tsx +2 -1
- package/dist/mdx/react/segmented-control/examples/Basic.tsx +2 -1
- package/dist/mdx/react/segmented-control/examples/Sizes.tsx +2 -3
- package/dist/mdx/react/select/examples/Controlled.tsx +2 -1
- package/dist/mdx/react/skeleton/examples/Basic.tsx +1 -1
- package/dist/mdx/react/skeleton/examples/Color.tsx +1 -1
- package/dist/mdx/react/skeleton/examples/Simulation.tsx +3 -3
- package/dist/mdx/react/table/examples/BasicWithHeading.tsx +1 -1
- package/dist/mdx/react/table/examples/FixedColumn.tsx +2 -2
- package/dist/mdx/react/tabs/examples/AlternativeTabStop.tsx +1 -1
- package/dist/mdx/react/tabs/examples/Basic.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +6 -2
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +1 -1
- package/dist/mdx/react/tabs/examples/Icons.tsx +1 -1
- package/dist/mdx/react/tabs/examples/NamedTabs.tsx +1 -1
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +7 -3
- package/dist/mdx/react/tabs/examples/RightToLeft.tsx +1 -1
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/text/examples/LabelText/Disabled.tsx +1 -1
- package/dist/mdx/react/tokens/examples/Overview.tsx +9 -11
- package/dist/mdx/react/tokens/examples/Tokens.tsx +3 -2
- package/dist/mdx/react/tooltip/examples/DescriptionType.tsx +2 -1
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +2 -2
- package/dist/mdx/styling/mdx/MergingStyles.mdx +1 -0
- package/dist/mdx/styling/mdx/examples/EmotionButton.tsx +1 -0
- package/dist/mdx/styling/mdx/examples/StylingOverrides.tsx +5 -5
- package/dist/mdx/tokens/TokenMigrationFinal.mdx +1 -1
- package/lib/ExampleCodeBlock.tsx +1 -1
- package/lib/Table.tsx +2 -2
- package/lib/widgetUtils.tsx +1 -1
- package/package.json +8 -8
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
ListBox,
|
|
5
3
|
useGridModel,
|
|
@@ -9,26 +7,41 @@ import {
|
|
|
9
7
|
} from '@workday/canvas-kit-react/collection';
|
|
10
8
|
import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
11
9
|
import {Box, Flex} from '@workday/canvas-kit-react/layout';
|
|
10
|
+
import {createStencil, createStyles, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
|
|
11
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
12
12
|
|
|
13
13
|
const useItem = composeHooks(useListItemSelect, useListItemRovingFocus, useListItemRegister);
|
|
14
14
|
|
|
15
|
+
const itemStencil = createStencil({
|
|
16
|
+
vars: {
|
|
17
|
+
background: '',
|
|
18
|
+
},
|
|
19
|
+
base: ({background}) => ({
|
|
20
|
+
background,
|
|
21
|
+
width: system.size.md,
|
|
22
|
+
border: `${px2rem(1)} solid ${system.color.border.strong}`,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
|
|
15
26
|
const Item = createSubcomponent('button')({
|
|
16
27
|
modelHook: useGridModel,
|
|
17
28
|
elemPropsHook: useItem,
|
|
18
29
|
})((elemProps, Element, model) => {
|
|
30
|
+
const backgroundColor = model.state.selectedIds.includes(elemProps['data-id'])
|
|
31
|
+
? system.color.surface.alt.default
|
|
32
|
+
: system.color.surface.default;
|
|
33
|
+
|
|
19
34
|
return (
|
|
20
|
-
<Box
|
|
21
|
-
as={Element}
|
|
22
|
-
{...elemProps}
|
|
23
|
-
width={40}
|
|
24
|
-
border="solid 1px black"
|
|
25
|
-
style={{
|
|
26
|
-
background: model.state.selectedIds.includes(elemProps['data-id']) ? 'gray' : 'white',
|
|
27
|
-
}}
|
|
28
|
-
/>
|
|
35
|
+
<Box as={Element} {...handleCsProp(elemProps, itemStencil({background: backgroundColor}))} />
|
|
29
36
|
);
|
|
30
37
|
});
|
|
31
38
|
|
|
39
|
+
const listBoxStencil = createStyles({
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
flexWrap: 'wrap',
|
|
42
|
+
width: px2rem(200),
|
|
43
|
+
});
|
|
44
|
+
|
|
32
45
|
export default () => {
|
|
33
46
|
const model = useGridModel({
|
|
34
47
|
columnCount: 5,
|
|
@@ -39,7 +52,7 @@ export default () => {
|
|
|
39
52
|
});
|
|
40
53
|
|
|
41
54
|
return (
|
|
42
|
-
<ListBox model={model} as={Flex}
|
|
55
|
+
<ListBox model={model} as={Flex} cs={listBoxStencil}>
|
|
43
56
|
{item => <Item>{item.id}</Item>}
|
|
44
57
|
</ListBox>
|
|
45
58
|
);
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
} from '@workday/canvas-kit-react/collection';
|
|
11
11
|
import {composeHooks} from '@workday/canvas-kit-react/common';
|
|
12
12
|
import {Box, Flex} from '@workday/canvas-kit-react/layout';
|
|
13
|
+
import {px2rem} from '@workday/canvas-kit-styling';
|
|
14
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
13
15
|
|
|
14
16
|
function pickRandom<T>(arr: T[]): T {
|
|
15
17
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
@@ -28,7 +30,7 @@ const options = Array(1000)
|
|
|
28
30
|
export default () => {
|
|
29
31
|
const [messages, setMessages] = React.useState<string[]>([]);
|
|
30
32
|
|
|
31
|
-
const {model
|
|
33
|
+
const {model} = useListLoader(
|
|
32
34
|
{
|
|
33
35
|
getId: (item: string) => item,
|
|
34
36
|
getTextValue: (item: string) => item,
|
|
@@ -61,10 +63,10 @@ export default () => {
|
|
|
61
63
|
);
|
|
62
64
|
|
|
63
65
|
return (
|
|
64
|
-
<Flex gap
|
|
65
|
-
<Flex flexDirection
|
|
66
|
+
<Flex cs={{gap: system.gap.xl}}>
|
|
67
|
+
<Flex cs={{flexDirection: 'column', gap: 0}}>
|
|
66
68
|
<p>Scroll or focus and use keys to navigate</p>
|
|
67
|
-
<ListBox model={model}
|
|
69
|
+
<ListBox model={model} cs={{maxHeight: px2rem(400), width: px2rem(300)}}>
|
|
68
70
|
{item => (
|
|
69
71
|
<ListBox.Item
|
|
70
72
|
as="button"
|
|
@@ -79,9 +81,9 @@ export default () => {
|
|
|
79
81
|
)}
|
|
80
82
|
</ListBox>
|
|
81
83
|
</Flex>
|
|
82
|
-
<Flex flexDirection
|
|
84
|
+
<Flex cs={{flexDirection: 'column', gap: 0}}>
|
|
83
85
|
<p>Events:</p>
|
|
84
|
-
<Box as="ul"
|
|
86
|
+
<Box as="ul" cs={{maxHeight: px2rem(400), overflowY: 'auto'}}>
|
|
85
87
|
{messages.map(message => (
|
|
86
88
|
<li key={message}>{message}</li>
|
|
87
89
|
))}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
ListBox,
|
|
5
3
|
ListItemProps,
|
|
@@ -11,6 +9,8 @@ import {
|
|
|
11
9
|
useListModel,
|
|
12
10
|
} from '@workday/canvas-kit-react/collection';
|
|
13
11
|
import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
12
|
+
import {createStencil, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
|
|
13
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
14
14
|
|
|
15
15
|
const useMultiSelectItem = composeHooks(
|
|
16
16
|
useListItemSelect,
|
|
@@ -18,18 +18,30 @@ const useMultiSelectItem = composeHooks(
|
|
|
18
18
|
useListItemRegister
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
+
const itemStencil = createStencil({
|
|
22
|
+
vars: {
|
|
23
|
+
background: '',
|
|
24
|
+
},
|
|
25
|
+
base: ({background}) => ({
|
|
26
|
+
background,
|
|
27
|
+
width: system.size.md,
|
|
28
|
+
border: `${px2rem(1)} solid ${system.color.border.strong}`,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
21
32
|
const Item = createSubcomponent('button')({
|
|
22
33
|
displayName: 'MultiSelectableItem',
|
|
23
34
|
modelHook: useListModel,
|
|
24
35
|
elemPropsHook: useMultiSelectItem,
|
|
25
36
|
})<ListItemProps>((elemProps, Element, model) => {
|
|
37
|
+
const backgroundColor = model.state.selectedIds.includes(elemProps['data-id'])
|
|
38
|
+
? system.color.surface.alt.default
|
|
39
|
+
: system.color.surface.default;
|
|
40
|
+
|
|
26
41
|
return (
|
|
27
42
|
<Element
|
|
28
43
|
role="listitem"
|
|
29
|
-
{...elemProps}
|
|
30
|
-
style={{
|
|
31
|
-
background: model.state.selectedIds.includes(elemProps['data-id']) ? 'gray' : 'white',
|
|
32
|
-
}}
|
|
44
|
+
{...handleCsProp(elemProps, itemStencil({background: backgroundColor}))}
|
|
33
45
|
/>
|
|
34
46
|
);
|
|
35
47
|
});
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import styled from '@emotion/styled';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
3
|
import {ActionBar, useActionBarModel} from '@workday/canvas-kit-react/action-bar';
|
|
5
4
|
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
6
|
-
import {StyledType} from '@workday/canvas-kit-react/common';
|
|
7
5
|
import {Box} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import {createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
7
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
8
|
|
|
9
9
|
type MyActionItem = {
|
|
10
10
|
id: string;
|
|
11
11
|
text: React.ReactNode;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const actionBarStencil = createStencil({
|
|
15
|
+
base: {
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
height: '100%',
|
|
18
|
+
'> *': {
|
|
19
|
+
flex: '0 0 auto',
|
|
20
|
+
},
|
|
17
21
|
},
|
|
18
22
|
});
|
|
19
23
|
|
|
@@ -32,14 +36,13 @@ export default () => {
|
|
|
32
36
|
|
|
33
37
|
return (
|
|
34
38
|
<>
|
|
35
|
-
<Box
|
|
39
|
+
<Box cs={{marginBlockEnd: system.gap.xxl, height: '50vh'}}>
|
|
36
40
|
<ActionBar model={model}>
|
|
37
|
-
<
|
|
41
|
+
<ActionBar.List
|
|
38
42
|
position="relative"
|
|
39
43
|
as="section"
|
|
40
44
|
aria-label="Overflow example actions"
|
|
41
|
-
|
|
42
|
-
height="100%"
|
|
45
|
+
cs={actionBarStencil()}
|
|
43
46
|
overflowButton={
|
|
44
47
|
<ActionBar.OverflowButton
|
|
45
48
|
cs={{overflow: 'visible', flex: 0}}
|
|
@@ -55,9 +58,9 @@ export default () => {
|
|
|
55
58
|
{item.text}
|
|
56
59
|
</ActionBar.Item>
|
|
57
60
|
)}
|
|
58
|
-
</
|
|
61
|
+
</ActionBar.List>
|
|
59
62
|
<ActionBar.Menu.Popper>
|
|
60
|
-
<ActionBar.Menu.Card
|
|
63
|
+
<ActionBar.Menu.Card cs={{maxWidth: px2rem(300), maxHeight: px2rem(200)}}>
|
|
61
64
|
<ActionBar.Menu.List>
|
|
62
65
|
{(item: MyActionItem) => (
|
|
63
66
|
<ActionBar.Menu.Item onClick={() => console.log(item.id)}>
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
createElemPropsHook,
|
|
15
15
|
createSubcomponent,
|
|
16
16
|
} from '@workday/canvas-kit-react/common';
|
|
17
|
+
import {cssVar} from '@workday/canvas-kit-styling';
|
|
18
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
17
19
|
|
|
18
20
|
// Create a custom hook for our item
|
|
19
21
|
const useItem = composeHooks(
|
|
@@ -21,7 +23,9 @@ const useItem = composeHooks(
|
|
|
21
23
|
return {
|
|
22
24
|
role: 'listitem',
|
|
23
25
|
style: {
|
|
24
|
-
background: model.state.selectedIds.includes(elemProps['data-id'])
|
|
26
|
+
background: model.state.selectedIds.includes(elemProps['data-id'])
|
|
27
|
+
? cssVar(system.color.surface.alt.default)
|
|
28
|
+
: cssVar(system.color.surface.default),
|
|
25
29
|
},
|
|
26
30
|
};
|
|
27
31
|
}),
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
ListBox,
|
|
5
3
|
useGridModel,
|
|
@@ -10,26 +8,41 @@ import {
|
|
|
10
8
|
} from '@workday/canvas-kit-react/collection';
|
|
11
9
|
import {composeHooks, createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
12
10
|
import {Box, Flex} from '@workday/canvas-kit-react/layout';
|
|
11
|
+
import {createStencil, createStyles, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
|
|
12
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
13
13
|
|
|
14
14
|
const useItem = composeHooks(useListItemSelect, useListItemRovingFocus, useListItemRegister);
|
|
15
15
|
|
|
16
|
+
const itemStencil = createStencil({
|
|
17
|
+
vars: {
|
|
18
|
+
background: '',
|
|
19
|
+
},
|
|
20
|
+
base: ({background}) => ({
|
|
21
|
+
background,
|
|
22
|
+
width: system.size.md,
|
|
23
|
+
border: `${px2rem(1)} solid ${system.color.border.strong}`,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
16
27
|
const Item = createSubcomponent('button')({
|
|
17
28
|
modelHook: useGridModel,
|
|
18
29
|
elemPropsHook: useItem,
|
|
19
30
|
})((elemProps, Element, model) => {
|
|
31
|
+
const backgroundColor = model.state.selectedIds.includes(elemProps['data-id'])
|
|
32
|
+
? system.color.surface.alt.default
|
|
33
|
+
: system.color.surface.default;
|
|
34
|
+
|
|
20
35
|
return (
|
|
21
|
-
<Box
|
|
22
|
-
as={Element}
|
|
23
|
-
{...elemProps}
|
|
24
|
-
width={40}
|
|
25
|
-
border="solid 1px black"
|
|
26
|
-
style={{
|
|
27
|
-
background: model.state.selectedIds.includes(elemProps['data-id']) ? 'gray' : 'white',
|
|
28
|
-
}}
|
|
29
|
-
/>
|
|
36
|
+
<Box as={Element} {...handleCsProp(elemProps, itemStencil({background: backgroundColor}))} />
|
|
30
37
|
);
|
|
31
38
|
});
|
|
32
39
|
|
|
40
|
+
const listBoxStyles = createStyles({
|
|
41
|
+
flexDirection: 'row',
|
|
42
|
+
flexWrap: 'wrap',
|
|
43
|
+
width: px2rem(200),
|
|
44
|
+
});
|
|
45
|
+
|
|
33
46
|
export default () => {
|
|
34
47
|
const model = useGridModel({
|
|
35
48
|
columnCount: 5,
|
|
@@ -41,7 +54,7 @@ export default () => {
|
|
|
41
54
|
});
|
|
42
55
|
|
|
43
56
|
return (
|
|
44
|
-
<ListBox model={model} as={Flex}
|
|
57
|
+
<ListBox model={model} as={Flex} cs={listBoxStyles}>
|
|
45
58
|
{item => <Item>{item.id}</Item>}
|
|
46
59
|
</ListBox>
|
|
47
60
|
);
|
|
@@ -135,11 +135,10 @@ export default () => {
|
|
|
135
135
|
<FormField.Input as={AutoCompleteInput} isLoading={loader.isLoading} />
|
|
136
136
|
<Combobox.Menu.Popper>
|
|
137
137
|
<Combobox.Menu.Card>
|
|
138
|
-
{model.state.items.length
|
|
138
|
+
{model.state.items.length < 1 ? (
|
|
139
139
|
<StyledMenuItem as="span">No Results Found</StyledMenuItem>
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
<Combobox.Menu.List maxHeight={px2rem(200)}>
|
|
140
|
+
) : (
|
|
141
|
+
<Combobox.Menu.List cs={{maxHeight: px2rem(200)}}>
|
|
143
142
|
{item => <Combobox.Menu.Item>{item}</Combobox.Menu.Item>}
|
|
144
143
|
</Combobox.Menu.List>
|
|
145
144
|
)}
|
|
@@ -6,6 +6,9 @@ import ResponsiveViewport from './examples/ResponsiveViewport';
|
|
|
6
6
|
|
|
7
7
|
# Responsive Styling
|
|
8
8
|
|
|
9
|
+
> **Note**: Some content on this page is outdated and does not follow our latest style patterns. It
|
|
10
|
+
> will be updated soon.
|
|
11
|
+
|
|
9
12
|
## What is Responsive Styling?
|
|
10
13
|
|
|
11
14
|
Responsive styling is an approach to web development that adjusts layout and appearance based on the
|
|
@@ -94,6 +97,7 @@ using a `min-width`. See example below.
|
|
|
94
97
|
```ts
|
|
95
98
|
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
96
99
|
import {space} from '@workday/canvas-kit-react/tokens';
|
|
100
|
+
|
|
97
101
|
const theme = useTheme();
|
|
98
102
|
const {up} = theme.canvas.breakpoints;
|
|
99
103
|
const mediaQuery = up('l'); // Returns '@media (min-width: 1024px)'
|
|
@@ -134,6 +138,7 @@ This example uses the `xl` breakpoint and only adds a `min-width` of `0` to the
|
|
|
134
138
|
```ts
|
|
135
139
|
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
136
140
|
import {space} from '@workday/canvas-kit-react/tokens';
|
|
141
|
+
|
|
137
142
|
const theme = useTheme();
|
|
138
143
|
const {down} = theme.canvas.breakpoints;
|
|
139
144
|
const mediaQuery = down('xl'); // Returns '@media (min-width: 0)'
|
|
@@ -160,6 +165,7 @@ seen in the second example below.
|
|
|
160
165
|
```ts
|
|
161
166
|
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
162
167
|
import {space} from '@workday/canvas-kit-react/tokens';
|
|
168
|
+
|
|
163
169
|
const theme = useTheme();
|
|
164
170
|
const {between} = theme.canvas.breakpoints;
|
|
165
171
|
// Returns '@media (min-width: 320px) and (max-width: 1023.5px)'
|
|
@@ -176,6 +182,7 @@ This example uses `xl` as the `end` breakpoint and only adds a min-width to the
|
|
|
176
182
|
```ts
|
|
177
183
|
import {useTheme} from '@workday/canvas-kit-react/common';
|
|
178
184
|
import {space} from '@workday/canvas-kit-react/tokens';
|
|
185
|
+
|
|
179
186
|
const theme = useTheme();
|
|
180
187
|
const {between} = theme.canvas.breakpoints;
|
|
181
188
|
const mediaQuery = between('m', 'xl'); // Returns '@media (min-width: 768px)'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
|
|
4
3
|
import {getTheme} from '@workday/canvas-kit-react/common';
|
|
5
4
|
import {Box, Grid} from '@workday/canvas-kit-react/layout';
|
|
@@ -17,10 +16,8 @@ const styles = {
|
|
|
17
16
|
gridTemplateRows: 'auto',
|
|
18
17
|
border: '10px solid',
|
|
19
18
|
borderRadius: 30,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
paddingTop: space.l,
|
|
23
|
-
paddingBottom: space.l,
|
|
19
|
+
paddingInline: space.s,
|
|
20
|
+
paddingBlock: space.l,
|
|
24
21
|
},
|
|
25
22
|
[medium]: {
|
|
26
23
|
gridTemplateAreas: "'Header Header' 'SmallContainer BodyContent' 'Footer Footer'",
|
|
@@ -153,6 +150,9 @@ const Circle = styled(Box)({
|
|
|
153
150
|
transform: 'translate(-50%, 0)',
|
|
154
151
|
});
|
|
155
152
|
|
|
153
|
+
/* Example is outdated in v15 as we are moving away from styled-components.
|
|
154
|
+
* TODO: Update this example to use the new styling approach.
|
|
155
|
+
*/
|
|
156
156
|
export default () => {
|
|
157
157
|
return (
|
|
158
158
|
<ParentCont>
|
|
@@ -5,6 +5,7 @@ import {Dialog} from '@workday/canvas-kit-react/dialog';
|
|
|
5
5
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
6
6
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
7
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
8
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
9
|
|
|
9
10
|
export default () => {
|
|
10
11
|
const [value, setValue] = React.useState('');
|
|
@@ -16,20 +17,25 @@ export default () => {
|
|
|
16
17
|
const handleEmail = () => {
|
|
17
18
|
console.log('Email Submitted');
|
|
18
19
|
};
|
|
20
|
+
|
|
19
21
|
return (
|
|
20
22
|
<Dialog>
|
|
21
23
|
<Dialog.Target as={PrimaryButton}>Open for Offer</Dialog.Target>
|
|
22
24
|
<Dialog.Popper>
|
|
23
25
|
<Dialog.Card>
|
|
24
26
|
<Dialog.CloseIcon aria-label="Close" />
|
|
25
|
-
<Dialog.Heading
|
|
27
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
28
|
+
Sign Up for 15% Off Your Next Order
|
|
29
|
+
</Dialog.Heading>
|
|
26
30
|
<Dialog.Body>
|
|
27
31
|
<FormField>
|
|
28
32
|
<FormField.Label>Email</FormField.Label>
|
|
29
33
|
<FormField.Input as={TextInput} onChange={handleChange} value={value} />
|
|
30
34
|
</FormField>
|
|
31
35
|
</Dialog.Body>
|
|
32
|
-
<Flex
|
|
36
|
+
<Flex
|
|
37
|
+
cs={{padding: system.padding.xxs, marginBlockStart: system.gap.xs, gap: system.gap.md}}
|
|
38
|
+
>
|
|
33
39
|
<Dialog.CloseButton as={PrimaryButton} onClick={handleEmail}>
|
|
34
40
|
Submit
|
|
35
41
|
</Dialog.CloseButton>
|
|
@@ -46,11 +46,17 @@ export default () => {
|
|
|
46
46
|
<Dialog.Popper placement="top">
|
|
47
47
|
<Dialog.Card>
|
|
48
48
|
<Dialog.CloseIcon aria-label="Close" />
|
|
49
|
-
<Dialog.Heading cs={{
|
|
49
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
50
50
|
This is dialog heading
|
|
51
51
|
</Dialog.Heading>
|
|
52
52
|
<Dialog.Body>This is dialog body.</Dialog.Body>
|
|
53
|
-
<Flex
|
|
53
|
+
<Flex
|
|
54
|
+
cs={{
|
|
55
|
+
gap: system.gap.sm,
|
|
56
|
+
padding: system.padding.xs,
|
|
57
|
+
marginBlockStart: system.gap.sm,
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
54
60
|
<Dialog.CloseButton as={PrimaryButton}>Submit</Dialog.CloseButton>
|
|
55
61
|
<Dialog.CloseButton>Cancel</Dialog.CloseButton>
|
|
56
62
|
</Flex>
|
|
@@ -64,11 +70,17 @@ export default () => {
|
|
|
64
70
|
<Dialog.Popper placement="left">
|
|
65
71
|
<Dialog.Card>
|
|
66
72
|
<Dialog.CloseIcon aria-label="Close" />
|
|
67
|
-
<Dialog.Heading cs={{
|
|
73
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
68
74
|
This is dialog heading
|
|
69
75
|
</Dialog.Heading>
|
|
70
76
|
<Dialog.Body>This is dialog body.</Dialog.Body>
|
|
71
|
-
<Flex
|
|
77
|
+
<Flex
|
|
78
|
+
cs={{
|
|
79
|
+
gap: system.gap.sm,
|
|
80
|
+
padding: system.padding.xs,
|
|
81
|
+
marginBlockStart: system.gap.sm,
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
72
84
|
<Dialog.CloseButton as={PrimaryButton}>Submit</Dialog.CloseButton>
|
|
73
85
|
<Dialog.CloseButton>Cancel</Dialog.CloseButton>
|
|
74
86
|
</Flex>
|
|
@@ -82,11 +94,17 @@ export default () => {
|
|
|
82
94
|
<Dialog.Popper placement="right">
|
|
83
95
|
<Dialog.Card>
|
|
84
96
|
<Dialog.CloseIcon aria-label="Close" />
|
|
85
|
-
<Dialog.Heading cs={{
|
|
97
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
86
98
|
This is dialog heading
|
|
87
99
|
</Dialog.Heading>
|
|
88
100
|
<Dialog.Body>This is dialog body.</Dialog.Body>
|
|
89
|
-
<Flex
|
|
101
|
+
<Flex
|
|
102
|
+
cs={{
|
|
103
|
+
gap: system.gap.sm,
|
|
104
|
+
padding: system.padding.xs,
|
|
105
|
+
marginBlockStart: system.gap.sm,
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
90
108
|
<Dialog.CloseButton as={PrimaryButton}>Submit</Dialog.CloseButton>
|
|
91
109
|
<Dialog.CloseButton>Cancel</Dialog.CloseButton>
|
|
92
110
|
</Flex>
|
|
@@ -100,11 +118,17 @@ export default () => {
|
|
|
100
118
|
<Dialog.Popper placement="bottom">
|
|
101
119
|
<Dialog.Card>
|
|
102
120
|
<Dialog.CloseIcon aria-label="Close" />
|
|
103
|
-
<Dialog.Heading cs={{
|
|
121
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
104
122
|
This is dialog heading
|
|
105
123
|
</Dialog.Heading>
|
|
106
124
|
<Dialog.Body>This is dialog body.</Dialog.Body>
|
|
107
|
-
<Flex
|
|
125
|
+
<Flex
|
|
126
|
+
cs={{
|
|
127
|
+
gap: system.gap.sm,
|
|
128
|
+
padding: system.padding.xs,
|
|
129
|
+
marginBlockStart: system.gap.sm,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
108
132
|
<Dialog.CloseButton as={PrimaryButton}>Submit</Dialog.CloseButton>
|
|
109
133
|
<Dialog.CloseButton>Cancel</Dialog.CloseButton>
|
|
110
134
|
</Flex>
|
|
@@ -5,6 +5,7 @@ import {Dialog} from '@workday/canvas-kit-react/dialog';
|
|
|
5
5
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
6
6
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
7
7
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
8
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
9
|
|
|
9
10
|
export default () => {
|
|
10
11
|
const [value, setValue] = React.useState('');
|
|
@@ -16,21 +17,30 @@ export default () => {
|
|
|
16
17
|
const handleEmail = () => {
|
|
17
18
|
console.log('Email Submitted');
|
|
18
19
|
};
|
|
20
|
+
|
|
19
21
|
return (
|
|
20
|
-
<Flex gap
|
|
22
|
+
<Flex cs={{gap: system.gap.lg}}>
|
|
21
23
|
<Dialog>
|
|
22
24
|
<Dialog.Target as={PrimaryButton}>Open for Offer</Dialog.Target>
|
|
23
25
|
<Dialog.Popper>
|
|
24
26
|
<Dialog.Card>
|
|
25
27
|
<Dialog.CloseIcon aria-label="Close" />
|
|
26
|
-
<Dialog.Heading
|
|
28
|
+
<Dialog.Heading cs={{paddingBlockStart: system.padding.md}}>
|
|
29
|
+
Sign Up for 15% Off Your Next Order
|
|
30
|
+
</Dialog.Heading>
|
|
27
31
|
<Dialog.Body>
|
|
28
32
|
<FormField>
|
|
29
33
|
<FormField.Label>Email</FormField.Label>
|
|
30
34
|
<FormField.Input as={TextInput} onChange={handleChange} value={value} />
|
|
31
35
|
</FormField>
|
|
32
36
|
</Dialog.Body>
|
|
33
|
-
<Flex
|
|
37
|
+
<Flex
|
|
38
|
+
cs={{
|
|
39
|
+
padding: system.padding.xxs,
|
|
40
|
+
marginBlockStart: system.gap.xs,
|
|
41
|
+
gap: system.gap.md,
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
34
44
|
<Dialog.CloseButton as={PrimaryButton} onClick={handleEmail}>
|
|
35
45
|
Submit
|
|
36
46
|
</Dialog.CloseButton>
|
|
@@ -7,7 +7,7 @@ import {createStyles, cssVar} from '@workday/canvas-kit-styling';
|
|
|
7
7
|
import {base, system} from '@workday/canvas-tokens-web';
|
|
8
8
|
|
|
9
9
|
const formFieldHintStyles = createStyles({
|
|
10
|
-
|
|
10
|
+
paddingBlockStart: system.padding.xs,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
export default () => {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
2
2
|
import Basic from './examples/Box/Basic';
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
# Box
|
|
5
6
|
|
|
7
|
+
> **Note**: Some of the content on this page may be outdated and may not follow the latest CK style
|
|
8
|
+
> guidance. Please use care when making updates and carefully review any changes. Prefer using the
|
|
9
|
+
> `createStyles` or `createStencil` utilities along with the latest design tokens to set styles.
|
|
10
|
+
> This page will be updated soon.
|
|
11
|
+
|
|
6
12
|
`Box` is a primitive component that provides a common, ergonomic API around Canvas design tokens. It
|
|
7
13
|
is highly flexible, and its primary purpose is to build other components.
|
|
8
14
|
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
2
2
|
import Basic from './examples/Flex/Basic';
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
# Canvas Kit Flex
|
|
5
6
|
|
|
7
|
+
> **Note**: Some of the content on this page may be outdated and may not follow the latest CK style
|
|
8
|
+
> guidance. Please use care when making updates and carefully review any changes. Prefer using the
|
|
9
|
+
> `createStyles` or `createStencil` utilities along with the latest design tokens to set styles.
|
|
10
|
+
> This page will be updated soon.
|
|
11
|
+
|
|
6
12
|
`Flex` is a low-level layout component that provides a common, ergonomic API for building
|
|
7
13
|
one-dimensional layouts with
|
|
8
14
|
[CSS Flexbox](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox).
|
|
@@ -3,8 +3,14 @@ import Basic from './examples/Grid/Basic';
|
|
|
3
3
|
import GridLayout from './examples/Grid/GridLayout';
|
|
4
4
|
import GridLayoutInteractive from './examples/Grid/GridLayoutInteractive';
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
# Canvas Kit Grid
|
|
7
8
|
|
|
9
|
+
> **Note**: Some of the content on this page may be outdated and may not follow the latest CK style
|
|
10
|
+
> guidance. Please use care when making updates and carefully review any changes. Prefer using the
|
|
11
|
+
> `createStyles` or `createStencil` utilities along with the latest design tokens to set styles.
|
|
12
|
+
> This page will be updated soon.
|
|
13
|
+
|
|
8
14
|
`Grid` is a low-level layout component that provides a common, ergonomic API for building
|
|
9
15
|
two-dimensional layouts (rows and columns) with
|
|
10
16
|
[CSS Grid](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids).
|