@workday/canvas-kit-docs 8.0.0-alpha.144-next.0 → 8.0.0-alpha.151-next.3
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/mdx/8.0-UPGRADE-GUIDE.mdx +28 -2
- package/dist/mdx/preview-react/_examples/examples/SidePanelWithOverlay.tsx +5 -8
- package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +12 -9
- package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +11 -9
- package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +10 -9
- package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +10 -8
- package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +11 -9
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +3 -2
- package/dist/mdx/react/_examples/examples/PageHeader.tsx +13 -11
- package/dist/mdx/react/layout/Box.mdx +30 -3
- package/dist/mdx/react/layout/Grid.mdx +130 -0
- package/dist/mdx/react/layout/examples/Flex/FlexCard.tsx +7 -19
- package/dist/mdx/react/layout/examples/Flex/Usage.tsx +31 -48
- package/dist/mdx/react/layout/examples/Font.tsx +21 -0
- package/dist/mdx/react/layout/examples/Grid/GridCard.tsx +44 -0
- package/dist/mdx/react/layout/examples/Grid/GridLayout.tsx +65 -0
- package/dist/mdx/react/layout/examples/Grid/GridLayoutInteractive.tsx +114 -0
- package/dist/mdx/react/layout/examples/Grid/UIExample.tsx +71 -0
- package/dist/mdx/react/layout/examples/PropTables.splitprops.tsx +3 -1
- package/dist/mdx/react/layout/examples/Stack/HStackCards.tsx +7 -3
- package/dist/mdx/react/layout/examples/Stack/StackCard.tsx +6 -4
- package/dist/mdx/react/layout/examples/Stack/VStackCards.tsx +7 -3
- package/dist/mdx/react/layout/examples/Text.tsx +32 -0
- package/dist/mdx/react/radio/examples/NoValue.tsx +2 -2
- package/dist/mdx/react/skeleton/examples/Simulation.tsx +4 -8
- package/dist/mdx/react/text/PropTables.splitprops.tsx +15 -0
- package/dist/mdx/react/text/Text.mdx +129 -0
- package/dist/mdx/react/text/examples/BodyText.tsx +10 -0
- package/dist/mdx/react/text/examples/Heading.tsx +16 -0
- package/dist/mdx/react/text/examples/Label.tsx +14 -0
- package/dist/mdx/react/text/examples/Subtext.tsx +10 -0
- package/dist/mdx/react/text/examples/Text.tsx +23 -0
- package/dist/mdx/react/text/examples/Title.tsx +16 -0
- package/package.json +3 -3
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
# Canvas Kit
|
|
1
|
+
# Canvas Kit 8.0 Upgrade Guide
|
|
2
2
|
|
|
3
|
-
This guide contains breaking changes in Canvas Kit
|
|
3
|
+
This guide contains breaking changes in Canvas Kit v8. Please
|
|
4
4
|
[reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
|
|
5
5
|
any questions.
|
|
6
6
|
|
|
7
7
|
- [Codemod](#codemod)
|
|
8
|
+
- [Components](#components)
|
|
9
|
+
- [Box](#box)
|
|
8
10
|
- [General Changes](#general-changes) -[Remove Default Imports](#remove-default-imports)
|
|
9
11
|
|
|
10
12
|
## Codemod
|
|
@@ -32,6 +34,30 @@ rollback more easily if necessary.**
|
|
|
32
34
|
[Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
|
|
33
35
|
encounter any issues or use cases that we've missed.
|
|
34
36
|
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
### Box
|
|
40
|
+
|
|
41
|
+
#### Updating props
|
|
42
|
+
|
|
43
|
+
The following props have been added to the `Box` component to support font and text styles:
|
|
44
|
+
`fontFamily`, `fontSize`, `fontStyle`, `fontWeight`, `lineHeight`, `letterSpacing`, `textAlign`,
|
|
45
|
+
`textDecoration`, `textTransform`, `textShadow`, `whiteSpace`, `wordBreak`.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
// v7
|
|
49
|
+
const StyledBox = styled(Box)({
|
|
50
|
+
fontFamily: 'monospace',
|
|
51
|
+
fontSize: type.properties.fontSizes[16],
|
|
52
|
+
fontWeight: type.properties.fontWeights.medium
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
<StyledBox />
|
|
56
|
+
|
|
57
|
+
// v8
|
|
58
|
+
<Box fontFamily="monospace" fontSize={16} fontWeight="medium" />
|
|
59
|
+
```
|
|
60
|
+
|
|
35
61
|
## General Changes
|
|
36
62
|
|
|
37
63
|
### Remove Default Imports
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {styled} from '@workday/canvas-kit-react/common';
|
|
3
|
-
import {
|
|
3
|
+
import {depth} from '@workday/canvas-kit-react/tokens';
|
|
4
4
|
import {SidePanel, useSidePanel} from '@workday/canvas-kit-preview-react/side-panel';
|
|
5
5
|
import {Flex, Box} from '@workday/canvas-kit-react/layout';
|
|
6
|
-
|
|
7
|
-
const StyledHeader = styled('h3')({
|
|
8
|
-
...type.levels.body.large,
|
|
9
|
-
color: colors.licorice500,
|
|
10
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
11
|
-
});
|
|
6
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
12
7
|
|
|
13
8
|
const StyledPanel = styled(SidePanel)({
|
|
14
9
|
...depth[6],
|
|
@@ -22,7 +17,9 @@ export default () => {
|
|
|
22
17
|
<Flex height={320} backgroundColor="soap100" position="relative">
|
|
23
18
|
<StyledPanel touched={true} variant="alternate">
|
|
24
19
|
<Flex alignItems="center" paddingY="s" paddingX="s">
|
|
25
|
-
<
|
|
20
|
+
<Text as="h3" typeLevel="body.large" fontWeight="bold" color="licorice500">
|
|
21
|
+
Alternate Panel
|
|
22
|
+
</Text>
|
|
26
23
|
</Flex>
|
|
27
24
|
</StyledPanel>
|
|
28
25
|
<Box position="absolute" background="rgba(0,0,0,0.65)" height="100%" width="100%" />
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {styled} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {space} from '@workday/canvas-kit-react/tokens';
|
|
3
4
|
import {AccentIcon} from '@workday/canvas-kit-react/icon';
|
|
4
5
|
import {rocketIcon} from '@workday/canvas-accent-icons-web';
|
|
5
6
|
import {SidePanel, useSidePanel} from '@workday/canvas-kit-preview-react/side-panel';
|
|
6
7
|
import {Flex, HStack} from '@workday/canvas-kit-react/layout';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const StyledHeader = styled('h3')({
|
|
10
|
-
...type.levels.body.large,
|
|
11
|
-
color: colors.licorice500,
|
|
12
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
13
|
-
});
|
|
8
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
14
9
|
|
|
15
10
|
const StyledAccentIcon = styled(AccentIcon)({
|
|
16
11
|
marginRight: space.s,
|
|
@@ -24,7 +19,15 @@ export default () => {
|
|
|
24
19
|
<SidePanel {...panelProps}>
|
|
25
20
|
<Flex alignItems="center" paddingY="s" paddingX="s">
|
|
26
21
|
<StyledAccentIcon icon={rocketIcon} />
|
|
27
|
-
<
|
|
22
|
+
<Text
|
|
23
|
+
as="h3"
|
|
24
|
+
typeLevel="body.large"
|
|
25
|
+
color="licorice500"
|
|
26
|
+
fontWeight="bold"
|
|
27
|
+
{...labelProps}
|
|
28
|
+
>
|
|
29
|
+
Tasks Panel
|
|
30
|
+
</Text>
|
|
28
31
|
</Flex>
|
|
29
32
|
</SidePanel>
|
|
30
33
|
</HStack>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {colors, type} from '@workday/canvas-kit-react/tokens';
|
|
3
2
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
3
|
import {
|
|
5
4
|
SidePanel,
|
|
@@ -7,18 +6,13 @@ import {
|
|
|
7
6
|
SidePanelTransitionStates,
|
|
8
7
|
} from '@workday/canvas-kit-preview-react/side-panel';
|
|
9
8
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
10
|
-
import {
|
|
9
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
10
|
+
import {CanvasProvider} from '@workday/canvas-kit-react/common';
|
|
11
11
|
import {AccentIcon} from '@workday/canvas-kit-react/icon';
|
|
12
12
|
import {rocketIcon} from '@workday/canvas-accent-icons-web';
|
|
13
13
|
// local helper hook for setting content direction;
|
|
14
14
|
import {useDirection} from './useDirection';
|
|
15
15
|
|
|
16
|
-
const StyledHeader = styled('h3')({
|
|
17
|
-
...type.levels.body.large,
|
|
18
|
-
color: colors.licorice500,
|
|
19
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
20
|
-
});
|
|
21
|
-
|
|
22
16
|
export default () => {
|
|
23
17
|
const {direction, toggleDirection} = useDirection();
|
|
24
18
|
const {expanded, panelProps, labelProps, controlProps} = useSidePanel();
|
|
@@ -36,7 +30,15 @@ export default () => {
|
|
|
36
30
|
<Flex marginInlineEnd="s">
|
|
37
31
|
<AccentIcon icon={rocketIcon} />
|
|
38
32
|
</Flex>
|
|
39
|
-
<
|
|
33
|
+
<Text
|
|
34
|
+
as="h3"
|
|
35
|
+
typeLevel="body.large"
|
|
36
|
+
color="licorice500"
|
|
37
|
+
fontWeight="bold"
|
|
38
|
+
{...labelProps}
|
|
39
|
+
>
|
|
40
|
+
Tasks Panel
|
|
41
|
+
</Text>
|
|
40
42
|
</Flex>
|
|
41
43
|
)}
|
|
42
44
|
</SidePanel>
|
|
@@ -5,15 +5,8 @@ import {
|
|
|
5
5
|
SidePanelTransitionStates,
|
|
6
6
|
} from '@workday/canvas-kit-preview-react/side-panel';
|
|
7
7
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
8
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
9
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
9
|
-
import {colors, type} from '@workday/canvas-kit-react/tokens';
|
|
10
|
-
import {styled} from '@workday/canvas-kit-react/common';
|
|
11
|
-
|
|
12
|
-
const StyledHeader = styled('h3')({
|
|
13
|
-
...type.levels.body.large,
|
|
14
|
-
color: colors.licorice500,
|
|
15
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
16
|
-
});
|
|
17
10
|
|
|
18
11
|
export default () => {
|
|
19
12
|
const {expanded, panelProps, labelProps, controlProps} = useSidePanel({initialExpanded: false});
|
|
@@ -33,7 +26,15 @@ export default () => {
|
|
|
33
26
|
>
|
|
34
27
|
{panelState === 'expanded' && (
|
|
35
28
|
<Flex alignItems="center" paddingY="s" paddingX="s">
|
|
36
|
-
<
|
|
29
|
+
<Text
|
|
30
|
+
as="h3"
|
|
31
|
+
typeLevel="body.large"
|
|
32
|
+
color="licorice500"
|
|
33
|
+
fontWeight="bold"
|
|
34
|
+
{...labelProps}
|
|
35
|
+
>
|
|
36
|
+
Tasks Panel
|
|
37
|
+
</Text>
|
|
37
38
|
</Flex>
|
|
38
39
|
)}
|
|
39
40
|
</SidePanel>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {colors, type} from '@workday/canvas-kit-react/tokens';
|
|
3
2
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
3
|
import {
|
|
5
4
|
SidePanel,
|
|
@@ -7,16 +6,11 @@ import {
|
|
|
7
6
|
SidePanelTransitionStates,
|
|
8
7
|
} from '@workday/canvas-kit-preview-react/side-panel';
|
|
9
8
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
9
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
10
10
|
import {CanvasProvider, styled} from '@workday/canvas-kit-react/common';
|
|
11
11
|
// local helper hook for setting content direction;
|
|
12
12
|
import {useDirection} from './useDirection';
|
|
13
13
|
|
|
14
|
-
const StyledHeader = styled('h3')({
|
|
15
|
-
...type.levels.body.large,
|
|
16
|
-
color: colors.licorice500,
|
|
17
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
14
|
const StyledSidePanel = styled(SidePanel)({
|
|
21
15
|
marginLeft: 'auto',
|
|
22
16
|
});
|
|
@@ -32,7 +26,15 @@ const RightPanel = () => {
|
|
|
32
26
|
<SidePanel.ToggleButton {...controlProps} />
|
|
33
27
|
{panelState === 'expanded' && (
|
|
34
28
|
<Flex alignItems="center" justifyContent="flex-end" paddingY="s" paddingX="s">
|
|
35
|
-
<
|
|
29
|
+
<Text
|
|
30
|
+
as="h3"
|
|
31
|
+
typeLevel="body.large"
|
|
32
|
+
color="licorice500"
|
|
33
|
+
fontWeight="bold"
|
|
34
|
+
{...labelProps}
|
|
35
|
+
>
|
|
36
|
+
Tasks Panel
|
|
37
|
+
</Text>
|
|
36
38
|
</Flex>
|
|
37
39
|
)}
|
|
38
40
|
</StyledSidePanel>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {colors, type} from '@workday/canvas-kit-react/tokens';
|
|
3
2
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
3
|
import {
|
|
5
4
|
SidePanel,
|
|
@@ -7,16 +6,11 @@ import {
|
|
|
7
6
|
SidePanelTransitionStates,
|
|
8
7
|
} from '@workday/canvas-kit-preview-react/side-panel';
|
|
9
8
|
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
10
|
-
import {
|
|
9
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
10
|
+
import {CanvasProvider} from '@workday/canvas-kit-react/common';
|
|
11
11
|
// local helper hook for setting content direction;
|
|
12
12
|
import {useDirection} from './useDirection';
|
|
13
13
|
|
|
14
|
-
const StyledHeader = styled('h3')({
|
|
15
|
-
...type.levels.body.large,
|
|
16
|
-
color: colors.licorice500,
|
|
17
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
14
|
export default () => {
|
|
21
15
|
const {direction, toggleDirection} = useDirection();
|
|
22
16
|
const {expanded, panelProps, labelProps, controlProps} = useSidePanel();
|
|
@@ -31,7 +25,15 @@ export default () => {
|
|
|
31
25
|
<SidePanel.ToggleButton {...controlProps} />
|
|
32
26
|
{panelState === 'expanded' && (
|
|
33
27
|
<Flex alignItems="center" paddingY="s" paddingX="s">
|
|
34
|
-
<
|
|
28
|
+
<Text
|
|
29
|
+
as="h3"
|
|
30
|
+
typeLevel="body.large"
|
|
31
|
+
color="licorice500"
|
|
32
|
+
fontWeight="bold"
|
|
33
|
+
{...labelProps}
|
|
34
|
+
>
|
|
35
|
+
Alternate Panel
|
|
36
|
+
</Text>
|
|
35
37
|
</Flex>
|
|
36
38
|
)}
|
|
37
39
|
</SidePanel>
|
|
@@ -5,9 +5,10 @@ import React from 'react';
|
|
|
5
5
|
import {TextArea} from '@workday/canvas-kit-preview-react/text-area';
|
|
6
6
|
import {useThemedRing} from '@workday/canvas-kit-labs-react/common';
|
|
7
7
|
import {space, colors} from '@workday/canvas-kit-react/tokens';
|
|
8
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
8
9
|
|
|
9
10
|
export default () => {
|
|
10
|
-
const [value, setValue] = React.useState('');
|
|
11
|
+
const [value, setValue] = React.useState('Hello');
|
|
11
12
|
|
|
12
13
|
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
13
14
|
setValue(event.target.value.slice(0, 10));
|
|
@@ -30,7 +31,7 @@ export default () => {
|
|
|
30
31
|
<TextArea.Field css={alertStyles} onChange={handleChange} value={value} />
|
|
31
32
|
<TextArea.Hint paddingTop={space.xxs}>
|
|
32
33
|
<strong>Character Limit: </strong>
|
|
33
|
-
<
|
|
34
|
+
<Text color={hintColor}>{10 - value.length} Left</Text>
|
|
34
35
|
</TextArea.Hint>
|
|
35
36
|
</TextArea>
|
|
36
37
|
);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {createComponent, styled} from '@workday/canvas-kit-react/common';
|
|
3
3
|
|
|
4
|
-
import {colors, gradients, space
|
|
4
|
+
import {colors, gradients, space} from '@workday/canvas-kit-react/tokens';
|
|
5
5
|
|
|
6
6
|
import {HStack, HStackProps, StackSpacing} from '@workday/canvas-kit-react/layout';
|
|
7
7
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
8
8
|
import {justifyIcon, notificationsIcon} from '@workday/canvas-system-icons-web';
|
|
9
|
+
import {Heading} from '@workday/canvas-kit-react/text';
|
|
9
10
|
|
|
10
11
|
interface HeaderItemProps extends Omit<HStackProps, 'spacing'> {
|
|
11
12
|
spacing?: StackSpacing;
|
|
@@ -31,9 +32,18 @@ const PageHeaderItem = createComponent('div')({
|
|
|
31
32
|
const PageHeaderTitle = createComponent('h2')({
|
|
32
33
|
displayName: 'PageHeader.Title',
|
|
33
34
|
Component: ({children, ...props}, ref, Element) => (
|
|
34
|
-
<
|
|
35
|
+
<Heading
|
|
36
|
+
as={Element}
|
|
37
|
+
ref={ref}
|
|
38
|
+
size="medium"
|
|
39
|
+
variant="inverse"
|
|
40
|
+
padding={`${space.xs} 0`}
|
|
41
|
+
margin={0}
|
|
42
|
+
whiteSpace="nowrap"
|
|
43
|
+
{...props}
|
|
44
|
+
>
|
|
35
45
|
{children}
|
|
36
|
-
</
|
|
46
|
+
</Heading>
|
|
37
47
|
),
|
|
38
48
|
});
|
|
39
49
|
|
|
@@ -53,11 +63,3 @@ const Header = styled('header')({
|
|
|
53
63
|
alignItems: 'center',
|
|
54
64
|
justifyContent: 'space-between',
|
|
55
65
|
});
|
|
56
|
-
|
|
57
|
-
const Title = styled('h2')({
|
|
58
|
-
...type.levels.heading.medium,
|
|
59
|
-
color: colors.frenchVanilla100,
|
|
60
|
-
padding: `${space.xs} 0`,
|
|
61
|
-
margin: 0,
|
|
62
|
-
whiteSpace: 'nowrap',
|
|
63
|
-
});
|
|
@@ -3,12 +3,14 @@ import {Box} from '@workday/canvas-kit-react/layout';
|
|
|
3
3
|
import As from './examples/As';
|
|
4
4
|
import Border from './examples/Border';
|
|
5
5
|
import Color from './examples/Color';
|
|
6
|
+
import Font from './examples/Font';
|
|
6
7
|
import Depth from './examples/Depth';
|
|
7
8
|
import FlexItem from './examples/FlexItem';
|
|
8
9
|
import Layout from './examples/Layout';
|
|
9
10
|
import Position from './examples/Position';
|
|
10
11
|
import Ref from './examples/Ref';
|
|
11
12
|
import Space from './examples/Space';
|
|
13
|
+
import Text from './examples/Text';
|
|
12
14
|
// props tables
|
|
13
15
|
import {
|
|
14
16
|
BoxBorder,
|
|
@@ -60,16 +62,20 @@ is highly flexible, and its primary purpose is to build other components.
|
|
|
60
62
|
- [Example](#example-2)
|
|
61
63
|
- [Flex Item](#flex-item)
|
|
62
64
|
- [Example](#example-3)
|
|
63
|
-
- [
|
|
65
|
+
- [Font](#font)
|
|
64
66
|
- [Example](#example-4)
|
|
67
|
+
- [Layout](#layout)
|
|
68
|
+
- [Example](#example-5)
|
|
65
69
|
- [Position](#position)
|
|
66
70
|
- [Position Logical Props](#position-logical-props)
|
|
67
71
|
- [Position Standard Props](#position-standard-props)
|
|
68
|
-
- [Example](#example-
|
|
72
|
+
- [Example](#example-6)
|
|
69
73
|
- [Space](#space)
|
|
70
74
|
- [Space Logical Props](#space-logical-props)
|
|
71
75
|
- [Space Standard Props](#space-standard-props)
|
|
72
|
-
- [Example](#example-
|
|
76
|
+
- [Example](#example-7)
|
|
77
|
+
- [Text](#space)
|
|
78
|
+
- [Example](#example-8)
|
|
73
79
|
- [Exhaustive Style Prop List](#exhaustive-style-prop-list)
|
|
74
80
|
- [Border Props](#border-props)
|
|
75
81
|
- [Color Props](#color-props)
|
|
@@ -273,6 +279,16 @@ table for flex item props:
|
|
|
273
279
|
|
|
274
280
|
---
|
|
275
281
|
|
|
282
|
+
### Font
|
|
283
|
+
|
|
284
|
+
Font style props allow you to adjust the font family, style, size or weight of components.
|
|
285
|
+
|
|
286
|
+
#### Example
|
|
287
|
+
|
|
288
|
+
<ExampleCodeBlock code={Font} />
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
276
292
|
### Layout
|
|
277
293
|
|
|
278
294
|
Layout style props allow you to adjust the display, dimensions, and overflow of a component. These
|
|
@@ -372,6 +388,17 @@ Bidirectional support will only affect `marginLeft`, `marginRight`, `paddingLeft
|
|
|
372
388
|
|
|
373
389
|
<ExampleCodeBlock code={Space} />
|
|
374
390
|
|
|
391
|
+
### Text
|
|
392
|
+
|
|
393
|
+
Text style props allow you to modify text using props such as `textDecoration` or `textTransform` or
|
|
394
|
+
set line styles by `lineHeight` or `letterSpacing`, etc.
|
|
395
|
+
|
|
396
|
+
#### Example
|
|
397
|
+
|
|
398
|
+
<ExampleCodeBlock code={Text} />
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
375
402
|
## Exhaustive Style Prop List
|
|
376
403
|
|
|
377
404
|
Below is an exhaustive list of `Box` style props divided by category.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {Grid, GridItem} from '@workday/canvas-kit-react/layout';
|
|
2
|
+
// examples
|
|
3
|
+
import GridLayout from './examples/Grid/GridLayout';
|
|
4
|
+
import UIExample from './examples/Grid/UIExample';
|
|
5
|
+
import GridLayoutInteractive from './examples/Grid/GridLayoutInteractive';
|
|
6
|
+
import {GridStyle} from './examples/PropTables.splitprops.tsx';
|
|
7
|
+
import {GridStyleProps} from '../lib/utils/grid';
|
|
8
|
+
import {GridItemStyleProps} from '../lib/utils/gridItem';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Canvas Kit Grid
|
|
12
|
+
|
|
13
|
+
`Grid` is a low-level layout component that provides a common, ergonomic API for building
|
|
14
|
+
two-dimensional layouts (rows and columns) with
|
|
15
|
+
[CSS Grid](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Grids).
|
|
16
|
+
|
|
17
|
+
If you want to see how Flexbox and Grid can
|
|
18
|
+
[work together](https://css-tricks.com/css-grid-replace-flexbox/).
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
yarn add @workday/canvas-kit-react
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Basic Example
|
|
29
|
+
|
|
30
|
+
Below is a basic layout built with `Grid`. We created four components: `Header`, `SideBar`,
|
|
31
|
+
`BodyContent` and `Footer`. We also used those names for their respective `gridArea` props. Then we
|
|
32
|
+
can use those names in the parent component, `UIExample`, to organize the UI however we want. This
|
|
33
|
+
allows the parent container to control how its children render. For page layouts, Workday typically
|
|
34
|
+
uses a 12 column grid. In the example below, the Sidebar is 3 columns and the Body Content is 9
|
|
35
|
+
columns.
|
|
36
|
+
|
|
37
|
+
> Note: You can learn more about CSS Grid's `gridArea` and `gridTemplateAreas`
|
|
38
|
+
> [here](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas).
|
|
39
|
+
|
|
40
|
+
<ExampleCodeBlock code={UIExample} />
|
|
41
|
+
|
|
42
|
+
### Using Grid Items
|
|
43
|
+
|
|
44
|
+
In the example above we nested `Grid` components to create our layout, and we controlled the layout
|
|
45
|
+
structure from the top-level `Grid` container. That's a perfectly valid approach. However, we can
|
|
46
|
+
also use `Grid.Item` components to allow child cells to have more control. While any direct child of
|
|
47
|
+
a `Grid` component is implicitly a grid item, `Grid.Item` provides special CSS Grid Item style props
|
|
48
|
+
that allow you to have more control over how and where each item renders.
|
|
49
|
+
|
|
50
|
+
To demonstrate this behavior, the example below has a `Grid` container with nine cells. The eight
|
|
51
|
+
`soap500` cells are `Grid` components, and the `peach300` cell is a `Grid.Item`. We can use the
|
|
52
|
+
`Grid.Item` style props `gridRowStart` and `gridColumnStart` to manipulate where the cell renders.
|
|
53
|
+
You can use the `Row` and `Column` buttons to manipulate these props and see the `Grid.Item`'s
|
|
54
|
+
position adjust accordingly.
|
|
55
|
+
|
|
56
|
+
> Note: This example is solely intended to demonstrate the `Grid.Item`'s functionality and is NOT
|
|
57
|
+
> considered an accessibility best practice. Visually reordering content does not change the order
|
|
58
|
+
> it is read by a screen reader or the tab order. You can learn more about CSS Grid layout and
|
|
59
|
+
> accessibility
|
|
60
|
+
> [here](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility).
|
|
61
|
+
|
|
62
|
+
<ExampleCodeBlock code={GridLayoutInteractive} />
|
|
63
|
+
|
|
64
|
+
Let's look at another `Grid.Item` example. Below, we have a `Grid` container with two rows: one with
|
|
65
|
+
seven elements and the other with two elements. This example is to show how a user can use the
|
|
66
|
+
`<Grid.Item/>` component to wrap a `Grid` component. This would allow a user to have access to the
|
|
67
|
+
child props of `Grid.Item` to place a layout where needed. The row with elements 3 - 7 is put before
|
|
68
|
+
the 1 & 2 elements since that layout is wrapped by the `Grid.Item` component.
|
|
69
|
+
|
|
70
|
+
<ExampleCodeBlock code={GridLayout} />
|
|
71
|
+
|
|
72
|
+
### Using Grid vs. Flex vs. Box
|
|
73
|
+
|
|
74
|
+
`Box` is the underlying layout component that `Grid` and `Flex` are built upon. So `Grid` and `Flex`
|
|
75
|
+
have access to all `BoxProps`. But `Grid` and `Flex` have their own specific style props that map to
|
|
76
|
+
CSS Grid and Flexbox properties, respectively. When using these components to build layouts, it is
|
|
77
|
+
not a matter of choosing `Grid` _or_ `Flex` _or_ `Box`, but rather deciding how to use them
|
|
78
|
+
together. They are intended to be complementary not exclusionary. With that said, here are some
|
|
79
|
+
general rules for when to use which:
|
|
80
|
+
|
|
81
|
+
- Use `Grid` for building **two-dimensional** layouts (rows AND columns).
|
|
82
|
+
- Use `Flex` for building **one-dimensional** layouts (a row OR a column).
|
|
83
|
+
- Use `Box` for generic containers that don't need CSS Flexbox or Grid.
|
|
84
|
+
|
|
85
|
+
## Components
|
|
86
|
+
|
|
87
|
+
### Grid
|
|
88
|
+
|
|
89
|
+
Grid is a container component for creating two-dimensional layouts with CSS Grid. It has special
|
|
90
|
+
style props that map to CSS Grid style properties to provide a common, ergonomic API for building
|
|
91
|
+
layouts.
|
|
92
|
+
|
|
93
|
+
#### Usage
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Grid grid gridTemplateColumns="1fr 2fr 1fr" gridGap={space.s}>
|
|
97
|
+
<div>Implicit grid item 1</div>
|
|
98
|
+
<div>Implicit grid item 2</div>
|
|
99
|
+
<div>Implicit grid item 3</div>
|
|
100
|
+
</Grid>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Props
|
|
104
|
+
|
|
105
|
+
As previously mentioned, `Grid` is built on top of `Box` and has access to all its props, including
|
|
106
|
+
[grid container properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout#the_grid_container)
|
|
107
|
+
through style props as well. Here are the grid container props:
|
|
108
|
+
|
|
109
|
+
<ArgsTable of={GridStyleProps} />
|
|
110
|
+
|
|
111
|
+
### Grid.Item
|
|
112
|
+
|
|
113
|
+
`Grid.Item` is a subcomponent of Grid. It has specific grid item style props that map to CSS Grid
|
|
114
|
+
Item properties. This allows you greater control over how child components render in your layout.
|
|
115
|
+
|
|
116
|
+
#### Usage
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<Grid gridGap={space.s}>
|
|
120
|
+
<Grid.Item gridColumn="1 / span 2">First item</Grid.Item>
|
|
121
|
+
<Grid.Item gridRow="1 / span 2">Second item</Grid.Item>
|
|
122
|
+
<Grid.Item gridColumn="1 / span 2" gridRow="2">
|
|
123
|
+
Third item
|
|
124
|
+
</Grid.Item>
|
|
125
|
+
</Grid>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### Props
|
|
129
|
+
|
|
130
|
+
<ArgsTable of={GridItemStyleProps} />
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {Flex, Box} from '@workday/canvas-kit-react/layout';
|
|
3
3
|
import {PrimaryButton, SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
// temporary placeholder until type components are added to canvas-kit
|
|
7
|
-
const H3 = props => (
|
|
8
|
-
<h3
|
|
9
|
-
style={{
|
|
10
|
-
...type.levels.body.large,
|
|
11
|
-
margin: 0,
|
|
12
|
-
fontWeight: type.properties.fontWeights.bold,
|
|
13
|
-
}}
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const Body = props => <p style={{...type.levels.body.small, margin: 0}} {...props} />;
|
|
4
|
+
import {BodyText} from '@workday/canvas-kit-react/text';
|
|
19
5
|
|
|
20
6
|
export default () => {
|
|
21
7
|
const [isComplete, setIsComplete] = React.useState(false);
|
|
@@ -29,10 +15,12 @@ export default () => {
|
|
|
29
15
|
borderColor="soap400"
|
|
30
16
|
maxWidth={600}
|
|
31
17
|
>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
<BodyText as="h3" size="large" fontWeight="bold" margin={0}>
|
|
19
|
+
Learn about Flex {isComplete && '🥳'}
|
|
20
|
+
</BodyText>
|
|
21
|
+
<BodyText size="small" margin={0} paddingY="s">
|
|
22
|
+
Complete this task when you have a functional understanding of Flex.
|
|
23
|
+
</BodyText>
|
|
36
24
|
<Flex justifyContent="flex-end">
|
|
37
25
|
<Box marginRight="xxs">
|
|
38
26
|
<PrimaryButton onClick={() => setIsComplete(true)}>Complete</PrimaryButton>
|