@workday/canvas-kit-react 8.0.0-alpha.150-next.2 → 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.
Files changed (144) hide show
  1. package/banner/lib/Banner.tsx +3 -6
  2. package/card/lib/CardBody.tsx +3 -6
  3. package/card/lib/CardHeading.tsx +13 -10
  4. package/checkbox/lib/Checkbox.tsx +9 -24
  5. package/dist/commonjs/banner/lib/Banner.d.ts.map +1 -1
  6. package/dist/commonjs/banner/lib/Banner.js +2 -4
  7. package/dist/commonjs/card/lib/Card.d.ts +1 -1
  8. package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
  9. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  10. package/dist/commonjs/card/lib/CardBody.js +1 -6
  11. package/dist/commonjs/card/lib/CardHeading.d.ts.map +1 -1
  12. package/dist/commonjs/card/lib/CardHeading.js +2 -10
  13. package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
  14. package/dist/commonjs/checkbox/lib/Checkbox.js +2 -13
  15. package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
  16. package/dist/commonjs/form-field/lib/Hint.d.ts.map +1 -1
  17. package/dist/commonjs/form-field/lib/Hint.js +5 -13
  18. package/dist/commonjs/index.d.ts +1 -0
  19. package/dist/commonjs/index.d.ts.map +1 -1
  20. package/dist/commonjs/index.js +1 -0
  21. package/dist/commonjs/layout/index.d.ts +2 -0
  22. package/dist/commonjs/layout/index.d.ts.map +1 -1
  23. package/dist/commonjs/layout/index.js +2 -0
  24. package/dist/commonjs/layout/lib/Box.d.ts +4 -2
  25. package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
  26. package/dist/commonjs/layout/lib/Box.js +27 -3
  27. package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
  28. package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
  29. package/dist/commonjs/layout/lib/Grid.d.ts +2 -2
  30. package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
  31. package/dist/commonjs/layout/lib/utils/color.d.ts.map +1 -1
  32. package/dist/commonjs/layout/lib/utils/color.js +1 -0
  33. package/dist/commonjs/layout/lib/utils/font.d.ts +29 -0
  34. package/dist/commonjs/layout/lib/utils/font.d.ts.map +1 -0
  35. package/dist/commonjs/layout/lib/utils/font.js +57 -0
  36. package/dist/commonjs/layout/lib/utils/text.d.ts +35 -0
  37. package/dist/commonjs/layout/lib/utils/text.d.ts.map +1 -0
  38. package/dist/commonjs/layout/lib/utils/text.js +48 -0
  39. package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
  40. package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.d.ts.map +1 -1
  41. package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.js +5 -4
  42. package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
  43. package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.js +2 -4
  44. package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
  45. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
  46. package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
  47. package/dist/commonjs/popup/lib/PopupCard.js +2 -2
  48. package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
  49. package/dist/commonjs/radio/lib/Radio.js +2 -13
  50. package/dist/commonjs/side-panel/lib/SidePanel.d.ts.map +1 -1
  51. package/dist/commonjs/side-panel/lib/SidePanel.js +2 -2
  52. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  53. package/dist/commonjs/text/index.d.ts +4 -0
  54. package/dist/commonjs/text/index.d.ts.map +1 -0
  55. package/dist/commonjs/text/index.js +15 -0
  56. package/dist/commonjs/text/lib/LabelText.d.ts +8 -0
  57. package/dist/commonjs/text/lib/LabelText.d.ts.map +1 -0
  58. package/dist/commonjs/text/lib/LabelText.js +51 -0
  59. package/dist/commonjs/text/lib/Text.d.ts +14 -0
  60. package/dist/commonjs/text/lib/Text.d.ts.map +1 -0
  61. package/dist/commonjs/text/lib/Text.js +90 -0
  62. package/dist/commonjs/text/lib/TypeLevelComponents.d.ts +13 -0
  63. package/dist/commonjs/text/lib/TypeLevelComponents.d.ts.map +1 -0
  64. package/dist/commonjs/text/lib/TypeLevelComponents.js +79 -0
  65. package/dist/es6/banner/lib/Banner.d.ts.map +1 -1
  66. package/dist/es6/banner/lib/Banner.js +2 -4
  67. package/dist/es6/card/lib/Card.d.ts +1 -1
  68. package/dist/es6/card/lib/CardBody.d.ts +1 -1
  69. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  70. package/dist/es6/card/lib/CardBody.js +1 -3
  71. package/dist/es6/card/lib/CardHeading.d.ts.map +1 -1
  72. package/dist/es6/card/lib/CardHeading.js +2 -7
  73. package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
  74. package/dist/es6/checkbox/lib/Checkbox.js +3 -14
  75. package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
  76. package/dist/es6/form-field/lib/Hint.d.ts.map +1 -1
  77. package/dist/es6/form-field/lib/Hint.js +6 -14
  78. package/dist/es6/index.d.ts +1 -0
  79. package/dist/es6/index.d.ts.map +1 -1
  80. package/dist/es6/index.js +1 -0
  81. package/dist/es6/layout/index.d.ts +2 -0
  82. package/dist/es6/layout/index.d.ts.map +1 -1
  83. package/dist/es6/layout/index.js +2 -0
  84. package/dist/es6/layout/lib/Box.d.ts +4 -2
  85. package/dist/es6/layout/lib/Box.d.ts.map +1 -1
  86. package/dist/es6/layout/lib/Box.js +27 -3
  87. package/dist/es6/layout/lib/Flex.d.ts +1 -1
  88. package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
  89. package/dist/es6/layout/lib/Grid.d.ts +2 -2
  90. package/dist/es6/layout/lib/Stack.d.ts +4 -4
  91. package/dist/es6/layout/lib/utils/color.d.ts.map +1 -1
  92. package/dist/es6/layout/lib/utils/color.js +2 -1
  93. package/dist/es6/layout/lib/utils/font.d.ts +29 -0
  94. package/dist/es6/layout/lib/utils/font.d.ts.map +1 -0
  95. package/dist/es6/layout/lib/utils/font.js +53 -0
  96. package/dist/es6/layout/lib/utils/text.d.ts +35 -0
  97. package/dist/es6/layout/lib/utils/text.d.ts.map +1 -0
  98. package/dist/es6/layout/lib/utils/text.js +44 -0
  99. package/dist/es6/modal/lib/Modal.d.ts +1 -1
  100. package/dist/es6/pagination/lib/Pagination/AdditionalDetails.d.ts.map +1 -1
  101. package/dist/es6/pagination/lib/Pagination/AdditionalDetails.js +6 -5
  102. package/dist/es6/pagination/lib/Pagination/GoTo/Label.d.ts.map +1 -1
  103. package/dist/es6/pagination/lib/Pagination/GoTo/Label.js +2 -4
  104. package/dist/es6/popup/lib/Popup.d.ts +1 -1
  105. package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
  106. package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
  107. package/dist/es6/popup/lib/PopupCard.js +2 -2
  108. package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
  109. package/dist/es6/radio/lib/Radio.js +3 -14
  110. package/dist/es6/side-panel/lib/SidePanel.d.ts.map +1 -1
  111. package/dist/es6/side-panel/lib/SidePanel.js +3 -3
  112. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  113. package/dist/es6/text/index.d.ts +4 -0
  114. package/dist/es6/text/index.d.ts.map +1 -0
  115. package/dist/es6/text/index.js +3 -0
  116. package/dist/es6/text/lib/LabelText.d.ts +8 -0
  117. package/dist/es6/text/lib/LabelText.d.ts.map +1 -0
  118. package/dist/es6/text/lib/LabelText.js +29 -0
  119. package/dist/es6/text/lib/Text.d.ts +14 -0
  120. package/dist/es6/text/lib/Text.d.ts.map +1 -0
  121. package/dist/es6/text/lib/Text.js +68 -0
  122. package/dist/es6/text/lib/TypeLevelComponents.d.ts +13 -0
  123. package/dist/es6/text/lib/TypeLevelComponents.d.ts.map +1 -0
  124. package/dist/es6/text/lib/TypeLevelComponents.js +57 -0
  125. package/form-field/lib/Hint.tsx +8 -19
  126. package/index.ts +1 -0
  127. package/layout/index.ts +2 -0
  128. package/layout/lib/Box.tsx +34 -4
  129. package/layout/lib/utils/color.ts +7 -2
  130. package/layout/lib/utils/font.ts +67 -0
  131. package/layout/lib/utils/text.ts +57 -0
  132. package/package.json +5 -5
  133. package/pagination/lib/Pagination/AdditionalDetails.tsx +7 -8
  134. package/pagination/lib/Pagination/GoTo/Label.tsx +3 -11
  135. package/popup/lib/PopupCard.tsx +2 -1
  136. package/radio/lib/Radio.tsx +9 -24
  137. package/side-panel/lib/SidePanel.tsx +7 -7
  138. package/text/LICENSE +52 -0
  139. package/text/README.md +5 -0
  140. package/text/index.ts +3 -0
  141. package/text/lib/LabelText.tsx +25 -0
  142. package/text/lib/Text.tsx +66 -0
  143. package/text/lib/TypeLevelComponents.tsx +43 -0
  144. package/text/package.json +6 -0
@@ -0,0 +1,68 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import { createComponent } from '@workday/canvas-kit-react/common';
25
+ // type changes no need
26
+ import { type } from '@workday/canvas-kit-react/tokens';
27
+ import { Box } from '@workday/canvas-kit-react/layout';
28
+ /**
29
+ * Function returns updated props by token and variant values
30
+ */
31
+ var validateProps = function (_a) {
32
+ var typeLevel = _a.typeLevel, variant = _a.variant, props = __rest(_a, ["typeLevel", "variant"]);
33
+ var updatedProps = props;
34
+ var tokenPropNames = [
35
+ 'color',
36
+ 'fontFamily',
37
+ 'fontSize',
38
+ 'fontWeight',
39
+ 'letterSpacing',
40
+ 'lineHeight',
41
+ ];
42
+ /*
43
+ If token provided it updates undefined values of token styles:
44
+ `fontFamily`, `fontSize`, `lineHeight`, `fontWeight`, `color`
45
+ by replacing them by token value
46
+ */
47
+ if (typeLevel) {
48
+ var _b = typeLevel.split('.'), level = _b[0], size = _b[1];
49
+ var tokenProps_1 = type.levels[level][size];
50
+ tokenPropNames.forEach(function (item) {
51
+ if (!props[item]) {
52
+ updatedProps[item] = tokenProps_1[item];
53
+ }
54
+ });
55
+ }
56
+ // If variant provided it updates color value by variant color
57
+ if (variant) {
58
+ updatedProps = __assign(__assign({}, updatedProps), type.variants[variant]);
59
+ }
60
+ return updatedProps;
61
+ };
62
+ export var Text = createComponent('span')({
63
+ displayName: 'Text',
64
+ Component: function (_a, ref, Element) {
65
+ var children = _a.children, elemProps = __rest(_a, ["children"]);
66
+ return (React.createElement(Box, __assign({ ref: ref, as: Element }, validateProps(elemProps)), children));
67
+ },
68
+ });
@@ -0,0 +1,13 @@
1
+ import { TextProps } from '@workday/canvas-kit-react/text';
2
+ /**
3
+ * Props interface for type level specific component:
4
+ * Title, Heading, BodyText, Subtext.
5
+ */
6
+ export interface TypeLevelProps extends Omit<TextProps, 'typeLevel'> {
7
+ size: 'large' | 'medium' | 'small';
8
+ }
9
+ export declare const Subtext: import("../../common").ElementComponent<"p", TypeLevelProps>;
10
+ export declare const BodyText: import("../../common").ElementComponent<"p", TypeLevelProps>;
11
+ export declare const Heading: import("../../common").ElementComponent<"h2", TypeLevelProps>;
12
+ export declare const Title: import("../../common").ElementComponent<"h1", TypeLevelProps>;
13
+ //# sourceMappingURL=TypeLevelComponents.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,57 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import * as React from 'react';
24
+ import { createComponent } from '@workday/canvas-kit-react/common';
25
+ import { Text } from '@workday/canvas-kit-react/text';
26
+ export var Subtext = createComponent('p')({
27
+ displayName: 'Subtext',
28
+ Component: function (_a, ref, Element) {
29
+ var size = _a.size, elemProps = __rest(_a, ["size"]);
30
+ var typeLevel = "subtext." + size;
31
+ return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
32
+ },
33
+ });
34
+ export var BodyText = createComponent('p')({
35
+ displayName: 'BodyText',
36
+ Component: function (_a, ref, Element) {
37
+ var size = _a.size, elemProps = __rest(_a, ["size"]);
38
+ var typeLevel = "body." + size;
39
+ return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
40
+ },
41
+ });
42
+ export var Heading = createComponent('h2')({
43
+ displayName: 'Heading',
44
+ Component: function (_a, ref, Element) {
45
+ var size = _a.size, elemProps = __rest(_a, ["size"]);
46
+ var typeLevel = "heading." + size;
47
+ return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
48
+ },
49
+ });
50
+ export var Title = createComponent('h1')({
51
+ displayName: 'Title',
52
+ Component: function (_a, ref, Element) {
53
+ var size = _a.size, elemProps = __rest(_a, ["size"]);
54
+ var typeLevel = "title." + size;
55
+ return React.createElement(Text, __assign({ ref: ref, as: Element, typeLevel: typeLevel }, elemProps));
56
+ },
57
+ });
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
- import {ErrorType, styled, Themeable} from '@workday/canvas-kit-react/common';
3
- import {space, type} from '@workday/canvas-kit-react/tokens';
2
+ import {ErrorType, Themeable, styled} from '@workday/canvas-kit-react/common';
3
+ import {space} from '@workday/canvas-kit-react/tokens';
4
+ import {Subtext, Text} from '@workday/canvas-kit-react/text';
4
5
 
5
6
  export interface HintProps extends Themeable, React.HTMLAttributes<HTMLParagraphElement> {
6
7
  /**
@@ -19,20 +20,7 @@ export interface HintProps extends Themeable, React.HTMLAttributes<HTMLParagraph
19
20
  alertLabel?: string;
20
21
  }
21
22
 
22
- const Label = styled('span')<Pick<HintProps, 'error'>>(
23
- type.levels.subtext.medium,
24
- {
25
- fontWeight: type.properties.fontWeights.medium,
26
- },
27
- ({error, theme}) => error === ErrorType.Error && {color: theme.canvas.palette.error.main}
28
- );
29
-
30
- const Message = styled('p')<Pick<HintProps, 'error'>>(
31
- type.levels.subtext.medium,
32
- {
33
- margin: `${space.xxs} 0 0`,
34
- width: '100%',
35
- },
23
+ const Message = styled(Subtext)<Pick<HintProps, 'error'>>(
36
24
  ({error, theme}) => error === ErrorType.Error && {color: theme.canvas.palette.error.main}
37
25
  );
38
26
 
@@ -41,7 +29,6 @@ class Hint extends React.Component<HintProps> {
41
29
 
42
30
  public render() {
43
31
  const {errorLabel = 'Error', alertLabel = 'Alert', children, error} = this.props;
44
-
45
32
  let hintLabel: string | undefined;
46
33
  switch (error) {
47
34
  case Hint.ErrorType.Error:
@@ -54,8 +41,10 @@ class Hint extends React.Component<HintProps> {
54
41
  }
55
42
 
56
43
  return (
57
- <Message {...this.props}>
58
- {typeof error !== 'undefined' && hintLabel && <Label error={error}>{hintLabel}: </Label>}
44
+ <Message size="medium" margin={`${space.xxs} 0 0`} width="100%" {...this.props}>
45
+ {typeof error !== 'undefined' && hintLabel && (
46
+ <Text fontWeight="medium">{hintLabel}: </Text>
47
+ )}
59
48
  {children}
60
49
  </Message>
61
50
  );
package/index.ts CHANGED
@@ -27,6 +27,7 @@ export * from './status-indicator';
27
27
  export * from './switch';
28
28
  export * from './table';
29
29
  export * from './tabs';
30
+ export * from './text';
30
31
  export * from './text-area';
31
32
  export * from './text-input';
32
33
  export * from './toast';
package/layout/index.ts CHANGED
@@ -7,9 +7,11 @@ export * from './lib/utils/border';
7
7
  export * from './lib/utils/color';
8
8
  export {DepthStyleProps} from './lib/utils/depth';
9
9
  export * from './lib/utils/flexItem';
10
+ export * from './lib/utils/font';
10
11
  export * from './lib/utils/layout';
11
12
  export * from './lib/utils/position';
12
13
  export {SpaceStyleProps} from './lib/utils/space';
14
+ export * from './lib/utils/text';
13
15
  export * from './lib/Flex';
14
16
  export * from './lib/Grid';
15
17
  export * from './lib/Stack';
@@ -8,23 +8,47 @@ import {border, BorderStyleProps} from './utils/border';
8
8
  import {color, ColorStyleProps} from './utils/color';
9
9
  import {depth, DepthStyleProps} from './utils/depth';
10
10
  import {flexItem, FlexItemStyleProps} from './utils/flexItem';
11
+ import {font, FontStyleProps} from './utils/font';
11
12
  import {layout, LayoutStyleProps} from './utils/layout';
12
13
  import {other, OtherStyleProps} from './utils/other';
13
14
  import {position, PositionStyleProps} from './utils/position';
14
15
  import {space, SpaceStyleProps} from './utils/space';
16
+ import {text, TextStyleProps} from './utils/text';
15
17
 
16
18
  export type BoxProps = BorderStyleProps &
17
19
  ColorStyleProps &
18
20
  DepthStyleProps &
19
21
  FlexItemStyleProps &
22
+ FontStyleProps &
20
23
  LayoutStyleProps &
21
24
  OtherStyleProps &
22
25
  PositionStyleProps &
23
- SpaceStyleProps & {
26
+ SpaceStyleProps &
27
+ TextStyleProps & {
24
28
  children?: React.ReactNode;
25
29
  };
26
30
 
27
- const omittedProps = ['display', 'color', 'height', 'overflow', 'width', 'border', 'background'];
31
+ const omittedProps = [
32
+ 'display',
33
+ 'color',
34
+ 'height',
35
+ 'overflow',
36
+ 'width',
37
+ 'border',
38
+ 'background',
39
+ 'fontSize',
40
+ 'fontWeight',
41
+ 'fontFamily',
42
+ 'letterSpacing',
43
+ 'lineHeight',
44
+ 'textAlign',
45
+ 'textDecoration',
46
+ 'textOverflow',
47
+ 'textTransform',
48
+ 'textShadow',
49
+ 'whiteSpace',
50
+ 'wordBreak',
51
+ ];
28
52
 
29
53
  const shouldForwardProp = (prop: string) => {
30
54
  return isPropValid(prop) && !omittedProps.includes(prop);
@@ -55,9 +79,11 @@ export const boxStyleFn = <P extends BoxProps>(props: P) => {
55
79
  color,
56
80
  depth,
57
81
  flexItem,
82
+ font,
58
83
  layout,
59
84
  position,
60
85
  space,
86
+ text,
61
87
  ].reduce((result, style) => {
62
88
  // @ts-ignore
63
89
  const temp = typeof style === 'function' ? style(props) : style;
@@ -79,9 +105,11 @@ const StyledBoxElement = styled('div', {shouldForwardProp})<StyledType & BoxProp
79
105
  color,
80
106
  depth,
81
107
  flexItem,
108
+ font,
82
109
  layout,
83
110
  position,
84
- space
111
+ space,
112
+ text
85
113
  );
86
114
 
87
115
  // Meant to be used with components. There is no `shouldForwardProps` - all props will be forwarded to the component
@@ -93,10 +121,12 @@ const StyledBoxComponent = styled('div')<StyledType & BoxProps>(
93
121
  color,
94
122
  depth,
95
123
  flexItem,
124
+ font,
96
125
  layout,
97
126
  other,
98
127
  position,
99
- space
128
+ space,
129
+ text
100
130
  );
101
131
 
102
132
  /**
@@ -1,4 +1,9 @@
1
- import {colors as colorTokens, CanvasColor} from '@workday/canvas-kit-react/tokens';
1
+ // type changes no need
2
+ import {
3
+ colors as colorTokens,
4
+ CanvasColor,
5
+ CanvasTypeVariants,
6
+ } from '@workday/canvas-kit-react/tokens';
2
7
 
3
8
  export type ColorTokens = typeof colorTokens;
4
9
 
@@ -26,7 +31,7 @@ const getBackgroundImage = (value: string) => ({
26
31
  backgroundImage: value,
27
32
  });
28
33
 
29
- const getColor = (value: CanvasColor | string) => ({
34
+ const getColor = (value: CanvasColor | keyof CanvasTypeVariants | string) => ({
30
35
  color: colorTokens[value] || value,
31
36
  });
32
37
 
@@ -0,0 +1,67 @@
1
+ import {Property} from 'csstype';
2
+ import {type, CanvasTypeProperties} from '@workday/canvas-kit-react/tokens';
3
+
4
+ export type FontFamilyTokens = keyof CanvasTypeProperties['fontFamilies'];
5
+ export type FontSizeTokens = keyof CanvasTypeProperties['fontSizes'];
6
+ export type FontWeightTokens = keyof CanvasTypeProperties['fontWeights'];
7
+ type FontValue = FontFamilyTokens & FontSizeTokens & FontWeightTokens;
8
+
9
+ /** style props to for color properties */
10
+ export type FontStyleProps = {
11
+ /** sets `font-family` property */
12
+ fontFamily?: Property.FontFamily | FontFamilyTokens;
13
+ /** sets `font-size` property */
14
+ fontSize?: Property.FontSize | FontSizeTokens;
15
+ /** sets `font-style` property */
16
+ fontStyle?: Property.FontStyle;
17
+ /** sets `font-weight` property */
18
+ fontWeight?: Property.FontWeight | FontWeightTokens;
19
+ };
20
+
21
+ const getFontFamily = (value: FontStyleProps['fontFamily']) => ({
22
+ fontFamily: type.properties.fontFamilies[value as FontFamilyTokens] || value,
23
+ });
24
+
25
+ const getFontSize = (value: FontStyleProps['fontSize']) => ({
26
+ fontSize: type.properties.fontSizes[value as FontSizeTokens] || value,
27
+ });
28
+
29
+ const getFontStyle = (value: FontStyleProps['fontStyle']) => ({
30
+ fontStyle: value,
31
+ });
32
+
33
+ const getFontWeight = (value: FontStyleProps['fontWeight']) => ({
34
+ fontWeight: type.properties.fontWeights[value as FontWeightTokens] || value,
35
+ });
36
+
37
+ const fontProps = {
38
+ fontFamily: getFontFamily,
39
+ fontSize: getFontSize,
40
+ fontWeight: getFontWeight,
41
+ fontStyle: getFontStyle,
42
+ };
43
+
44
+ /**
45
+ * A style prop function that takes components props and returns font styles from canvas token values.
46
+ * If no `FontStyleProps` are found, it returns an empty object.
47
+ *
48
+ * @example
49
+ * // You'll most likely use `font` with low-level, styled components
50
+ * const BoxExample = () => (
51
+ * <Box fontFamily="monospace" fontWeight="medium">Hello, fonts!</Box>
52
+ * );
53
+ *
54
+ */
55
+ export function font<P extends FontStyleProps>(props: P) {
56
+ let styles = {};
57
+ for (const key in props) {
58
+ if (key in fontProps) {
59
+ const value = props[key as keyof FontStyleProps] as FontValue;
60
+ const fontFn = fontProps[key as keyof FontStyleProps];
61
+ const style = fontFn(value);
62
+ styles = {...styles, ...style};
63
+ }
64
+ }
65
+
66
+ return styles;
67
+ }
@@ -0,0 +1,57 @@
1
+ import {Property} from 'csstype';
2
+
3
+ /** style props to for text properties */
4
+ export type TextStyleProps = {
5
+ /** sets `line-height` property */
6
+ lineHeight?: Property.LineHeight;
7
+ /** sets `letter-spacing` property */
8
+ letterSpacing?: Property.LetterSpacing;
9
+ /** sets `text-align` property */
10
+ textAlign?: Property.TextAlign;
11
+ /** sets `text-decoration` property */
12
+ textDecoration?: Property.TextDecoration;
13
+ /** sets `text-overflow` property */
14
+ textOverflow?: Property.TextOverflow;
15
+ /** sets `text-transform` property */
16
+ textTransform?: Property.TextTransform;
17
+ /** sets `text-shadow` property */
18
+ textShadow?: Property.TextShadow;
19
+ /** sets `white-space` property */
20
+ whiteSpace?: Property.WhiteSpace;
21
+ /** sets `word-break` property */
22
+ wordBreak?: Property.WordBreak;
23
+ };
24
+
25
+ const textProps = [
26
+ 'lineHeight',
27
+ 'letterSpacing',
28
+ 'textAlign',
29
+ 'textDecoration',
30
+ 'textOverflow',
31
+ 'textTransform',
32
+ 'textShadow',
33
+ 'whiteSpace',
34
+ 'wordBreak',
35
+ ];
36
+
37
+ /**
38
+ * A style prop function that takes components props and returns text styles.
39
+ * If no `TextStyleProps` are found, it returns an empty object.
40
+ *
41
+ * @example
42
+ * // You'll most likely use `text-align` with low-level, styled components
43
+ * const BoxExample = () => (
44
+ * <Box textAlign="center">Hello, alignment!</Box>
45
+ * );
46
+ *
47
+ */
48
+ export function text<P extends TextStyleProps>(props: P) {
49
+ let styles = {};
50
+ for (const key in props) {
51
+ if (textProps.includes(key)) {
52
+ const value = props[key as keyof TextStyleProps] as string;
53
+ styles = {...styles, [key]: value};
54
+ }
55
+ }
56
+ return styles;
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.0.0-alpha.150-next.2+b0c3f340",
3
+ "version": "8.0.0-alpha.151-next.3+548c0a40",
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,9 +49,9 @@
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-labs-react": "^8.0.0-alpha.150-next.2+b0c3f340",
53
- "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.150-next.2+b0c3f340",
54
- "@workday/canvas-kit-preview-react": "^8.0.0-alpha.150-next.2+b0c3f340",
52
+ "@workday/canvas-kit-labs-react": "^8.0.0-alpha.151-next.3+548c0a40",
53
+ "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.151-next.3+548c0a40",
54
+ "@workday/canvas-kit-preview-react": "^8.0.0-alpha.151-next.3+548c0a40",
55
55
  "@workday/canvas-system-icons-web": "^3.0.0",
56
56
  "@workday/design-assets-types": "^0.2.8",
57
57
  "chroma-js": "^2.1.0",
@@ -70,5 +70,5 @@
70
70
  "@workday/canvas-accent-icons-web": "^3.0.0",
71
71
  "@workday/canvas-applet-icons-web": "^2.0.0"
72
72
  },
73
- "gitHead": "b0c3f340ec8e06d39bed5d992b23a1b36892106f"
73
+ "gitHead": "548c0a4090f25b1feeabaf1c1288fec4539e7d0a"
74
74
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import {type, typeColors, space} from '@workday/canvas-kit-react/tokens';
2
+ import {type, space, typeColors} from '@workday/canvas-kit-react/tokens';
3
3
  import {accessibleHide, styled, StyledType} from '@workday/canvas-kit-react/common';
4
4
 
5
5
  import {PaginationModel} from './types';
@@ -16,19 +16,13 @@ export interface AdditionalDetailsProps extends Omit<FlexProps, 'children'> {
16
16
  const StyledAdditionalDetails = styled(Flex)<
17
17
  StyledType & Pick<AdditionalDetailsProps, 'shouldHideDetails'>
18
18
  >(({shouldHideDetails}) => {
19
- const styles = {
20
- ...type.levels.subtext.medium,
21
- color: typeColors.hint,
22
- };
23
19
  if (shouldHideDetails) {
24
20
  return {
25
- ...styles,
26
21
  ...accessibleHide,
27
22
  marginTop: space.zero,
28
23
  };
29
24
  } else {
30
25
  return {
31
- ...styles,
32
26
  marginTop: space.xs,
33
27
  };
34
28
  }
@@ -43,7 +37,12 @@ export const AdditionalDetails = ({
43
37
  const liveRegionProps = useLiveRegion({shouldAnnounceToScreenReader});
44
38
 
45
39
  return (
46
- <StyledAdditionalDetails {...liveRegionProps} {...elemProps}>
40
+ <StyledAdditionalDetails
41
+ {...type.levels.subtext.medium}
42
+ color={typeColors.hint}
43
+ {...liveRegionProps}
44
+ {...elemProps}
45
+ >
47
46
  {typeof children === 'function' ? children(model) : children}
48
47
  </StyledAdditionalDetails>
49
48
  );
@@ -1,8 +1,6 @@
1
1
  import * as React from 'react';
2
- import {type, typeColors} from '@workday/canvas-kit-react/tokens';
3
-
4
2
  import {PaginationModel} from '../types';
5
- import {StyledType, styled} from '@workday/canvas-kit-react/common';
3
+ import {LabelText} from '@workday/canvas-kit-react/text';
6
4
 
7
5
  export interface GoToLabelProps
8
6
  extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, 'children'> {
@@ -13,16 +11,10 @@ export interface GoToLabelProps
13
11
  children?: (model: PaginationModel) => React.ReactNode | React.ReactNode;
14
12
  }
15
13
 
16
- const StyledLabel = styled('label')<StyledType>({
17
- ...type.levels.subtext.medium,
18
- color: typeColors.hint,
19
- whiteSpace: 'nowrap',
20
- });
21
-
22
14
  export const GoToLabel = ({model, children, ...elemProps}: GoToLabelProps) => {
23
15
  return (
24
- <StyledLabel {...elemProps}>
16
+ <LabelText typeLevel="subtext.medium" variant="hint" whiteSpace="nowrap" {...elemProps}>
25
17
  {typeof children === 'function' ? children(model) : children}
26
- </StyledLabel>
18
+ </LabelText>
27
19
  );
28
20
  };
@@ -38,7 +38,7 @@ const popupAnimation = (transformOrigin: TransformOrigin) => {
38
38
 
39
39
  const StyledPopupCard = styled(Card)<
40
40
  StyledType & {width?: number | string; transformOrigin?: TransformOrigin}
41
- >(type.levels.subtext.large, ({transformOrigin}) => {
41
+ >(({transformOrigin}) => {
42
42
  if (transformOrigin == null) {
43
43
  return {};
44
44
  }
@@ -81,6 +81,7 @@ export const PopupCard = createSubcomponent('div')({
81
81
  elemProps.margin ? space[elemProps.margin as CanvasSpaceKeys] || elemProps.margin : space.xl
82
82
  } * 2)`}
83
83
  overflowY="auto" // force IE11 to limit the flex size of the card. Without this, the body isn't allowed to overflow properly: https://github.com/philipwalton/flexbugs/issues/216#issuecomment-453053557
84
+ {...type.levels.subtext.large}
84
85
  {...elemProps}
85
86
  >
86
87
  {children}
@@ -8,13 +8,8 @@ import {
8
8
  Themeable,
9
9
  useUniqueId,
10
10
  } from '@workday/canvas-kit-react/common';
11
- import {
12
- canvas,
13
- borderRadius,
14
- colors,
15
- inputColors,
16
- spaceNumbers,
17
- } from '@workday/canvas-kit-react/tokens';
11
+ import {borderRadius, colors, inputColors, spaceNumbers} from '@workday/canvas-kit-react/tokens';
12
+ import {LabelText} from '@workday/canvas-kit-react/text';
18
13
 
19
14
  export interface RadioProps extends Themeable {
20
15
  /**
@@ -277,21 +272,6 @@ const RadioCheck = styled('div')<Pick<RadioProps, 'checked' | 'variant'>>(
277
272
  })
278
273
  );
279
274
 
280
- const RadioLabel = styled('label')<{disabled?: boolean; variant?: 'inverse' | undefined}>(
281
- {
282
- ...canvas.type.levels.subtext.large,
283
- paddingLeft: radioLabelDistance,
284
- },
285
- ({variant}) => (variant === 'inverse' ? {color: colors.frenchVanilla100} : undefined),
286
- ({disabled, variant}) =>
287
- disabled
288
- ? {
289
- color: variant === 'inverse' ? colors.frenchVanilla100 : inputColors.disabled.text,
290
- opacity: variant === 'inverse' ? '.4' : '1',
291
- }
292
- : {cursor: 'pointer'}
293
- );
294
-
295
275
  export const Radio = createComponent('input')({
296
276
  displayName: 'Radio',
297
277
  Component: (
@@ -333,9 +313,14 @@ export const Radio = createComponent('input')({
333
313
  </RadioBackground>
334
314
  </RadioInputWrapper>
335
315
  {label && (
336
- <RadioLabel htmlFor={inputId} disabled={disabled} variant={variant}>
316
+ <LabelText
317
+ paddingLeft={radioLabelDistance}
318
+ htmlFor={inputId}
319
+ disabled={disabled}
320
+ variant={variant}
321
+ >
337
322
  {label}
338
- </RadioLabel>
323
+ </LabelText>
339
324
  )}
340
325
  </RadioContainer>
341
326
  );
@@ -3,9 +3,10 @@ import styled from '@emotion/styled';
3
3
  import throttle from 'lodash/throttle';
4
4
 
5
5
  import {CanvasSystemIcon} from '@workday/design-assets-types';
6
- import {colors, space, type, CanvasSpaceValues} from '@workday/canvas-kit-react/tokens';
6
+ import {colors, space, CanvasSpaceValues} from '@workday/canvas-kit-react/tokens';
7
7
  import {TertiaryButton, TertiaryButtonProps} from '@workday/canvas-kit-react/button';
8
8
  import {chevronLeftIcon, chevronRightIcon} from '@workday/canvas-system-icons-web';
9
+ import {Heading} from '@workday/canvas-kit-react/text';
9
10
 
10
11
  export interface SidePanelProps extends React.HTMLAttributes<HTMLDivElement> {
11
12
  /**
@@ -78,11 +79,6 @@ export enum SidePanelBackgroundColor {
78
79
 
79
80
  const closedWidth = space.xxl;
80
81
 
81
- const Header = styled('h2')({
82
- ...type.levels.heading.small,
83
- marginTop: space.zero,
84
- });
85
-
86
82
  const SidePanelContainer = styled('div')<
87
83
  Pick<SidePanelProps, 'open' | 'backgroundColor' | 'padding' | 'openWidth' | 'openDirection'>
88
84
  >(
@@ -214,7 +210,11 @@ export class SidePanel extends React.Component<SidePanelProps, SidePanelState> {
214
210
  {...elemProps}
215
211
  >
216
212
  <ChildrenContainer open={open} openWidth={openWidth}>
217
- {header && open ? <Header>{header}</Header> : null}
213
+ {header && open ? (
214
+ <Heading as="h2" size="small" marginTop="zero">
215
+ {header}
216
+ </Heading>
217
+ ) : null}
218
218
  {this.props.children}
219
219
  </ChildrenContainer>
220
220
  <SidePanelFooter openWidth={openWidth} open={open}>