@workday/canvas-kit-react 8.0.0-alpha.252-next.21 → 8.0.0-alpha.254-next.23

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.
@@ -4,5 +4,27 @@ export interface TypeLabelProps extends TextProps {
4
4
  cursor?: Property.Cursor;
5
5
  disabled?: boolean;
6
6
  }
7
+ /**
8
+ * ## LabelText
9
+ * [View Docs](https://canvas.workday.com/components/text/label-text)
10
+ *
11
+ * ---
12
+ * This component is intended to be used for labeling input fields.
13
+ * It's built on top of the `Text` component, so it has access to all `TextProps`.
14
+ * By default, it renders a semantic `label` element.
15
+ *
16
+ * It also uses the `subtext.large` typeLevel by default:
17
+ * - font-size: 14px (0.875rem)
18
+ * - font-weight: regular (400)
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { LabelText } from '@workday/canvas-kit-react/text';
23
+ *
24
+ * const CustomLabelText = () => (
25
+ * <LabelText>Input Label Text</LabelText>
26
+ * );
27
+ * ```
28
+ */
7
29
  export declare const LabelText: import("../../common").ElementComponent<"label", TypeLabelProps>;
8
30
  //# sourceMappingURL=LabelText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LabelText.d.ts","sourceRoot":"","sources":["../../../../text/lib/LabelText.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAG/D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAUD,eAAO,MAAM,SAAS,kEAKpB,CAAC"}
1
+ {"version":3,"file":"LabelText.d.ts","sourceRoot":"","sources":["../../../../text/lib/LabelText.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAG/D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAUD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,kEAKpB,CAAC"}
@@ -43,6 +43,28 @@ var StyledLabel = common_1.styled(text_1.Text.as('label'))(function (_a) {
43
43
  opacity: disabled && variant === 'inverse' ? '.4' : '1',
44
44
  });
45
45
  });
46
+ /**
47
+ * ## LabelText
48
+ * [View Docs](https://canvas.workday.com/components/text/label-text)
49
+ *
50
+ * ---
51
+ * This component is intended to be used for labeling input fields.
52
+ * It's built on top of the `Text` component, so it has access to all `TextProps`.
53
+ * By default, it renders a semantic `label` element.
54
+ *
55
+ * It also uses the `subtext.large` typeLevel by default:
56
+ * - font-size: 14px (0.875rem)
57
+ * - font-weight: regular (400)
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * import { LabelText } from '@workday/canvas-kit-react/text';
62
+ *
63
+ * const CustomLabelText = () => (
64
+ * <LabelText>Input Label Text</LabelText>
65
+ * );
66
+ * ```
67
+ */
46
68
  exports.LabelText = common_1.createComponent('label')({
47
69
  displayName: 'Label',
48
70
  Component: function (elemProps, ref, Element) {
@@ -3,12 +3,56 @@ import { BoxProps } from '@workday/canvas-kit-react/layout';
3
3
  export interface TextProps extends BoxProps {
4
4
  /**
5
5
  * Type token as string with level and size separated by dot.
6
- */
6
+ * These values map to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <Text typeLevel="body.small">Small body text</Text>
11
+ * ```
12
+ */
7
13
  typeLevel?: `${keyof CanvasTypeHierarchy}.${'large' | 'medium' | 'small'}`;
8
14
  /**
9
15
  * Type variant token names: `error`, `hint` or `inverse`.
10
- */
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <Text variant="error" typeLevel="subtext.large">Error text</Text>
20
+ * ```
21
+ */
11
22
  variant?: keyof CanvasTypeVariants;
12
23
  }
24
+ /**
25
+ * ## Text
26
+ * [View Docs](https://canvas.workday.com/components/text/text)
27
+ *
28
+ * ---
29
+ * This is a generic base component intended to render any text.
30
+ * It's built on top of the `Box` component, so it has access to all [BoxProps](https://canvas.workday.com/components/layout/box/#props).
31
+ * It also has `typeLevel` and `variant` style props that simplify navigating our type hierarchy and using [Canvas type tokens](https://canvas.workday.com/tokens/type#type-styles).
32
+ * By default, it renders a semantic `span` element, but you can adjust this as needed with the `as` prop.
33
+ *
34
+ * The type hierarchy is organized into four levels, which correspond to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
35
+ *
36
+ * - `title`: Intended to be used for large page titles.
37
+ * - `heading`: Intended to be used for headings and large text.
38
+ * - `body`: Intended to be used for standard body text.
39
+ * - `subtext`: Intended to be used for small subtext content or in tight spaces.
40
+ *
41
+ * Each level has three sizes: `large`, `medium`, and `small`.
42
+ *
43
+ * You can provide any level and size to the `typeLevel` prop, and it will apply the correct styles accordingly.
44
+ * In the example below we're providing the `subtext` level and `small` size to the component with the value `subtext.small`.
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * import { Text } from '@workday/canvas-kit-react/text';
49
+ *
50
+ * const CustomErrorText = () => (
51
+ * <Text typeLevel="subtext.small" variant="error">
52
+ * Error Text
53
+ * </Text>
54
+ * );
55
+ * ```
56
+ */
13
57
  export declare const Text: import("../../common").ElementComponent<"span", TextProps>;
14
58
  //# sourceMappingURL=Text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../text/lib/Text.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE/D,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC;;OAEG;IACF,SAAS,CAAC,EAAE,GAAG,MAAM,mBAAmB,IAAI,OAAO,GAAC,QAAQ,GAAC,OAAO,EAAE,CAAC;IACxE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;CACpC;AA2CD,eAAO,MAAM,IAAI,4DAOf,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../text/lib/Text.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE/D,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC;;;;;;;;MAQE;IACF,SAAS,CAAC,EAAE,GAAG,MAAM,mBAAmB,IAAI,OAAO,GAAC,QAAQ,GAAC,OAAO,EAAE,CAAC;IACvE;;;;;;;MAOE;IACF,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;CACpC;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCE;AACF,eAAO,MAAM,IAAI,4DAOf,CAAC"}
@@ -49,7 +49,7 @@ var tokens_1 = require("@workday/canvas-kit-react/tokens");
49
49
  var layout_1 = require("@workday/canvas-kit-react/layout");
50
50
  /**
51
51
  * Function returns updated props by token and variant values
52
- */
52
+ */
53
53
  var validateProps = function (_a) {
54
54
  var typeLevel = _a.typeLevel, variant = _a.variant, props = __rest(_a, ["typeLevel", "variant"]);
55
55
  var updatedProps = props;
@@ -81,6 +81,39 @@ var validateProps = function (_a) {
81
81
  }
82
82
  return updatedProps;
83
83
  };
84
+ /**
85
+ * ## Text
86
+ * [View Docs](https://canvas.workday.com/components/text/text)
87
+ *
88
+ * ---
89
+ * This is a generic base component intended to render any text.
90
+ * It's built on top of the `Box` component, so it has access to all [BoxProps](https://canvas.workday.com/components/layout/box/#props).
91
+ * It also has `typeLevel` and `variant` style props that simplify navigating our type hierarchy and using [Canvas type tokens](https://canvas.workday.com/tokens/type#type-styles).
92
+ * By default, it renders a semantic `span` element, but you can adjust this as needed with the `as` prop.
93
+ *
94
+ * The type hierarchy is organized into four levels, which correspond to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
95
+ *
96
+ * - `title`: Intended to be used for large page titles.
97
+ * - `heading`: Intended to be used for headings and large text.
98
+ * - `body`: Intended to be used for standard body text.
99
+ * - `subtext`: Intended to be used for small subtext content or in tight spaces.
100
+ *
101
+ * Each level has three sizes: `large`, `medium`, and `small`.
102
+ *
103
+ * You can provide any level and size to the `typeLevel` prop, and it will apply the correct styles accordingly.
104
+ * In the example below we're providing the `subtext` level and `small` size to the component with the value `subtext.small`.
105
+ *
106
+ * @example
107
+ * ```tsx
108
+ * import { Text } from '@workday/canvas-kit-react/text';
109
+ *
110
+ * const CustomErrorText = () => (
111
+ * <Text typeLevel="subtext.small" variant="error">
112
+ * Error Text
113
+ * </Text>
114
+ * );
115
+ * ```
116
+ */
84
117
  exports.Text = common_1.createComponent('span')({
85
118
  displayName: 'Text',
86
119
  Component: function (_a, ref, Element) {
@@ -1,13 +1,132 @@
1
1
  import { TextProps } from '@workday/canvas-kit-react/text';
2
2
  /**
3
- * Props interface for type level specific component:
3
+ * Prop interface for type level specific components:
4
4
  * Title, Heading, BodyText, Subtext.
5
5
  */
6
6
  export interface TypeLevelProps extends Omit<TextProps, 'typeLevel'> {
7
+ /**
8
+ * Each type level has three sizes: `large`, `medium`, and `small`.
9
+ */
7
10
  size: 'large' | 'medium' | 'small';
8
11
  }
12
+ /**
13
+ * ## Subtext
14
+ * [View Docs](https://canvas.workday.com/components/text/subtext)
15
+ *
16
+ * ---
17
+ * This component is intended to be used for small subtext content or in tight spaces.
18
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
19
+ * It has three sizes: large, medium, and small.
20
+ * Here's a quick reference for font-sizes and weights:
21
+ *
22
+ * - `large`
23
+ * - font-size: 14px (0.875rem)
24
+ * - font-weight: regular (400)
25
+ * - `medium`
26
+ * - font-size: 12px (0.75rem)
27
+ * - font-weight: regular (400)
28
+ * - `small`
29
+ * - font-size: 10px (0.625rem)
30
+ * - font-weight: regular (400)
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import { Subtext } from '@workday/canvas-kit-react/text';
35
+ *
36
+ * const CustomSubtext = () => (
37
+ * <Subtext size="small">Subtext</Subtext>
38
+ * );
39
+ * ```
40
+ */
9
41
  export declare const Subtext: import("../../common").ElementComponent<"p", TypeLevelProps>;
42
+ /**
43
+ * ## BodyText
44
+ * [View Docs](https://canvas.workday.com/components/text/body-text)
45
+ *
46
+ * ---
47
+ * This component is intended to be used for standard body text.
48
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
49
+ * It has three sizes: large, medium, and small.
50
+ * Here's a quick reference for font-sizes and weights:
51
+ *
52
+ * - `large`
53
+ * - font-size: 20px (1.25rem)
54
+ * - font-weight: regular (400)
55
+ * - `medium`
56
+ * - font-size: 18px (1.125rem)
57
+ * - font-weight: regular (400)
58
+ * - `small`
59
+ * - font-size: 16px (1rem)
60
+ * - font-weight: regular (400)
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * import { BodyText } from '@workday/canvas-kit-react/text';
65
+ *
66
+ * const CustomBodyText = () => (
67
+ * <BodyText size="small">Body Text</BodyText>
68
+ * );
69
+ * ```
70
+ */
10
71
  export declare const BodyText: import("../../common").ElementComponent<"p", TypeLevelProps>;
72
+ /**
73
+ * ## Heading
74
+ * [View Docs](https://canvas.workday.com/components/text/heading)
75
+ *
76
+ * ---
77
+ * This component is intended to be used for headings and large text.
78
+ * By default, it renders a semantic `h2` element, but you can adjust this as needed with the `as` prop.
79
+ * It has three sizes: large, medium, and small.
80
+ * Here's a quick reference for font-sizes and weights:
81
+ *
82
+ * - `large`
83
+ * - font-size: 32px (2rem)
84
+ * - font-weight: bold (700)
85
+ * - `medium`
86
+ * - font-size: 28px (1.75rem)
87
+ * - font-weight: bold (700)
88
+ * - `small`
89
+ * - font-size: 24px (1.5rem)
90
+ * - font-weight: bold (700)
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { Heading } from '@workday/canvas-kit-react/text';
95
+ *
96
+ * const CustomHeading = () => (
97
+ * <Heading size="small">Heading Text</Heading>
98
+ * );
99
+ * ```
100
+ */
11
101
  export declare const Heading: import("../../common").ElementComponent<"h2", TypeLevelProps>;
102
+ /**
103
+ * ## Title
104
+ * [View Docs](https://canvas.workday.com/components/text/title)
105
+ *
106
+ * ---
107
+ * This component is intended to be used large page titles.
108
+ * By default, it renders a semantic `h1` element, but you can adjust this as needed with the `as` prop.
109
+ * It has three sizes: large, medium, and small.
110
+ * Here's a quick reference for font-sizes and weights:
111
+ *
112
+ * - `large`
113
+ * - font-size: 56px (3/5rem)
114
+ * - font-weight: bold (700)
115
+ * - `medium`
116
+ * - font-size: 48px (3rem)
117
+ * - font-weight: bold (700)
118
+ * - `small`
119
+ * - font-size: 40px (2.5rem)
120
+ * - font-weight: bold (700)
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * import { Title } from '@workday/canvas-kit-react/text';
125
+ *
126
+ * const CustomTitle = () => (
127
+ * <Title size="small">Title Text</Title>
128
+ * );
129
+ * ```
130
+ */
12
131
  export declare const Title: import("../../common").ElementComponent<"h1", TypeLevelProps>;
13
132
  //# sourceMappingURL=TypeLevelComponents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypeLevelComponents.d.ts","sourceRoot":"","sources":["../../../../text/lib/TypeLevelComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAClE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,OAAO,8DAMlB,CAAC;AAEH,eAAO,MAAM,QAAQ,8DAMnB,CAAC;AAEH,eAAO,MAAM,OAAO,+DAMlB,CAAC;AAEH,eAAO,MAAM,KAAK,+DAMhB,CAAC"}
1
+ {"version":3,"file":"TypeLevelComponents.d.ts","sourceRoot":"","sources":["../../../../text/lib/TypeLevelComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAClE;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO,8DAMlB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,QAAQ,8DAQnB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO,+DAMlB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,KAAK,+DAMhB,CAAC"}
@@ -45,6 +45,35 @@ exports.Title = exports.Heading = exports.BodyText = exports.Subtext = void 0;
45
45
  var React = __importStar(require("react"));
46
46
  var common_1 = require("@workday/canvas-kit-react/common");
47
47
  var text_1 = require("@workday/canvas-kit-react/text");
48
+ /**
49
+ * ## Subtext
50
+ * [View Docs](https://canvas.workday.com/components/text/subtext)
51
+ *
52
+ * ---
53
+ * This component is intended to be used for small subtext content or in tight spaces.
54
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
55
+ * It has three sizes: large, medium, and small.
56
+ * Here's a quick reference for font-sizes and weights:
57
+ *
58
+ * - `large`
59
+ * - font-size: 14px (0.875rem)
60
+ * - font-weight: regular (400)
61
+ * - `medium`
62
+ * - font-size: 12px (0.75rem)
63
+ * - font-weight: regular (400)
64
+ * - `small`
65
+ * - font-size: 10px (0.625rem)
66
+ * - font-weight: regular (400)
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * import { Subtext } from '@workday/canvas-kit-react/text';
71
+ *
72
+ * const CustomSubtext = () => (
73
+ * <Subtext size="small">Subtext</Subtext>
74
+ * );
75
+ * ```
76
+ */
48
77
  exports.Subtext = common_1.createComponent('p')({
49
78
  displayName: 'Subtext',
50
79
  Component: function (_a, ref, Element) {
@@ -53,14 +82,72 @@ exports.Subtext = common_1.createComponent('p')({
53
82
  return React.createElement(text_1.Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
54
83
  },
55
84
  });
85
+ /**
86
+ * ## BodyText
87
+ * [View Docs](https://canvas.workday.com/components/text/body-text)
88
+ *
89
+ * ---
90
+ * This component is intended to be used for standard body text.
91
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
92
+ * It has three sizes: large, medium, and small.
93
+ * Here's a quick reference for font-sizes and weights:
94
+ *
95
+ * - `large`
96
+ * - font-size: 20px (1.25rem)
97
+ * - font-weight: regular (400)
98
+ * - `medium`
99
+ * - font-size: 18px (1.125rem)
100
+ * - font-weight: regular (400)
101
+ * - `small`
102
+ * - font-size: 16px (1rem)
103
+ * - font-weight: regular (400)
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * import { BodyText } from '@workday/canvas-kit-react/text';
108
+ *
109
+ * const CustomBodyText = () => (
110
+ * <BodyText size="small">Body Text</BodyText>
111
+ * );
112
+ * ```
113
+ */
56
114
  exports.BodyText = common_1.createComponent('p')({
57
115
  displayName: 'BodyText',
58
116
  Component: function (_a, ref, Element) {
59
117
  var size = _a.size, elemProps = __rest(_a, ["size"]);
60
118
  var typeLevel = "body." + size;
61
- return React.createElement(text_1.Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
119
+ return (React.createElement(text_1.Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps)));
62
120
  },
63
121
  });
122
+ /**
123
+ * ## Heading
124
+ * [View Docs](https://canvas.workday.com/components/text/heading)
125
+ *
126
+ * ---
127
+ * This component is intended to be used for headings and large text.
128
+ * By default, it renders a semantic `h2` element, but you can adjust this as needed with the `as` prop.
129
+ * It has three sizes: large, medium, and small.
130
+ * Here's a quick reference for font-sizes and weights:
131
+ *
132
+ * - `large`
133
+ * - font-size: 32px (2rem)
134
+ * - font-weight: bold (700)
135
+ * - `medium`
136
+ * - font-size: 28px (1.75rem)
137
+ * - font-weight: bold (700)
138
+ * - `small`
139
+ * - font-size: 24px (1.5rem)
140
+ * - font-weight: bold (700)
141
+ *
142
+ * @example
143
+ * ```tsx
144
+ * import { Heading } from '@workday/canvas-kit-react/text';
145
+ *
146
+ * const CustomHeading = () => (
147
+ * <Heading size="small">Heading Text</Heading>
148
+ * );
149
+ * ```
150
+ */
64
151
  exports.Heading = common_1.createComponent('h2')({
65
152
  displayName: 'Heading',
66
153
  Component: function (_a, ref, Element) {
@@ -69,6 +156,35 @@ exports.Heading = common_1.createComponent('h2')({
69
156
  return React.createElement(text_1.Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
70
157
  },
71
158
  });
159
+ /**
160
+ * ## Title
161
+ * [View Docs](https://canvas.workday.com/components/text/title)
162
+ *
163
+ * ---
164
+ * This component is intended to be used large page titles.
165
+ * By default, it renders a semantic `h1` element, but you can adjust this as needed with the `as` prop.
166
+ * It has three sizes: large, medium, and small.
167
+ * Here's a quick reference for font-sizes and weights:
168
+ *
169
+ * - `large`
170
+ * - font-size: 56px (3/5rem)
171
+ * - font-weight: bold (700)
172
+ * - `medium`
173
+ * - font-size: 48px (3rem)
174
+ * - font-weight: bold (700)
175
+ * - `small`
176
+ * - font-size: 40px (2.5rem)
177
+ * - font-weight: bold (700)
178
+ *
179
+ * @example
180
+ * ```tsx
181
+ * import { Title } from '@workday/canvas-kit-react/text';
182
+ *
183
+ * const CustomTitle = () => (
184
+ * <Title size="small">Title Text</Title>
185
+ * );
186
+ * ```
187
+ */
72
188
  exports.Title = common_1.createComponent('h1')({
73
189
  displayName: 'Title',
74
190
  Component: function (_a, ref, Element) {
@@ -4,5 +4,27 @@ export interface TypeLabelProps extends TextProps {
4
4
  cursor?: Property.Cursor;
5
5
  disabled?: boolean;
6
6
  }
7
+ /**
8
+ * ## LabelText
9
+ * [View Docs](https://canvas.workday.com/components/text/label-text)
10
+ *
11
+ * ---
12
+ * This component is intended to be used for labeling input fields.
13
+ * It's built on top of the `Text` component, so it has access to all `TextProps`.
14
+ * By default, it renders a semantic `label` element.
15
+ *
16
+ * It also uses the `subtext.large` typeLevel by default:
17
+ * - font-size: 14px (0.875rem)
18
+ * - font-weight: regular (400)
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * import { LabelText } from '@workday/canvas-kit-react/text';
23
+ *
24
+ * const CustomLabelText = () => (
25
+ * <LabelText>Input Label Text</LabelText>
26
+ * );
27
+ * ```
28
+ */
7
29
  export declare const LabelText: import("../../common").ElementComponent<"label", TypeLabelProps>;
8
30
  //# sourceMappingURL=LabelText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LabelText.d.ts","sourceRoot":"","sources":["../../../../text/lib/LabelText.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAG/D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAUD,eAAO,MAAM,SAAS,kEAKpB,CAAC"}
1
+ {"version":3,"file":"LabelText.d.ts","sourceRoot":"","sources":["../../../../text/lib/LabelText.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAG/D,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAUD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,SAAS,kEAKpB,CAAC"}
@@ -21,6 +21,28 @@ var StyledLabel = styled(Text.as('label'))(function (_a) {
21
21
  opacity: disabled && variant === 'inverse' ? '.4' : '1',
22
22
  });
23
23
  });
24
+ /**
25
+ * ## LabelText
26
+ * [View Docs](https://canvas.workday.com/components/text/label-text)
27
+ *
28
+ * ---
29
+ * This component is intended to be used for labeling input fields.
30
+ * It's built on top of the `Text` component, so it has access to all `TextProps`.
31
+ * By default, it renders a semantic `label` element.
32
+ *
33
+ * It also uses the `subtext.large` typeLevel by default:
34
+ * - font-size: 14px (0.875rem)
35
+ * - font-weight: regular (400)
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * import { LabelText } from '@workday/canvas-kit-react/text';
40
+ *
41
+ * const CustomLabelText = () => (
42
+ * <LabelText>Input Label Text</LabelText>
43
+ * );
44
+ * ```
45
+ */
24
46
  export var LabelText = createComponent('label')({
25
47
  displayName: 'Label',
26
48
  Component: function (elemProps, ref, Element) {
@@ -3,12 +3,56 @@ import { BoxProps } from '@workday/canvas-kit-react/layout';
3
3
  export interface TextProps extends BoxProps {
4
4
  /**
5
5
  * Type token as string with level and size separated by dot.
6
- */
6
+ * These values map to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <Text typeLevel="body.small">Small body text</Text>
11
+ * ```
12
+ */
7
13
  typeLevel?: `${keyof CanvasTypeHierarchy}.${'large' | 'medium' | 'small'}`;
8
14
  /**
9
15
  * Type variant token names: `error`, `hint` or `inverse`.
10
- */
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <Text variant="error" typeLevel="subtext.large">Error text</Text>
20
+ * ```
21
+ */
11
22
  variant?: keyof CanvasTypeVariants;
12
23
  }
24
+ /**
25
+ * ## Text
26
+ * [View Docs](https://canvas.workday.com/components/text/text)
27
+ *
28
+ * ---
29
+ * This is a generic base component intended to render any text.
30
+ * It's built on top of the `Box` component, so it has access to all [BoxProps](https://canvas.workday.com/components/layout/box/#props).
31
+ * It also has `typeLevel` and `variant` style props that simplify navigating our type hierarchy and using [Canvas type tokens](https://canvas.workday.com/tokens/type#type-styles).
32
+ * By default, it renders a semantic `span` element, but you can adjust this as needed with the `as` prop.
33
+ *
34
+ * The type hierarchy is organized into four levels, which correspond to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
35
+ *
36
+ * - `title`: Intended to be used for large page titles.
37
+ * - `heading`: Intended to be used for headings and large text.
38
+ * - `body`: Intended to be used for standard body text.
39
+ * - `subtext`: Intended to be used for small subtext content or in tight spaces.
40
+ *
41
+ * Each level has three sizes: `large`, `medium`, and `small`.
42
+ *
43
+ * You can provide any level and size to the `typeLevel` prop, and it will apply the correct styles accordingly.
44
+ * In the example below we're providing the `subtext` level and `small` size to the component with the value `subtext.small`.
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * import { Text } from '@workday/canvas-kit-react/text';
49
+ *
50
+ * const CustomErrorText = () => (
51
+ * <Text typeLevel="subtext.small" variant="error">
52
+ * Error Text
53
+ * </Text>
54
+ * );
55
+ * ```
56
+ */
13
57
  export declare const Text: import("../../common").ElementComponent<"span", TextProps>;
14
58
  //# sourceMappingURL=Text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../text/lib/Text.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE/D,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC;;OAEG;IACF,SAAS,CAAC,EAAE,GAAG,MAAM,mBAAmB,IAAI,OAAO,GAAC,QAAQ,GAAC,OAAO,EAAE,CAAC;IACxE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;CACpC;AA2CD,eAAO,MAAM,IAAI,4DAOf,CAAC"}
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../text/lib/Text.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAO,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,kCAAkC,CAAC;AAC/F,OAAO,EAAM,QAAQ,EAAC,MAAM,kCAAkC,CAAC;AAE/D,MAAM,WAAW,SAAU,SAAQ,QAAQ;IACzC;;;;;;;;MAQE;IACF,SAAS,CAAC,EAAE,GAAG,MAAM,mBAAmB,IAAI,OAAO,GAAC,QAAQ,GAAC,OAAO,EAAE,CAAC;IACvE;;;;;;;MAOE;IACF,OAAO,CAAC,EAAE,MAAM,kBAAkB,CAAC;CACpC;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCE;AACF,eAAO,MAAM,IAAI,4DAOf,CAAC"}
@@ -27,7 +27,7 @@ import { type } from '@workday/canvas-kit-react/tokens';
27
27
  import { Box } from '@workday/canvas-kit-react/layout';
28
28
  /**
29
29
  * Function returns updated props by token and variant values
30
- */
30
+ */
31
31
  var validateProps = function (_a) {
32
32
  var typeLevel = _a.typeLevel, variant = _a.variant, props = __rest(_a, ["typeLevel", "variant"]);
33
33
  var updatedProps = props;
@@ -59,6 +59,39 @@ var validateProps = function (_a) {
59
59
  }
60
60
  return updatedProps;
61
61
  };
62
+ /**
63
+ * ## Text
64
+ * [View Docs](https://canvas.workday.com/components/text/text)
65
+ *
66
+ * ---
67
+ * This is a generic base component intended to render any text.
68
+ * It's built on top of the `Box` component, so it has access to all [BoxProps](https://canvas.workday.com/components/layout/box/#props).
69
+ * It also has `typeLevel` and `variant` style props that simplify navigating our type hierarchy and using [Canvas type tokens](https://canvas.workday.com/tokens/type#type-styles).
70
+ * By default, it renders a semantic `span` element, but you can adjust this as needed with the `as` prop.
71
+ *
72
+ * The type hierarchy is organized into four levels, which correspond to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
73
+ *
74
+ * - `title`: Intended to be used for large page titles.
75
+ * - `heading`: Intended to be used for headings and large text.
76
+ * - `body`: Intended to be used for standard body text.
77
+ * - `subtext`: Intended to be used for small subtext content or in tight spaces.
78
+ *
79
+ * Each level has three sizes: `large`, `medium`, and `small`.
80
+ *
81
+ * You can provide any level and size to the `typeLevel` prop, and it will apply the correct styles accordingly.
82
+ * In the example below we're providing the `subtext` level and `small` size to the component with the value `subtext.small`.
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * import { Text } from '@workday/canvas-kit-react/text';
87
+ *
88
+ * const CustomErrorText = () => (
89
+ * <Text typeLevel="subtext.small" variant="error">
90
+ * Error Text
91
+ * </Text>
92
+ * );
93
+ * ```
94
+ */
62
95
  export var Text = createComponent('span')({
63
96
  displayName: 'Text',
64
97
  Component: function (_a, ref, Element) {
@@ -1,13 +1,132 @@
1
1
  import { TextProps } from '@workday/canvas-kit-react/text';
2
2
  /**
3
- * Props interface for type level specific component:
3
+ * Prop interface for type level specific components:
4
4
  * Title, Heading, BodyText, Subtext.
5
5
  */
6
6
  export interface TypeLevelProps extends Omit<TextProps, 'typeLevel'> {
7
+ /**
8
+ * Each type level has three sizes: `large`, `medium`, and `small`.
9
+ */
7
10
  size: 'large' | 'medium' | 'small';
8
11
  }
12
+ /**
13
+ * ## Subtext
14
+ * [View Docs](https://canvas.workday.com/components/text/subtext)
15
+ *
16
+ * ---
17
+ * This component is intended to be used for small subtext content or in tight spaces.
18
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
19
+ * It has three sizes: large, medium, and small.
20
+ * Here's a quick reference for font-sizes and weights:
21
+ *
22
+ * - `large`
23
+ * - font-size: 14px (0.875rem)
24
+ * - font-weight: regular (400)
25
+ * - `medium`
26
+ * - font-size: 12px (0.75rem)
27
+ * - font-weight: regular (400)
28
+ * - `small`
29
+ * - font-size: 10px (0.625rem)
30
+ * - font-weight: regular (400)
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import { Subtext } from '@workday/canvas-kit-react/text';
35
+ *
36
+ * const CustomSubtext = () => (
37
+ * <Subtext size="small">Subtext</Subtext>
38
+ * );
39
+ * ```
40
+ */
9
41
  export declare const Subtext: import("../../common").ElementComponent<"p", TypeLevelProps>;
42
+ /**
43
+ * ## BodyText
44
+ * [View Docs](https://canvas.workday.com/components/text/body-text)
45
+ *
46
+ * ---
47
+ * This component is intended to be used for standard body text.
48
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
49
+ * It has three sizes: large, medium, and small.
50
+ * Here's a quick reference for font-sizes and weights:
51
+ *
52
+ * - `large`
53
+ * - font-size: 20px (1.25rem)
54
+ * - font-weight: regular (400)
55
+ * - `medium`
56
+ * - font-size: 18px (1.125rem)
57
+ * - font-weight: regular (400)
58
+ * - `small`
59
+ * - font-size: 16px (1rem)
60
+ * - font-weight: regular (400)
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * import { BodyText } from '@workday/canvas-kit-react/text';
65
+ *
66
+ * const CustomBodyText = () => (
67
+ * <BodyText size="small">Body Text</BodyText>
68
+ * );
69
+ * ```
70
+ */
10
71
  export declare const BodyText: import("../../common").ElementComponent<"p", TypeLevelProps>;
72
+ /**
73
+ * ## Heading
74
+ * [View Docs](https://canvas.workday.com/components/text/heading)
75
+ *
76
+ * ---
77
+ * This component is intended to be used for headings and large text.
78
+ * By default, it renders a semantic `h2` element, but you can adjust this as needed with the `as` prop.
79
+ * It has three sizes: large, medium, and small.
80
+ * Here's a quick reference for font-sizes and weights:
81
+ *
82
+ * - `large`
83
+ * - font-size: 32px (2rem)
84
+ * - font-weight: bold (700)
85
+ * - `medium`
86
+ * - font-size: 28px (1.75rem)
87
+ * - font-weight: bold (700)
88
+ * - `small`
89
+ * - font-size: 24px (1.5rem)
90
+ * - font-weight: bold (700)
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { Heading } from '@workday/canvas-kit-react/text';
95
+ *
96
+ * const CustomHeading = () => (
97
+ * <Heading size="small">Heading Text</Heading>
98
+ * );
99
+ * ```
100
+ */
11
101
  export declare const Heading: import("../../common").ElementComponent<"h2", TypeLevelProps>;
102
+ /**
103
+ * ## Title
104
+ * [View Docs](https://canvas.workday.com/components/text/title)
105
+ *
106
+ * ---
107
+ * This component is intended to be used large page titles.
108
+ * By default, it renders a semantic `h1` element, but you can adjust this as needed with the `as` prop.
109
+ * It has three sizes: large, medium, and small.
110
+ * Here's a quick reference for font-sizes and weights:
111
+ *
112
+ * - `large`
113
+ * - font-size: 56px (3/5rem)
114
+ * - font-weight: bold (700)
115
+ * - `medium`
116
+ * - font-size: 48px (3rem)
117
+ * - font-weight: bold (700)
118
+ * - `small`
119
+ * - font-size: 40px (2.5rem)
120
+ * - font-weight: bold (700)
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * import { Title } from '@workday/canvas-kit-react/text';
125
+ *
126
+ * const CustomTitle = () => (
127
+ * <Title size="small">Title Text</Title>
128
+ * );
129
+ * ```
130
+ */
12
131
  export declare const Title: import("../../common").ElementComponent<"h1", TypeLevelProps>;
13
132
  //# sourceMappingURL=TypeLevelComponents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TypeLevelComponents.d.ts","sourceRoot":"","sources":["../../../../text/lib/TypeLevelComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAClE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,OAAO,8DAMlB,CAAC;AAEH,eAAO,MAAM,QAAQ,8DAMnB,CAAC;AAEH,eAAO,MAAM,OAAO,+DAMlB,CAAC;AAEH,eAAO,MAAM,KAAK,+DAMhB,CAAC"}
1
+ {"version":3,"file":"TypeLevelComponents.d.ts","sourceRoot":"","sources":["../../../../text/lib/TypeLevelComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAO,SAAS,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;IAClE;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO,8DAMlB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,QAAQ,8DAQnB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,OAAO,+DAMlB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,KAAK,+DAMhB,CAAC"}
@@ -23,6 +23,35 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import * as React from 'react';
24
24
  import { createComponent } from '@workday/canvas-kit-react/common';
25
25
  import { Text } from '@workday/canvas-kit-react/text';
26
+ /**
27
+ * ## Subtext
28
+ * [View Docs](https://canvas.workday.com/components/text/subtext)
29
+ *
30
+ * ---
31
+ * This component is intended to be used for small subtext content or in tight spaces.
32
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
33
+ * It has three sizes: large, medium, and small.
34
+ * Here's a quick reference for font-sizes and weights:
35
+ *
36
+ * - `large`
37
+ * - font-size: 14px (0.875rem)
38
+ * - font-weight: regular (400)
39
+ * - `medium`
40
+ * - font-size: 12px (0.75rem)
41
+ * - font-weight: regular (400)
42
+ * - `small`
43
+ * - font-size: 10px (0.625rem)
44
+ * - font-weight: regular (400)
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * import { Subtext } from '@workday/canvas-kit-react/text';
49
+ *
50
+ * const CustomSubtext = () => (
51
+ * <Subtext size="small">Subtext</Subtext>
52
+ * );
53
+ * ```
54
+ */
26
55
  export var Subtext = createComponent('p')({
27
56
  displayName: 'Subtext',
28
57
  Component: function (_a, ref, Element) {
@@ -31,14 +60,72 @@ export var Subtext = createComponent('p')({
31
60
  return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
32
61
  },
33
62
  });
63
+ /**
64
+ * ## BodyText
65
+ * [View Docs](https://canvas.workday.com/components/text/body-text)
66
+ *
67
+ * ---
68
+ * This component is intended to be used for standard body text.
69
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
70
+ * It has three sizes: large, medium, and small.
71
+ * Here's a quick reference for font-sizes and weights:
72
+ *
73
+ * - `large`
74
+ * - font-size: 20px (1.25rem)
75
+ * - font-weight: regular (400)
76
+ * - `medium`
77
+ * - font-size: 18px (1.125rem)
78
+ * - font-weight: regular (400)
79
+ * - `small`
80
+ * - font-size: 16px (1rem)
81
+ * - font-weight: regular (400)
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * import { BodyText } from '@workday/canvas-kit-react/text';
86
+ *
87
+ * const CustomBodyText = () => (
88
+ * <BodyText size="small">Body Text</BodyText>
89
+ * );
90
+ * ```
91
+ */
34
92
  export var BodyText = createComponent('p')({
35
93
  displayName: 'BodyText',
36
94
  Component: function (_a, ref, Element) {
37
95
  var size = _a.size, elemProps = __rest(_a, ["size"]);
38
96
  var typeLevel = "body." + size;
39
- return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
97
+ return (React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps)));
40
98
  },
41
99
  });
100
+ /**
101
+ * ## Heading
102
+ * [View Docs](https://canvas.workday.com/components/text/heading)
103
+ *
104
+ * ---
105
+ * This component is intended to be used for headings and large text.
106
+ * By default, it renders a semantic `h2` element, but you can adjust this as needed with the `as` prop.
107
+ * It has three sizes: large, medium, and small.
108
+ * Here's a quick reference for font-sizes and weights:
109
+ *
110
+ * - `large`
111
+ * - font-size: 32px (2rem)
112
+ * - font-weight: bold (700)
113
+ * - `medium`
114
+ * - font-size: 28px (1.75rem)
115
+ * - font-weight: bold (700)
116
+ * - `small`
117
+ * - font-size: 24px (1.5rem)
118
+ * - font-weight: bold (700)
119
+ *
120
+ * @example
121
+ * ```tsx
122
+ * import { Heading } from '@workday/canvas-kit-react/text';
123
+ *
124
+ * const CustomHeading = () => (
125
+ * <Heading size="small">Heading Text</Heading>
126
+ * );
127
+ * ```
128
+ */
42
129
  export var Heading = createComponent('h2')({
43
130
  displayName: 'Heading',
44
131
  Component: function (_a, ref, Element) {
@@ -47,6 +134,35 @@ export var Heading = createComponent('h2')({
47
134
  return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
48
135
  },
49
136
  });
137
+ /**
138
+ * ## Title
139
+ * [View Docs](https://canvas.workday.com/components/text/title)
140
+ *
141
+ * ---
142
+ * This component is intended to be used large page titles.
143
+ * By default, it renders a semantic `h1` element, but you can adjust this as needed with the `as` prop.
144
+ * It has three sizes: large, medium, and small.
145
+ * Here's a quick reference for font-sizes and weights:
146
+ *
147
+ * - `large`
148
+ * - font-size: 56px (3/5rem)
149
+ * - font-weight: bold (700)
150
+ * - `medium`
151
+ * - font-size: 48px (3rem)
152
+ * - font-weight: bold (700)
153
+ * - `small`
154
+ * - font-size: 40px (2.5rem)
155
+ * - font-weight: bold (700)
156
+ *
157
+ * @example
158
+ * ```tsx
159
+ * import { Title } from '@workday/canvas-kit-react/text';
160
+ *
161
+ * const CustomTitle = () => (
162
+ * <Title size="small">Title Text</Title>
163
+ * );
164
+ * ```
165
+ */
50
166
  export var Title = createComponent('h1')({
51
167
  displayName: 'Title',
52
168
  Component: function (_a, ref, Element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.0.0-alpha.252-next.21+0ce754ca",
3
+ "version": "8.0.0-alpha.254-next.23+2fa69377",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,7 +49,7 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.252-next.21+0ce754ca",
52
+ "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.254-next.23+2fa69377",
53
53
  "@workday/canvas-system-icons-web": "^3.0.0",
54
54
  "@workday/design-assets-types": "^0.2.8",
55
55
  "chroma-js": "^2.1.0",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "0ce754caca6bcdb3876ccb8e012cfecddaffb882"
70
+ "gitHead": "2fa69377808c5dd76337d1b34dbd4ede07c7e1c4"
71
71
  }
@@ -17,6 +17,28 @@ const StyledLabel = styled(Text.as('label'))<StyledType & TypeLabelProps>(
17
17
  })
18
18
  );
19
19
 
20
+ /**
21
+ * ## LabelText
22
+ * [View Docs](https://canvas.workday.com/components/text/label-text)
23
+ *
24
+ * ---
25
+ * This component is intended to be used for labeling input fields.
26
+ * It's built on top of the `Text` component, so it has access to all `TextProps`.
27
+ * By default, it renders a semantic `label` element.
28
+ *
29
+ * It also uses the `subtext.large` typeLevel by default:
30
+ * - font-size: 14px (0.875rem)
31
+ * - font-weight: regular (400)
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * import { LabelText } from '@workday/canvas-kit-react/text';
36
+ *
37
+ * const CustomLabelText = () => (
38
+ * <LabelText>Input Label Text</LabelText>
39
+ * );
40
+ * ```
41
+ */
20
42
  export const LabelText = createComponent('label')({
21
43
  displayName: 'Label',
22
44
  Component: (elemProps: TypeLabelProps, ref, Element) => {
package/text/lib/Text.tsx CHANGED
@@ -7,17 +7,28 @@ import {Box, BoxProps} from '@workday/canvas-kit-react/layout';
7
7
  export interface TextProps extends BoxProps {
8
8
  /**
9
9
  * Type token as string with level and size separated by dot.
10
- */
11
- typeLevel?: `${keyof CanvasTypeHierarchy}.${'large'|'medium'|'small'}`;
10
+ * These values map to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <Text typeLevel="body.small">Small body text</Text>
15
+ * ```
16
+ */
17
+ typeLevel?: `${keyof CanvasTypeHierarchy}.${'large'|'medium'|'small'}`;
12
18
  /**
13
19
  * Type variant token names: `error`, `hint` or `inverse`.
14
- */
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * <Text variant="error" typeLevel="subtext.large">Error text</Text>
24
+ * ```
25
+ */
15
26
  variant?: keyof CanvasTypeVariants;
16
27
  }
17
28
 
18
29
  /**
19
30
  * Function returns updated props by token and variant values
20
- */
31
+ */
21
32
  const validateProps = ({typeLevel, variant, ...props}: TextProps) => {
22
33
  let updatedProps: any = props;
23
34
  const tokenPropNames = [
@@ -56,6 +67,39 @@ const validateProps = ({typeLevel, variant, ...props}: TextProps) => {
56
67
  return updatedProps;
57
68
  };
58
69
 
70
+ /**
71
+ * ## Text
72
+ * [View Docs](https://canvas.workday.com/components/text/text)
73
+ *
74
+ * ---
75
+ * This is a generic base component intended to render any text.
76
+ * It's built on top of the `Box` component, so it has access to all [BoxProps](https://canvas.workday.com/components/layout/box/#props).
77
+ * It also has `typeLevel` and `variant` style props that simplify navigating our type hierarchy and using [Canvas type tokens](https://canvas.workday.com/tokens/type#type-styles).
78
+ * By default, it renders a semantic `span` element, but you can adjust this as needed with the `as` prop.
79
+ *
80
+ * The type hierarchy is organized into four levels, which correspond to our [Canvas type levels](https://canvas.workday.com/tokens/type#type-styles).
81
+ *
82
+ * - `title`: Intended to be used for large page titles.
83
+ * - `heading`: Intended to be used for headings and large text.
84
+ * - `body`: Intended to be used for standard body text.
85
+ * - `subtext`: Intended to be used for small subtext content or in tight spaces.
86
+ *
87
+ * Each level has three sizes: `large`, `medium`, and `small`.
88
+ *
89
+ * You can provide any level and size to the `typeLevel` prop, and it will apply the correct styles accordingly.
90
+ * In the example below we're providing the `subtext` level and `small` size to the component with the value `subtext.small`.
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { Text } from '@workday/canvas-kit-react/text';
95
+ *
96
+ * const CustomErrorText = () => (
97
+ * <Text typeLevel="subtext.small" variant="error">
98
+ * Error Text
99
+ * </Text>
100
+ * );
101
+ * ```
102
+ */
59
103
  export const Text = createComponent('span')({
60
104
  displayName: 'Text',
61
105
  Component: ({children, ...elemProps}: TextProps, ref, Element) => (
@@ -3,13 +3,45 @@ import {createComponent} from '@workday/canvas-kit-react/common';
3
3
  import {Text, TextProps} from '@workday/canvas-kit-react/text';
4
4
 
5
5
  /**
6
- * Props interface for type level specific component:
6
+ * Prop interface for type level specific components:
7
7
  * Title, Heading, BodyText, Subtext.
8
8
  */
9
9
  export interface TypeLevelProps extends Omit<TextProps, 'typeLevel'> {
10
+ /**
11
+ * Each type level has three sizes: `large`, `medium`, and `small`.
12
+ */
10
13
  size: 'large' | 'medium' | 'small';
11
14
  }
12
15
 
16
+ /**
17
+ * ## Subtext
18
+ * [View Docs](https://canvas.workday.com/components/text/subtext)
19
+ *
20
+ * ---
21
+ * This component is intended to be used for small subtext content or in tight spaces.
22
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
23
+ * It has three sizes: large, medium, and small.
24
+ * Here's a quick reference for font-sizes and weights:
25
+ *
26
+ * - `large`
27
+ * - font-size: 14px (0.875rem)
28
+ * - font-weight: regular (400)
29
+ * - `medium`
30
+ * - font-size: 12px (0.75rem)
31
+ * - font-weight: regular (400)
32
+ * - `small`
33
+ * - font-size: 10px (0.625rem)
34
+ * - font-weight: regular (400)
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * import { Subtext } from '@workday/canvas-kit-react/text';
39
+ *
40
+ * const CustomSubtext = () => (
41
+ * <Subtext size="small">Subtext</Subtext>
42
+ * );
43
+ * ```
44
+ */
13
45
  export const Subtext = createComponent('p')({
14
46
  displayName: 'Subtext',
15
47
  Component: ({size, ...elemProps}: TypeLevelProps, ref, Element) => {
@@ -18,14 +50,74 @@ export const Subtext = createComponent('p')({
18
50
  },
19
51
  });
20
52
 
53
+ /**
54
+ * ## BodyText
55
+ * [View Docs](https://canvas.workday.com/components/text/body-text)
56
+ *
57
+ * ---
58
+ * This component is intended to be used for standard body text.
59
+ * By default, it renders a semantic `p` element, but you can adjust this as needed with the `as` prop.
60
+ * It has three sizes: large, medium, and small.
61
+ * Here's a quick reference for font-sizes and weights:
62
+ *
63
+ * - `large`
64
+ * - font-size: 20px (1.25rem)
65
+ * - font-weight: regular (400)
66
+ * - `medium`
67
+ * - font-size: 18px (1.125rem)
68
+ * - font-weight: regular (400)
69
+ * - `small`
70
+ * - font-size: 16px (1rem)
71
+ * - font-weight: regular (400)
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * import { BodyText } from '@workday/canvas-kit-react/text';
76
+ *
77
+ * const CustomBodyText = () => (
78
+ * <BodyText size="small">Body Text</BodyText>
79
+ * );
80
+ * ```
81
+ */
21
82
  export const BodyText = createComponent('p')({
22
83
  displayName: 'BodyText',
23
84
  Component: ({size, ...elemProps}: TypeLevelProps, ref, Element) => {
24
85
  const typeLevel = `body.${size}` as TextProps['typeLevel'];
25
- return <Text ref={ref} as={Element} typeLevel={typeLevel} {...elemProps} />;
86
+ return (
87
+ <Text ref={ref} as={Element} typeLevel={typeLevel} {...elemProps} />
88
+ );
26
89
  },
27
90
  });
28
91
 
92
+ /**
93
+ * ## Heading
94
+ * [View Docs](https://canvas.workday.com/components/text/heading)
95
+ *
96
+ * ---
97
+ * This component is intended to be used for headings and large text.
98
+ * By default, it renders a semantic `h2` element, but you can adjust this as needed with the `as` prop.
99
+ * It has three sizes: large, medium, and small.
100
+ * Here's a quick reference for font-sizes and weights:
101
+ *
102
+ * - `large`
103
+ * - font-size: 32px (2rem)
104
+ * - font-weight: bold (700)
105
+ * - `medium`
106
+ * - font-size: 28px (1.75rem)
107
+ * - font-weight: bold (700)
108
+ * - `small`
109
+ * - font-size: 24px (1.5rem)
110
+ * - font-weight: bold (700)
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * import { Heading } from '@workday/canvas-kit-react/text';
115
+ *
116
+ * const CustomHeading = () => (
117
+ * <Heading size="small">Heading Text</Heading>
118
+ * );
119
+ * ```
120
+ */
29
121
  export const Heading = createComponent('h2')({
30
122
  displayName: 'Heading',
31
123
  Component: ({size, ...elemProps}: TypeLevelProps, ref, Element) => {
@@ -34,6 +126,35 @@ export const Heading = createComponent('h2')({
34
126
  },
35
127
  });
36
128
 
129
+ /**
130
+ * ## Title
131
+ * [View Docs](https://canvas.workday.com/components/text/title)
132
+ *
133
+ * ---
134
+ * This component is intended to be used large page titles.
135
+ * By default, it renders a semantic `h1` element, but you can adjust this as needed with the `as` prop.
136
+ * It has three sizes: large, medium, and small.
137
+ * Here's a quick reference for font-sizes and weights:
138
+ *
139
+ * - `large`
140
+ * - font-size: 56px (3/5rem)
141
+ * - font-weight: bold (700)
142
+ * - `medium`
143
+ * - font-size: 48px (3rem)
144
+ * - font-weight: bold (700)
145
+ * - `small`
146
+ * - font-size: 40px (2.5rem)
147
+ * - font-weight: bold (700)
148
+ *
149
+ * @example
150
+ * ```tsx
151
+ * import { Title } from '@workday/canvas-kit-react/text';
152
+ *
153
+ * const CustomTitle = () => (
154
+ * <Title size="small">Title Text</Title>
155
+ * );
156
+ * ```
157
+ */
37
158
  export const Title = createComponent('h1')({
38
159
  displayName: 'Title',
39
160
  Component: ({size, ...elemProps}: TypeLevelProps, ref, Element) => {