@workday/canvas-kit-docs 8.0.0-alpha.150-next.2 → 8.0.0-alpha.155-next.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.
Files changed (29) hide show
  1. package/dist/mdx/8.0-UPGRADE-GUIDE.mdx +28 -2
  2. package/dist/mdx/preview-react/_examples/examples/SidePanelWithOverlay.tsx +5 -8
  3. package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +12 -9
  4. package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +11 -9
  5. package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +10 -9
  6. package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +10 -8
  7. package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +11 -9
  8. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +3 -2
  9. package/dist/mdx/react/_examples/examples/PageHeader.tsx +13 -11
  10. package/dist/mdx/react/layout/Box.mdx +30 -3
  11. package/dist/mdx/react/layout/examples/Flex/FlexCard.tsx +7 -19
  12. package/dist/mdx/react/layout/examples/Flex/Usage.tsx +31 -48
  13. package/dist/mdx/react/layout/examples/Font.tsx +21 -0
  14. package/dist/mdx/react/layout/examples/Stack/HStackCards.tsx +7 -3
  15. package/dist/mdx/react/layout/examples/Stack/StackCard.tsx +6 -4
  16. package/dist/mdx/react/layout/examples/Stack/VStackCards.tsx +7 -3
  17. package/dist/mdx/react/layout/examples/Text.tsx +32 -0
  18. package/dist/mdx/react/radio/examples/Basic.tsx +4 -6
  19. package/dist/mdx/react/radio/examples/NoValue.tsx +2 -2
  20. package/dist/mdx/react/skeleton/examples/Simulation.tsx +4 -8
  21. package/dist/mdx/react/text/PropTables.splitprops.tsx +15 -0
  22. package/dist/mdx/react/text/Text.mdx +129 -0
  23. package/dist/mdx/react/text/examples/BodyText.tsx +10 -0
  24. package/dist/mdx/react/text/examples/Heading.tsx +16 -0
  25. package/dist/mdx/react/text/examples/Label.tsx +14 -0
  26. package/dist/mdx/react/text/examples/Subtext.tsx +10 -0
  27. package/dist/mdx/react/text/examples/Text.tsx +23 -0
  28. package/dist/mdx/react/text/examples/Title.tsx +16 -0
  29. package/package.json +3 -3
@@ -1,10 +1,12 @@
1
- # Canvas Kit 7.0 Upgrade Guide
1
+ # Canvas Kit 8.0 Upgrade Guide
2
2
 
3
- This guide contains breaking changes in Canvas Kit v7. Please
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 {colors, depth, type} from '@workday/canvas-kit-react/tokens';
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
- <StyledHeader {...labelProps}>Alternate Panel</StyledHeader>
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 {colors, space, type} from '@workday/canvas-kit-react/tokens';
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 {styled} from '@workday/canvas-kit-react/common';
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
- <StyledHeader {...labelProps}>Tasks Panel</StyledHeader>
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 {CanvasProvider, styled} from '@workday/canvas-kit-react/common';
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
- <StyledHeader {...labelProps}>Tasks Panel</StyledHeader>
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
- <StyledHeader {...labelProps}>Tasks Panel</StyledHeader>
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
- <StyledHeader {...labelProps}>Tasks Panel</StyledHeader>
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 {CanvasProvider, styled} from '@workday/canvas-kit-react/common';
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
- <StyledHeader {...labelProps}>Alternate Panel</StyledHeader>
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
- <span css={{color: hintColor}}>{10 - value.length} Left</span>
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, type} from '@workday/canvas-kit-react/tokens';
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
- <Title ref={ref} as={Element} {...props}>
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
- </Title>
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
- - [Layout](#layout)
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-5)
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-6)
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.
@@ -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 {type} from '@workday/canvas-kit-react/tokens';
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
- <H3>Learn about Flex {isComplete && '🥳'}</H3>
33
- <Box paddingY="s">
34
- <Body>Complete this task when you have a functional understanding of Flex.</Body>
35
- </Box>
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>
@@ -1,23 +1,6 @@
1
1
  import * as React from 'react';
2
- import {Flex, FlexProps, Box} from '@workday/canvas-kit-react/layout';
3
- import {type} from '@workday/canvas-kit-react/tokens';
4
-
5
- // temporary placeholder until type components are added to canvas-kit
6
- const H3 = props => (
7
- <h3
8
- style={{
9
- ...type.levels.body.large,
10
- ...type.variants.inverse,
11
- margin: 0,
12
- fontWeight: type.properties.fontWeights.bold,
13
- }}
14
- {...props}
15
- />
16
- );
17
-
18
- const Body = props => (
19
- <p style={{...type.levels.body.small, ...type.variants.inverse, margin: 0}} {...props} />
20
- );
2
+ import {Flex, FlexProps} from '@workday/canvas-kit-react/layout';
3
+ import {BodyText} from '@workday/canvas-kit-react/text';
21
4
 
22
5
  const Card = ({children, ...props}: FlexProps) => (
23
6
  <Flex
@@ -40,41 +23,41 @@ export default () => {
40
23
  <h2>Canvas Principles</h2>
41
24
  <Flex alignItems="stretch" flexWrap="wrap">
42
25
  <Card backgroundColor="blueberry400">
43
- <H3>Empower over Enforce</H3>
44
- <Box paddingY="xs">
45
- <Body>
46
- Encourage our user's expression. Stay out of the way and provide them with the tools
47
- and resources to build their vision.
48
- </Body>
49
- </Box>
26
+ <BodyText as="h3" size="large" variant="inverse" fontWeight="bold" margin={0}>
27
+ Empower over Enforce
28
+ </BodyText>
29
+ <BodyText size="small" variant="inverse" margin={0} paddingY="xs">
30
+ Encourage our user's expression. Stay out of the way and provide them with the tools and
31
+ resources to build their vision.
32
+ </BodyText>
50
33
  </Card>
51
34
  <Card backgroundColor="juicyPear500">
52
- <H3>Evolution over Perfection</H3>
53
- <Box paddingY="xs">
54
- <Body>
55
- Nothing is ever perfect – embrace that. Make educated assumptions, validate and test
56
- our decisions, then iterate! Aim of continous rather than perfect solutions.
57
- </Body>
58
- </Box>
35
+ <BodyText as="h3" size="large" variant="inverse" fontWeight="bold" margin={0}>
36
+ Evolution over Perfection
37
+ </BodyText>
38
+ <BodyText size="small" variant="inverse" margin={0} paddingY="xs">
39
+ Nothing is ever perfect embrace that. Make educated assumptions, validate and test our
40
+ decisions, then iterate! Aim of continous rather than perfect solutions.
41
+ </BodyText>
59
42
  </Card>
60
43
  <Card backgroundColor="chiliMango400">
61
- <H3>Simple over Clever</H3>
62
- <Box paddingY="xs">
63
- <Body>
64
- Simple solutions invite the user in - clever solutions invite complexity. Make the
65
- system easy and predictable, and progressively disclose advanced functionality.
66
- </Body>
67
- </Box>
44
+ <BodyText as="h3" size="large" variant="inverse" fontWeight="bold" margin={0}>
45
+ Simple over Clever
46
+ </BodyText>
47
+ <BodyText size="small" variant="inverse" margin={0} paddingY="xs">
48
+ Simple solutions invite the user in - clever solutions invite complexity. Make the
49
+ system easy and predictable, and progressively disclose advanced functionality.
50
+ </BodyText>
68
51
  </Card>
69
52
  <Card backgroundColor="blackberry400">
70
- <H3>Everyone over Every One</H3>
71
- <Box paddingY="xs">
72
- <Body>
73
- Each piece of the system is designs and built to be accessible, while still providing
74
- the best experience for all consumers. But not if something is focused on a single use
75
- case and negates the usability for others.
76
- </Body>
77
- </Box>
53
+ <BodyText as="h3" size="large" variant="inverse" fontWeight="bold" margin={0}>
54
+ Everyone over Every One
55
+ </BodyText>
56
+ <BodyText size="small" variant="inverse" margin={0} paddingY="xs">
57
+ Each piece of the system is designs and built to be accessible, while still providing
58
+ the best experience for all consumers. But not if something is focused on a single use
59
+ case and negates the usability for others.
60
+ </BodyText>
78
61
  </Card>
79
62
  </Flex>
80
63
  </Flex>
@@ -0,0 +1,21 @@
1
+ import * as React from 'react';
2
+ import {Box} from '@workday/canvas-kit-react/layout';
3
+
4
+ export default () => (
5
+ <>
6
+ <Box fontSize={14} fontWeight="bold" border="1px solid black" margin="xxs" padding="s">
7
+ Default font, 14px, medium weight
8
+ </Box>
9
+ <Box
10
+ fontFamily="monospace"
11
+ fontSize={12}
12
+ fontWeight="bold"
13
+ fontStyle="italic"
14
+ border="1px solid black"
15
+ margin="xxs"
16
+ padding="s"
17
+ >
18
+ Monospace font, 12px, italic style
19
+ </Box>
20
+ </>
21
+ );
@@ -1,14 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import {HStack, Stack, Flex, Box} from '@workday/canvas-kit-react/layout';
3
3
  import {TertiaryButton} from '@workday/canvas-kit-react/button';
4
- import {type} from '@workday/canvas-kit-react/tokens';
4
+ import {BodyText, Heading} from '@workday/canvas-kit-react/text';
5
5
 
6
6
  const Card = ({heading = '', body = ''}) => (
7
7
  <Flex flex={1} flexBasis="auto" depth={1} padding="s" backgroundColor="frenchVanilla100">
8
8
  <Stack flexDirection="column" spacing="xs">
9
- <h3 style={{...type.levels.heading.small, margin: 0}}>{heading}</h3>
9
+ <Heading as="h3" size="small" margin={0}>
10
+ {heading}
11
+ </Heading>
10
12
  <Box maxWidth={240}>
11
- <p style={{...type.levels.body.small, margin: 0}}>{body}</p>
13
+ <BodyText size="small" margin={0}>
14
+ {body}
15
+ </BodyText>
12
16
  </Box>
13
17
  <Box>
14
18
  <TertiaryButton>Add to order</TertiaryButton>
@@ -1,19 +1,21 @@
1
1
  import * as React from 'react';
2
2
  import {Stack, Flex} from '@workday/canvas-kit-react/layout';
3
3
  import {TertiaryButton} from '@workday/canvas-kit-react/button';
4
- import {type} from '@workday/canvas-kit-react/tokens';
4
+ import {BodyText, Heading} from '@workday/canvas-kit-react/text';
5
5
 
6
6
  export default () => {
7
7
  return (
8
8
  <Flex backgroundColor="soap100" alignItems="flex-start" padding="s">
9
9
  <Flex depth={1} padding="s" backgroundColor="frenchVanilla100">
10
10
  <Stack flexDirection="column" spacing="xs">
11
- <h3 style={{...type.levels.heading.small, margin: 0}}>Stack</h3>
12
- <span style={{...type.levels.body.small}}>
11
+ <Heading as="h3" size="small" margin={0}>
12
+ Stack
13
+ </Heading>
14
+ <BodyText size="small" margin={0}>
13
15
  Stack provides a simple API for managing consistent space between elements in
14
16
  one-dimensional layouts. In this Card example, we are setting extra-small spacing the
15
17
  heading, body text, and button elements.
16
- </span>
18
+ </BodyText>
17
19
  <Flex>
18
20
  <TertiaryButton>Learn more</TertiaryButton>
19
21
  </Flex>
@@ -1,13 +1,17 @@
1
1
  import * as React from 'react';
2
2
  import {VStack, Stack, Flex} from '@workday/canvas-kit-react/layout';
3
3
  import {TertiaryButton} from '@workday/canvas-kit-react/button';
4
- import {type} from '@workday/canvas-kit-react/tokens';
4
+ import {BodyText, Heading} from '@workday/canvas-kit-react/text';
5
5
 
6
6
  const Card = ({heading = '', body = ''}) => (
7
7
  <Flex flex={1} flexBasis="auto" depth={1} padding="s" backgroundColor="frenchVanilla100">
8
8
  <Stack flexDirection="column" spacing="xs">
9
- <h3 style={{...type.levels.heading.small, margin: 0}}>{heading}</h3>
10
- <span style={{...type.levels.body.small}}>{body}</span>
9
+ <Heading as="h3" size="small" margin={0}>
10
+ {heading}
11
+ </Heading>
12
+ <BodyText size="small" margin={0}>
13
+ {body}
14
+ </BodyText>
11
15
  <Flex>
12
16
  <TertiaryButton>Add to order</TertiaryButton>
13
17
  </Flex>
@@ -0,0 +1,32 @@
1
+ import * as React from 'react';
2
+ import {Box} from '@workday/canvas-kit-react/layout';
3
+
4
+ const Card = props => <Box border="1px solid black" margin="xxs" padding="s" {...props} />;
5
+
6
+ export default () => (
7
+ <>
8
+ <Card
9
+ textAlign="center"
10
+ textDecoration="line-through"
11
+ textTransform="uppercase"
12
+ letterSpacing="0.05em"
13
+ lineHeight="2em"
14
+ wordBreak="break-all"
15
+ whiteSpace="break-spaces"
16
+ >
17
+ Centered text, uppercase, with line through, 0.05em letter-spacing, 2em line-height, with
18
+ breack-all and break-spaces.
19
+ </Card>
20
+ <Card
21
+ textAlign="left"
22
+ textDecoration="underline"
23
+ textTransform="lowercase"
24
+ letterSpacing="0.1em"
25
+ lineHeight="1em"
26
+ whiteSpace="nowrap"
27
+ >
28
+ Nowrap, Left-aligned text, with lowercase and underline, 0.1em letter-spacing, 1em
29
+ line-height,
30
+ </Card>
31
+ </>
32
+ );
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
+ import styled from '@emotion/styled';
2
3
  import {FormField} from '@workday/canvas-kit-react/form-field';
3
4
  import {Radio, RadioGroup} from '@workday/canvas-kit-react/radio';
4
- import styled from '@emotion/styled';
5
+ import {space} from '@workday/canvas-kit-react/tokens';
5
6
 
6
7
  export default () => {
7
8
  const [value, setValue] = React.useState<string | number>('deep-dish');
@@ -11,7 +12,7 @@ export default () => {
11
12
  };
12
13
 
13
14
  const StyledFormField = styled(FormField)({
14
- width: '161px',
15
+ width: space.xl,
15
16
  });
16
17
 
17
18
  return (
@@ -21,10 +22,7 @@ export default () => {
21
22
  <Radio label="Thin" value="thin" />
22
23
  <Radio label="Gluten free" value="gluten-free" />
23
24
  <Radio label="Cauliflower" value="cauliflower" />
24
- <Radio
25
- label="My favorite pizza crust flavor is butter because it's the best thing to put on bread"
26
- value="cauliflower"
27
- />
25
+ <Radio label="Butter - the best thing to put on bread" value="butter" />
28
26
  </RadioGroup>
29
27
  </StyledFormField>
30
28
  );
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import {FormField} from '@workday/canvas-kit-react/form-field';
3
3
  import {Radio, RadioGroup} from '@workday/canvas-kit-react/radio';
4
- import {type} from '@workday/canvas-kit-react/tokens';
4
+ import {Subtext} from '@workday/canvas-kit-react/text';
5
5
 
6
6
  export default () => {
7
7
  const [value, setValue] = React.useState<string | number>(0);
@@ -20,7 +20,7 @@ export default () => {
20
20
  <Radio label="Cauliflower" />
21
21
  </RadioGroup>
22
22
  </FormField>
23
- <p style={type.levels.subtext.large}>Value: {value}</p>
23
+ <Subtext size="large">Value: {value}</Subtext>
24
24
  </>
25
25
  );
26
26
  };
@@ -14,9 +14,10 @@ import {
14
14
  import {Box, Flex} from '@workday/canvas-kit-react/layout';
15
15
 
16
16
  import {Skeleton} from '@workday/canvas-kit-react/skeleton';
17
- import {borderRadius, space, type} from '@workday/canvas-kit-react/tokens';
17
+ import {borderRadius, space} from '@workday/canvas-kit-react/tokens';
18
18
  import {patternIcon} from '@workday/canvas-system-icons-web';
19
19
  import {StyledType} from '@workday/canvas-kit-react/common';
20
+ import {Heading} from '@workday/canvas-kit-react/text';
20
21
 
21
22
  const fadeOut = keyframes`
22
23
  from {
@@ -105,14 +106,9 @@ export default () => {
105
106
  <Box>
106
107
  <Flex alignItems="center" display="inline-flex" marginBottom="s">
107
108
  <SystemIconCircle icon={patternIcon} />
108
- <h3
109
- style={{
110
- ...type.levels.heading.small,
111
- margin: `0 0 0 ${space.xxs}`,
112
- }}
113
- >
109
+ <Heading as="h3" size="small" margin={`0 0 0 ${space.xxs}`}>
114
110
  Patterns
115
- </h3>
111
+ </Heading>
116
112
  </Flex>
117
113
  <p>
118
114
  Canvas Patterns classify and document reusable solutions built to respond to
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import {TextProps, TypeLabelProps, TypeLevelProps} from '@workday/canvas-kit-react/text';
3
+
4
+ // <ArgsTable of={Text} /> generates a very large props table given that
5
+ // Text includes BoxProps. Use this dummy component instead to
6
+ // limit the props shown.
7
+ export const TextComponent = (_: TextProps) => <div />;
8
+
9
+ // <ArgsTable of={Label} /> generates a props table with
10
+ // Text and Box props. Use this dummy component instead to limit the props shown.
11
+ export const LabelComponent = (_: TypeLabelProps) => <div />;
12
+
13
+ // <ArgsTable of={Heading} /> generates a props table with
14
+ // Text and Box props. Use this dummy component instead to limit the props shown.
15
+ export const TypeLevelComponent = (_: TypeLevelProps) => <div />;
@@ -0,0 +1,129 @@
1
+ import {Basic as BasicText} from './examples/Text';
2
+ import Label from './examples/Label';
3
+ import BodyText from './examples/BodyText';
4
+ import Heading from './examples/Heading';
5
+ import Subtext from './examples/Subtext';
6
+ import Title from './examples/Title';
7
+
8
+ import {TextComponent, LabelComponent, TypeLevelComponent} from './PropTables.splitprops.tsx';
9
+
10
+
11
+ # Canvas Kit React Text
12
+
13
+ `Text` is a group of text components that provide a common, ergonomic API to render text with
14
+ simplified usage of Canvas Kit type token.
15
+
16
+ ## Installation
17
+
18
+ ```sh
19
+ yarn add @workday/canvas-kit-react
20
+ ```
21
+
22
+ ## Text
23
+
24
+ ### Usage
25
+
26
+ `Text` is the base component that is used to render text in the UI. It is built off of our `Box`
27
+ component which allows the use of styles props such as `display`, `margin`, `padding` as well as the
28
+ most common type styles such as `fontWeight`, `fontSize` amongst others. This component is an
29
+ extension of our [type tokens](https://canvas.workdaydesign.com/tokens/type/#type-styles),
30
+ therefore, props like `typeLevel` and `variant` all exists.
31
+
32
+ By default `Text` component is a `span` element, but it's possible to override the element by
33
+ passing `as` prop.
34
+
35
+ ```tsx
36
+ <Text as="p" fontSize={14} fontWeight="medium">
37
+ Text here...
38
+ </Text>
39
+ ```
40
+
41
+ <ExampleCodeBlock code={BasicText} />
42
+
43
+ ### Text Props
44
+
45
+ As previously mentioned, `Text` is built on top of `Box` and has access to all its props. In
46
+ addition `Text` has its own props:
47
+
48
+ <ArgsTable of={TextComponent} />
49
+
50
+ ## LabelText
51
+
52
+ `LabelText` is a `label` element build based on the top of `Text` component with added ability to
53
+ add a cursor or disabled style.
54
+
55
+ ### Usage
56
+
57
+ ```tsx
58
+ <LabelText cursor="pointer" disabled={true}>
59
+ Text here...
60
+ </LabelText>
61
+ ```
62
+
63
+ <ExampleCodeBlock code={Label} />
64
+
65
+ ### LabelText Props
66
+
67
+ In addition to `Text` component props, `LabelText` has the following props:
68
+
69
+ <ArgsTable of={LabelComponent} />
70
+
71
+ ## Type Level Components
72
+
73
+ Type Level Components, `Subtext`, `BodyText`, `Heading` and `Title`, apply type token styles to text
74
+ element. Instead of passing type level token you can use one of Type Level Components, like in
75
+ example below:
76
+
77
+ ```tsx
78
+ // v7
79
+ <p css={{...type.levels.subtext.small}}>Small Subtext Text</p>
80
+
81
+ // v8
82
+ <Subtext size="small">Small Subtext Text</Subtext>
83
+ ```
84
+
85
+ ### Props
86
+
87
+ In addition to `Text` component props, each type level components has the following props:
88
+
89
+ <ArgsTable of={TypeLevelComponent} />
90
+
91
+ ### BodyText
92
+
93
+ `BodyText` component renders text with `type.levels.body[size]` styles.
94
+
95
+ ```tsx
96
+ <BodyText size="small">Small Body Text</BodyText>
97
+ ```
98
+
99
+ <ExampleCodeBlock code={BodyText} />
100
+
101
+ ### Heading
102
+
103
+ `Heading` component renders text with `type.levels.heading[size]` styles.
104
+
105
+ ```tsx
106
+ <Heading size="small">Small Heading Text</Heading>
107
+ ```
108
+
109
+ <ExampleCodeBlock code={Heading} />
110
+
111
+ ### Subtext
112
+
113
+ `Subtext` component renders text with `type.levels.subtext[size]` styles.
114
+
115
+ ```tsx
116
+ <Subtext size="small">Small Subtext Text</Subtext>
117
+ ```
118
+
119
+ <ExampleCodeBlock code={Subtext} />
120
+
121
+ ### Title
122
+
123
+ `Title` component renders text with `type.levels.title[size]` styles.
124
+
125
+ ```tsx
126
+ <Title size="small">Small Title Text</Title>
127
+ ```
128
+
129
+ <ExampleCodeBlock code={Title} />
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import {BodyText as BodyTextComponent} from '@workday/canvas-kit-react/text';
3
+
4
+ export default () => (
5
+ <>
6
+ <BodyTextComponent size="large">Large Body Text</BodyTextComponent>
7
+ <BodyTextComponent size="medium">Medium Body Text</BodyTextComponent>
8
+ <BodyTextComponent size="small">Small Body Text</BodyTextComponent>
9
+ </>
10
+ );
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import {Heading as HeadingComponent} from '@workday/canvas-kit-react/text';
3
+
4
+ export default () => (
5
+ <>
6
+ <HeadingComponent as="h4" size="large">
7
+ Large Heading Text
8
+ </HeadingComponent>
9
+ <HeadingComponent as="h5" size="medium">
10
+ Medium Heading Text
11
+ </HeadingComponent>
12
+ <HeadingComponent as="h6" size="small">
13
+ Small Heading Text
14
+ </HeadingComponent>
15
+ </>
16
+ );
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import {LabelText} from '@workday/canvas-kit-react/text';
3
+
4
+ export default () => (
5
+ <>
6
+ <LabelText marginBottom="s">Label</LabelText>
7
+ <LabelText cursor="pointer" marginBottom="s">
8
+ Label with pointer
9
+ </LabelText>
10
+ <LabelText disabled marginBottom="s">
11
+ Disabled Label
12
+ </LabelText>
13
+ </>
14
+ );
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import {Subtext as SubtextComponent} from '@workday/canvas-kit-react/text';
3
+
4
+ export default () => (
5
+ <>
6
+ <SubtextComponent size="large">Large Subtext</SubtextComponent>
7
+ <SubtextComponent size="medium">Medium Subtext</SubtextComponent>
8
+ <SubtextComponent size="small">Small Subtext</SubtextComponent>
9
+ </>
10
+ );
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+
3
+ import {type, typeColors} from '@workday/canvas-kit-react/tokens';
4
+ import {Box} from '@workday/canvas-kit-react';
5
+ import {Text} from '@workday/canvas-kit-react/text';
6
+
7
+ export default () => (
8
+ <Box>
9
+ <Text as="h4">Text as h4</Text>
10
+ <Text as="p" fontSize={14} fontWeight="regular" fontFamily="monospace">
11
+ Text with props passed
12
+ </Text>
13
+ <Text as="p" {...type.levels.subtext.large}>
14
+ Text with type token passed
15
+ </Text>
16
+ <Box {...type.levels.subtext.large} color={typeColors.hint} marginBottom="s">
17
+ <Text>Text with inherenced styles</Text>
18
+ </Box>
19
+ <Text as="p" typeLevel="body.small">
20
+ Small Body level text
21
+ </Text>
22
+ </Box>
23
+ );
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import {Title as TitleComponent} from '@workday/canvas-kit-react/text';
3
+
4
+ export default () => (
5
+ <>
6
+ <TitleComponent as="h1" size="large">
7
+ Large Title Text
8
+ </TitleComponent>
9
+ <TitleComponent as="h2" size="medium">
10
+ Medium Title Text
11
+ </TitleComponent>
12
+ <TitleComponent as="h3" size="small">
13
+ Small Title Text
14
+ </TitleComponent>
15
+ </>
16
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "8.0.0-alpha.150-next.2+b0c3f340",
3
+ "version": "8.0.0-alpha.155-next.0+f2928aa0",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@storybook/csf": "0.0.1",
45
- "@workday/canvas-kit-react": "^8.0.0-alpha.150-next.2+b0c3f340"
45
+ "@workday/canvas-kit-react": "^8.0.0-alpha.155-next.0+f2928aa0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "fs-extra": "^10.0.0",
@@ -50,5 +50,5 @@
50
50
  "mkdirp": "^1.0.3",
51
51
  "typescript": "4.1"
52
52
  },
53
- "gitHead": "b0c3f340ec8e06d39bed5d992b23a1b36892106f"
53
+ "gitHead": "f2928aa01f06683f727079a905a202b55ce3f9c4"
54
54
  }