@workday/canvas-kit-react 8.0.0-alpha.208-next.1 → 8.0.0-alpha.216-next.4

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 (230) hide show
  1. package/common/lib/utils/elements.ts +4 -4
  2. package/dist/commonjs/card/lib/Card.d.ts +1 -1
  3. package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
  4. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  5. package/dist/commonjs/common/lib/utils/elements.d.ts +1 -1
  6. package/dist/commonjs/common/lib/utils/elements.d.ts.map +1 -1
  7. package/dist/commonjs/common/lib/utils/elements.js +3 -3
  8. package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
  9. package/dist/commonjs/icon/lib/SystemIcon.d.ts +1 -1
  10. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  11. package/dist/commonjs/layout/index.d.ts +8 -4
  12. package/dist/commonjs/layout/index.d.ts.map +1 -1
  13. package/dist/commonjs/layout/index.js +10 -2
  14. package/dist/commonjs/layout/lib/Box.d.ts +6 -4
  15. package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
  16. package/dist/commonjs/layout/lib/Box.js +8 -9
  17. package/dist/commonjs/layout/lib/Flex.d.ts +5 -2
  18. package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
  19. package/dist/commonjs/layout/lib/Flex.js +5 -1
  20. package/dist/commonjs/layout/lib/Grid.d.ts +5 -6
  21. package/dist/commonjs/layout/lib/Grid.d.ts.map +1 -1
  22. package/dist/commonjs/layout/lib/Grid.js +2 -2
  23. package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
  24. package/dist/commonjs/layout/lib/utils/background.d.ts +44 -0
  25. package/dist/commonjs/layout/lib/utils/background.d.ts.map +1 -0
  26. package/dist/commonjs/layout/lib/utils/background.js +57 -0
  27. package/dist/commonjs/layout/lib/utils/border/color.d.ts +47 -0
  28. package/dist/commonjs/layout/lib/utils/border/color.d.ts.map +1 -0
  29. package/dist/commonjs/layout/lib/utils/border/color.js +42 -0
  30. package/dist/commonjs/layout/lib/utils/border/index.d.ts +26 -0
  31. package/dist/commonjs/layout/lib/utils/border/index.d.ts.map +1 -0
  32. package/dist/commonjs/layout/lib/utils/border/index.js +46 -0
  33. package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts +38 -0
  34. package/dist/commonjs/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
  35. package/dist/commonjs/layout/lib/utils/border/lineStyle.js +52 -0
  36. package/dist/commonjs/layout/lib/utils/border/radius.d.ts +33 -0
  37. package/dist/commonjs/layout/lib/utils/border/radius.d.ts.map +1 -0
  38. package/dist/commonjs/layout/lib/utils/border/radius.js +32 -0
  39. package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts +34 -0
  40. package/dist/commonjs/layout/lib/utils/border/shorthand.d.ts.map +1 -0
  41. package/dist/commonjs/layout/lib/utils/border/shorthand.js +42 -0
  42. package/dist/commonjs/layout/lib/utils/border/width.d.ts +34 -0
  43. package/dist/commonjs/layout/lib/utils/border/width.d.ts.map +1 -0
  44. package/dist/commonjs/layout/lib/utils/border/width.js +42 -0
  45. package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts +12 -0
  46. package/dist/commonjs/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
  47. package/dist/commonjs/layout/lib/utils/buildStyleFns.js +90 -0
  48. package/dist/commonjs/layout/lib/utils/color.d.ts +23 -16
  49. package/dist/commonjs/layout/lib/utils/color.d.ts.map +1 -1
  50. package/dist/commonjs/layout/lib/utils/color.js +25 -49
  51. package/dist/commonjs/layout/lib/utils/depth.d.ts +17 -11
  52. package/dist/commonjs/layout/lib/utils/depth.d.ts.map +1 -1
  53. package/dist/commonjs/layout/lib/utils/depth.js +20 -20
  54. package/dist/commonjs/layout/lib/utils/flex.d.ts +31 -12
  55. package/dist/commonjs/layout/lib/utils/flex.d.ts.map +1 -1
  56. package/dist/commonjs/layout/lib/utils/flex.js +58 -25
  57. package/dist/commonjs/layout/lib/utils/flexItem.d.ts +18 -15
  58. package/dist/commonjs/layout/lib/utils/flexItem.d.ts.map +1 -1
  59. package/dist/commonjs/layout/lib/utils/flexItem.js +43 -26
  60. package/dist/commonjs/layout/lib/utils/grid.d.ts +40 -35
  61. package/dist/commonjs/layout/lib/utils/grid.d.ts.map +1 -1
  62. package/dist/commonjs/layout/lib/utils/grid.js +99 -72
  63. package/dist/commonjs/layout/lib/utils/gridItem.d.ts +17 -14
  64. package/dist/commonjs/layout/lib/utils/gridItem.d.ts.map +1 -1
  65. package/dist/commonjs/layout/lib/utils/gridItem.js +58 -30
  66. package/dist/commonjs/layout/lib/utils/layout.d.ts +47 -25
  67. package/dist/commonjs/layout/lib/utils/layout.d.ts.map +1 -1
  68. package/dist/commonjs/layout/lib/utils/layout.js +71 -33
  69. package/dist/commonjs/layout/lib/utils/other.d.ts +44 -2
  70. package/dist/commonjs/layout/lib/utils/other.d.ts.map +1 -1
  71. package/dist/commonjs/layout/lib/utils/other.js +101 -17
  72. package/dist/commonjs/layout/lib/utils/position.d.ts +37 -20
  73. package/dist/commonjs/layout/lib/utils/position.d.ts.map +1 -1
  74. package/dist/commonjs/layout/lib/utils/position.js +49 -66
  75. package/dist/commonjs/layout/lib/utils/space.d.ts +107 -51
  76. package/dist/commonjs/layout/lib/utils/space.d.ts.map +1 -1
  77. package/dist/commonjs/layout/lib/utils/space.js +98 -148
  78. package/dist/commonjs/layout/lib/utils/stack.d.ts +3 -6
  79. package/dist/commonjs/layout/lib/utils/stack.d.ts.map +1 -1
  80. package/dist/commonjs/layout/lib/utils/stack.js +13 -39
  81. package/dist/commonjs/layout/lib/utils/systemProps.d.ts +31 -0
  82. package/dist/commonjs/layout/lib/utils/systemProps.d.ts.map +1 -0
  83. package/dist/commonjs/layout/lib/utils/systemProps.js +2 -0
  84. package/dist/commonjs/layout/lib/utils/text.d.ts +33 -15
  85. package/dist/commonjs/layout/lib/utils/text.d.ts.map +1 -1
  86. package/dist/commonjs/layout/lib/utils/text.js +74 -38
  87. package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
  88. package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
  89. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
  90. package/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  91. package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +72 -1
  92. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  93. package/dist/commonjs/tokens/lib/colors.types.d.ts +4 -6
  94. package/dist/commonjs/tokens/lib/colors.types.d.ts.map +1 -1
  95. package/dist/es6/card/lib/Card.d.ts +1 -1
  96. package/dist/es6/card/lib/CardBody.d.ts +1 -1
  97. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  98. package/dist/es6/common/lib/utils/elements.d.ts +1 -1
  99. package/dist/es6/common/lib/utils/elements.d.ts.map +1 -1
  100. package/dist/es6/common/lib/utils/elements.js +3 -3
  101. package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
  102. package/dist/es6/icon/lib/SystemIcon.d.ts +1 -1
  103. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  104. package/dist/es6/layout/index.d.ts +8 -4
  105. package/dist/es6/layout/index.d.ts.map +1 -1
  106. package/dist/es6/layout/index.js +7 -1
  107. package/dist/es6/layout/lib/Box.d.ts +6 -4
  108. package/dist/es6/layout/lib/Box.d.ts.map +1 -1
  109. package/dist/es6/layout/lib/Box.js +8 -9
  110. package/dist/es6/layout/lib/Flex.d.ts +5 -2
  111. package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
  112. package/dist/es6/layout/lib/Flex.js +5 -1
  113. package/dist/es6/layout/lib/Grid.d.ts +5 -6
  114. package/dist/es6/layout/lib/Grid.d.ts.map +1 -1
  115. package/dist/es6/layout/lib/Grid.js +2 -2
  116. package/dist/es6/layout/lib/Stack.d.ts +4 -4
  117. package/dist/es6/layout/lib/utils/background.d.ts +44 -0
  118. package/dist/es6/layout/lib/utils/background.d.ts.map +1 -0
  119. package/dist/es6/layout/lib/utils/background.js +54 -0
  120. package/dist/es6/layout/lib/utils/border/color.d.ts +47 -0
  121. package/dist/es6/layout/lib/utils/border/color.d.ts.map +1 -0
  122. package/dist/es6/layout/lib/utils/border/color.js +39 -0
  123. package/dist/es6/layout/lib/utils/border/index.d.ts +26 -0
  124. package/dist/es6/layout/lib/utils/border/index.d.ts.map +1 -0
  125. package/dist/es6/layout/lib/utils/border/index.js +43 -0
  126. package/dist/es6/layout/lib/utils/border/lineStyle.d.ts +38 -0
  127. package/dist/es6/layout/lib/utils/border/lineStyle.d.ts.map +1 -0
  128. package/dist/es6/layout/lib/utils/border/lineStyle.js +49 -0
  129. package/dist/es6/layout/lib/utils/border/radius.d.ts +33 -0
  130. package/dist/es6/layout/lib/utils/border/radius.d.ts.map +1 -0
  131. package/dist/es6/layout/lib/utils/border/radius.js +29 -0
  132. package/dist/es6/layout/lib/utils/border/shorthand.d.ts +34 -0
  133. package/dist/es6/layout/lib/utils/border/shorthand.d.ts.map +1 -0
  134. package/dist/es6/layout/lib/utils/border/shorthand.js +39 -0
  135. package/dist/es6/layout/lib/utils/border/width.d.ts +34 -0
  136. package/dist/es6/layout/lib/utils/border/width.d.ts.map +1 -0
  137. package/dist/es6/layout/lib/utils/border/width.js +39 -0
  138. package/dist/es6/layout/lib/utils/buildStyleFns.d.ts +12 -0
  139. package/dist/es6/layout/lib/utils/buildStyleFns.d.ts.map +1 -0
  140. package/dist/es6/layout/lib/utils/buildStyleFns.js +85 -0
  141. package/dist/es6/layout/lib/utils/color.d.ts +23 -16
  142. package/dist/es6/layout/lib/utils/color.d.ts.map +1 -1
  143. package/dist/es6/layout/lib/utils/color.js +24 -47
  144. package/dist/es6/layout/lib/utils/depth.d.ts +17 -11
  145. package/dist/es6/layout/lib/utils/depth.d.ts.map +1 -1
  146. package/dist/es6/layout/lib/utils/depth.js +19 -18
  147. package/dist/es6/layout/lib/utils/flex.d.ts +31 -12
  148. package/dist/es6/layout/lib/utils/flex.d.ts.map +1 -1
  149. package/dist/es6/layout/lib/utils/flex.js +57 -23
  150. package/dist/es6/layout/lib/utils/flexItem.d.ts +18 -15
  151. package/dist/es6/layout/lib/utils/flexItem.d.ts.map +1 -1
  152. package/dist/es6/layout/lib/utils/flexItem.js +42 -24
  153. package/dist/es6/layout/lib/utils/grid.d.ts +40 -35
  154. package/dist/es6/layout/lib/utils/grid.d.ts.map +1 -1
  155. package/dist/es6/layout/lib/utils/grid.js +98 -70
  156. package/dist/es6/layout/lib/utils/gridItem.d.ts +17 -14
  157. package/dist/es6/layout/lib/utils/gridItem.d.ts.map +1 -1
  158. package/dist/es6/layout/lib/utils/gridItem.js +57 -28
  159. package/dist/es6/layout/lib/utils/layout.d.ts +47 -25
  160. package/dist/es6/layout/lib/utils/layout.d.ts.map +1 -1
  161. package/dist/es6/layout/lib/utils/layout.js +70 -31
  162. package/dist/es6/layout/lib/utils/other.d.ts +44 -2
  163. package/dist/es6/layout/lib/utils/other.d.ts.map +1 -1
  164. package/dist/es6/layout/lib/utils/other.js +100 -15
  165. package/dist/es6/layout/lib/utils/position.d.ts +37 -20
  166. package/dist/es6/layout/lib/utils/position.d.ts.map +1 -1
  167. package/dist/es6/layout/lib/utils/position.js +48 -64
  168. package/dist/es6/layout/lib/utils/space.d.ts +107 -51
  169. package/dist/es6/layout/lib/utils/space.d.ts.map +1 -1
  170. package/dist/es6/layout/lib/utils/space.js +97 -146
  171. package/dist/es6/layout/lib/utils/stack.d.ts +3 -6
  172. package/dist/es6/layout/lib/utils/stack.d.ts.map +1 -1
  173. package/dist/es6/layout/lib/utils/stack.js +13 -39
  174. package/dist/es6/layout/lib/utils/systemProps.d.ts +31 -0
  175. package/dist/es6/layout/lib/utils/systemProps.d.ts.map +1 -0
  176. package/dist/es6/layout/lib/utils/systemProps.js +1 -0
  177. package/dist/es6/layout/lib/utils/text.d.ts +33 -15
  178. package/dist/es6/layout/lib/utils/text.d.ts.map +1 -1
  179. package/dist/es6/layout/lib/utils/text.js +73 -36
  180. package/dist/es6/modal/lib/Modal.d.ts +1 -1
  181. package/dist/es6/popup/lib/Popup.d.ts +1 -1
  182. package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
  183. package/dist/es6/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  184. package/dist/es6/popup/lib/hooks/useReturnFocus.js +73 -2
  185. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  186. package/dist/es6/tokens/lib/colors.types.d.ts +4 -6
  187. package/dist/es6/tokens/lib/colors.types.d.ts.map +1 -1
  188. package/icon/lib/SystemIcon.tsx +1 -1
  189. package/layout/index.ts +8 -4
  190. package/layout/lib/Box.tsx +10 -36
  191. package/layout/lib/Flex.tsx +5 -1
  192. package/layout/lib/Grid.tsx +3 -4
  193. package/layout/lib/utils/background.ts +83 -0
  194. package/layout/lib/utils/border/color.ts +85 -0
  195. package/layout/lib/utils/border/index.ts +49 -0
  196. package/layout/lib/utils/border/lineStyle.ts +87 -0
  197. package/layout/lib/utils/border/radius.ts +61 -0
  198. package/layout/lib/utils/border/shorthand.ts +73 -0
  199. package/layout/lib/utils/border/width.ts +73 -0
  200. package/layout/lib/utils/buildStyleFns.ts +117 -0
  201. package/layout/lib/utils/color.ts +40 -55
  202. package/layout/lib/utils/depth.ts +28 -24
  203. package/layout/lib/utils/flex.ts +83 -32
  204. package/layout/lib/utils/flexItem.ts +54 -36
  205. package/layout/lib/utils/grid.ts +131 -94
  206. package/layout/lib/utils/gridItem.ts +69 -41
  207. package/layout/lib/utils/layout.ts +109 -50
  208. package/layout/lib/utils/other.ts +142 -15
  209. package/layout/lib/utils/position.ts +79 -73
  210. package/layout/lib/utils/space.ts +202 -196
  211. package/layout/lib/utils/stack.ts +19 -45
  212. package/layout/lib/utils/systemProps.ts +46 -0
  213. package/layout/lib/utils/text.ts +99 -34
  214. package/package.json +3 -3
  215. package/popup/lib/hooks/useReturnFocus.tsx +82 -3
  216. package/tokens/lib/colors.types.ts +4 -7
  217. package/dist/commonjs/layout/lib/utils/border.d.ts +0 -103
  218. package/dist/commonjs/layout/lib/utils/border.d.ts.map +0 -1
  219. package/dist/commonjs/layout/lib/utils/border.js +0 -153
  220. package/dist/commonjs/layout/lib/utils/font.d.ts +0 -29
  221. package/dist/commonjs/layout/lib/utils/font.d.ts.map +0 -1
  222. package/dist/commonjs/layout/lib/utils/font.js +0 -57
  223. package/dist/es6/layout/lib/utils/border.d.ts +0 -103
  224. package/dist/es6/layout/lib/utils/border.d.ts.map +0 -1
  225. package/dist/es6/layout/lib/utils/border.js +0 -149
  226. package/dist/es6/layout/lib/utils/font.d.ts +0 -29
  227. package/dist/es6/layout/lib/utils/font.d.ts.map +0 -1
  228. package/dist/es6/layout/lib/utils/font.js +0 -53
  229. package/layout/lib/utils/border.ts +0 -263
  230. package/layout/lib/utils/font.ts +0 -67
@@ -4,10 +4,9 @@ import {createComponent, StyledType} from '@workday/canvas-kit-react/common';
4
4
  import {Box, BoxProps} from './Box';
5
5
 
6
6
  import {grid, GridStyleProps} from './utils/grid';
7
- import {GridItemStyleProps} from './utils/gridItem';
8
7
 
9
8
  export type GridProps = BoxProps & GridStyleProps;
10
- export type GridItemProps = BoxProps & GridItemStyleProps;
9
+ export type GridItemProps = BoxProps;
11
10
 
12
11
  const StyledGrid = styled(Box)<StyledType & GridProps>(
13
12
  {
@@ -30,11 +29,11 @@ const GridItem = createComponent('div')({
30
29
  /**
31
30
  * `Grid` is a two-dimensional layout system for the web. It lets you lay content out in rows and columns.
32
31
  * It is highly flexible, and can be used on its own or to build other components.
32
+ * `Grid` is built on top of `Box` and has access to all `BoxProps`.
33
33
  *
34
34
  * @example
35
- * ```
35
+ * ```tsx
36
36
  * import { Grid } from '@workday/canvas-kit-react/layout';
37
- * `Grid` is built on top of `Box` and has access to all `BoxProps`.
38
37
  *
39
38
  * interface CardProps extends GridProps {
40
39
  * // card-specific props
@@ -0,0 +1,83 @@
1
+ import {Property} from 'csstype';
2
+
3
+ import {buildStyleFns, buildStylePropFn, StyleFnConfig} from './buildStyleFns';
4
+ import {SystemPropValues} from './systemProps';
5
+
6
+ /** style props to set CSS background properties */
7
+ export type BackgroundStyleProps = {
8
+ /**
9
+ * - sets [CSS background property](https://developer.mozilla.org/en-US/docs/Web/CSS/background)
10
+ * - system tokens: `color`
11
+ * */
12
+ background?: SystemPropValues['color'];
13
+ /** sets [CSS background-attachment property](https://developer.mozilla.org/en-US/docs/Web/CSS/) */
14
+ backgroundAttachment?: Property.BackgroundAttachment;
15
+ /**
16
+ * - sets [CSS background-color property](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color)
17
+ * - system tokens: `color`
18
+ * */
19
+ backgroundColor?: SystemPropValues['color'];
20
+ /** sets [CSS background-image property](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) */
21
+ backgroundImage?: Property.BackgroundImage;
22
+ /** sets [CSS background-position property](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) */
23
+ backgroundPosition?: Property.BackgroundPosition;
24
+ /** sets [CSS background-repeat property](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) */
25
+ backgroundRepeat?: Property.BackgroundRepeat;
26
+ /** sets [CSS background-size property](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) */
27
+ backgroundSize?: Property.BackgroundSize;
28
+ };
29
+
30
+ export const backgroundStyleFnConfigs: StyleFnConfig[] = [
31
+ {
32
+ name: 'background',
33
+ properties: ['background'],
34
+ system: 'color',
35
+ },
36
+ {
37
+ name: 'backgroundAttachment',
38
+ properties: ['backgroundAttachment'],
39
+ system: 'none',
40
+ },
41
+ {
42
+ name: 'backgroundColor',
43
+ properties: ['backgroundColor'],
44
+ system: 'color',
45
+ },
46
+ {
47
+ name: 'backgroundImage',
48
+ properties: ['backgroundImage'],
49
+ system: 'none',
50
+ },
51
+ {
52
+ name: 'backgroundPosition',
53
+ properties: ['backgroundPosition'],
54
+ system: 'none',
55
+ },
56
+ {
57
+ name: 'backgroundRepeat',
58
+ properties: ['backgroundRepeat'],
59
+ system: 'none',
60
+ },
61
+ {
62
+ name: 'backgroundSize',
63
+ properties: ['backgroundSize'],
64
+ system: 'none',
65
+ },
66
+ ];
67
+
68
+ export const backgroundFns = buildStyleFns(backgroundStyleFnConfigs);
69
+ /**
70
+ * A style prop function that takes component props and returns border styles.
71
+ * Some props, such as background and backgroundColor, are connected to our design tokens.
72
+ * If no `BackgroundStyleProps` are found, it returns an empty object.
73
+ *
74
+ * @example
75
+ * ```tsx
76
+ * const BackgroundExample = () => (
77
+ * <Box backgroundColor="blueberry500">
78
+ * Hello, background styles!
79
+ * </Box>
80
+ * );
81
+ *```
82
+ */
83
+ export const background = buildStylePropFn<BackgroundStyleProps>(backgroundFns);
@@ -0,0 +1,85 @@
1
+ import {buildStyleFns, StyleFnConfig} from '../buildStyleFns';
2
+ import {SystemPropValues} from '../systemProps';
3
+
4
+ /** style props to set CSS border color properties */
5
+ export type BorderColorStyleProps = {
6
+ /**
7
+ * - sets [CSS border-color property]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-color)
8
+ * - system tokens: `color`
9
+ */
10
+ borderColor?: SystemPropValues['color'];
11
+ /**
12
+ * - sets [CSS border-top-color property]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-color)
13
+ * - system tokens: `color`
14
+ */
15
+ borderTopColor?: SystemPropValues['color'];
16
+ /**
17
+ * - sets [CSS border-right-color property]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-color)
18
+ * - no bidirectional support
19
+ * - system tokens: `color`
20
+ */
21
+ borderRightColor?: SystemPropValues['color'];
22
+ /**
23
+ * - sets [CSS border-bottom-color property]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-color)
24
+ * - system tokens: `color`
25
+ */
26
+ borderBottomColor?: SystemPropValues['color'];
27
+ /**
28
+ * - sets [CSS border-left-color property]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-color)
29
+ * - no bidirectional support
30
+ * - system tokens: `color`
31
+ */
32
+ borderLeftColor?: SystemPropValues['color'];
33
+ /**
34
+ * - sets [CSS border-inline-start-color property ]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-color)
35
+ * - bidirectional support
36
+ * - system tokens: `color`
37
+ */
38
+ borderInlineStartColor?: SystemPropValues['color'];
39
+ /**
40
+ * - sets [CSS border-inline-end-color property ]((https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end-color)
41
+ * - bidirectional support
42
+ * - system tokens: `color`
43
+ */
44
+ borderInlineEndColor?: SystemPropValues['color'];
45
+ };
46
+
47
+ export const borderColorStyleFnConfigs: StyleFnConfig[] = [
48
+ {
49
+ name: 'borderColor',
50
+ properties: ['borderColor'],
51
+ system: 'color',
52
+ },
53
+ {
54
+ name: 'borderTopColor',
55
+ properties: ['borderTopColor'],
56
+ system: 'color',
57
+ },
58
+ {
59
+ name: 'borderRightColor',
60
+ properties: ['borderRightColor'],
61
+ system: 'color',
62
+ },
63
+ {
64
+ name: 'borderBottomColor',
65
+ properties: ['borderBottomColor'],
66
+ system: 'color',
67
+ },
68
+ {
69
+ name: 'borderLeftColor',
70
+ properties: ['borderLeftColor'],
71
+ system: 'color',
72
+ },
73
+ {
74
+ name: 'borderInlineStartColor',
75
+ properties: ['borderInlineStartColor'],
76
+ system: 'color',
77
+ },
78
+ {
79
+ name: 'borderInlineEndColor',
80
+ properties: ['borderInlineEndColor'],
81
+ system: 'color',
82
+ },
83
+ ];
84
+
85
+ export const borderColorFns = buildStyleFns(borderColorStyleFnConfigs);
@@ -0,0 +1,49 @@
1
+ import {buildStylePropFn} from '../buildStyleFns';
2
+ import {BorderColorStyleProps, borderColorFns, borderColorStyleFnConfigs} from './color';
3
+ import {BorderLineStyleProps, borderLineStyleFns, borderLineStyleFnConfigs} from './lineStyle';
4
+ import {BorderRadiusStyleProps, borderRadiusFns, borderRadiusStyleFnConfigs} from './radius';
5
+ import {
6
+ BorderShorthandStyleProps,
7
+ borderShorthandFns,
8
+ borderShorthandStyleFnConfigs,
9
+ } from './shorthand';
10
+ import {BorderWidthStyleProps, borderWidthFns, borderWidthStyleFnConfigs} from './width';
11
+
12
+ export type BorderStyleProps = BorderColorStyleProps &
13
+ BorderLineStyleProps &
14
+ BorderRadiusStyleProps &
15
+ BorderShorthandStyleProps &
16
+ BorderWidthStyleProps;
17
+
18
+ /**
19
+ * A style prop function that takes component props and returns border styles. Some props, such as borderRadius and borderColor, are connected to our design tokens.
20
+ * If no `BorderStyleProps` are found, it returns an empty object.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * const BorderExample = () => (
25
+ * <Box
26
+ * border="solid 1px"
27
+ * borderColor="soap500"
28
+ * borderRadius="l"
29
+ * >
30
+ * Hello, border styles!
31
+ * </Box>
32
+ * );
33
+ *```
34
+ */
35
+ export const border = buildStylePropFn<BorderStyleProps>({
36
+ ...borderColorFns,
37
+ ...borderLineStyleFns,
38
+ ...borderRadiusFns,
39
+ ...borderShorthandFns,
40
+ ...borderWidthFns,
41
+ });
42
+
43
+ export const borderStyleFnConfigs = [
44
+ ...borderColorStyleFnConfigs,
45
+ ...borderLineStyleFnConfigs,
46
+ ...borderRadiusStyleFnConfigs,
47
+ ...borderShorthandStyleFnConfigs,
48
+ ...borderWidthStyleFnConfigs,
49
+ ];
@@ -0,0 +1,87 @@
1
+ import {Property} from 'csstype';
2
+
3
+ import {buildStyleFns, StyleFnConfig} from '../buildStyleFns';
4
+
5
+ /** style props to set CSS border style properties */
6
+ export type BorderLineStyleProps = {
7
+ /** sets [CSS border-collapse property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse) */
8
+ borderCollapse?: Property.BorderCollapse;
9
+ /** sets [CSS border-spacing property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-spacing) */
10
+ borderSpacing?: Property.BorderSpacing;
11
+ /** sets [CSS border-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-style) */
12
+ borderStyle?: Property.Border;
13
+ /** sets [CSS border-top-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-style) */
14
+ borderTopStyle?: Property.Border;
15
+ /**
16
+ * - sets [CSS border-right-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-style)
17
+ * - no bidirectional support
18
+ */
19
+ borderRightStyle?: Property.Border;
20
+ /** sets [CSS border-bottom-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-style) */
21
+ borderBottomStyle?: Property.Border;
22
+ /**
23
+ * - sets [CSS border-left-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-style)
24
+ * - no bidirectional support
25
+ */
26
+ borderLeftStyle?: Property.Border;
27
+ /**
28
+ * - sets [CSS border-inline-start-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-style)
29
+ * - bidirectional support
30
+ */
31
+ borderInlineStartStyle?: Property.Border;
32
+ /**
33
+ * - sets [CSS border-inline-end-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end-style)
34
+ * - bidirectional support
35
+ */
36
+ borderInlineEndStyle?: Property.Border;
37
+ };
38
+
39
+ export const borderLineStyleFnConfigs: StyleFnConfig[] = [
40
+ {
41
+ name: 'borderCollapse',
42
+ properties: ['borderCollapse'],
43
+ system: 'none',
44
+ },
45
+ {
46
+ name: 'borderSpacing',
47
+ properties: ['borderSpacing'],
48
+ system: 'none',
49
+ },
50
+ {
51
+ name: 'borderStyle',
52
+ properties: ['borderStyle'],
53
+ system: 'none',
54
+ },
55
+ {
56
+ name: 'borderTopStyle',
57
+ properties: ['borderTopStyle'],
58
+ system: 'none',
59
+ },
60
+ {
61
+ name: 'borderRightStyle',
62
+ properties: ['borderRightStyle'],
63
+ system: 'none',
64
+ },
65
+ {
66
+ name: 'borderBottomStyle',
67
+ properties: ['borderBottomStyle'],
68
+ system: 'none',
69
+ },
70
+ {
71
+ name: 'borderLeftStyle',
72
+ properties: ['borderLeftStyle'],
73
+ system: 'none',
74
+ },
75
+ {
76
+ name: 'borderInlineStartStyle',
77
+ properties: ['borderInlineStartStyle'],
78
+ system: 'none',
79
+ },
80
+ {
81
+ name: 'borderInlineEndStyle',
82
+ properties: ['borderInlineEndStyle'],
83
+ system: 'none',
84
+ },
85
+ ];
86
+
87
+ export const borderLineStyleFns = buildStyleFns(borderLineStyleFnConfigs);
@@ -0,0 +1,61 @@
1
+ import {buildStyleFns, StyleFnConfig} from '../buildStyleFns';
2
+ import {SystemPropValues} from '../systemProps';
3
+
4
+ /** style props to set CSS border radius properties */
5
+ export type BorderRadiusStyleProps = {
6
+ /**
7
+ * - sets [CSS border-radius property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius)
8
+ * - system tokens: `shape`
9
+ * */
10
+ borderRadius?: SystemPropValues['shape'];
11
+ /**
12
+ * - sets [CSS border-top-left-radius property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-left-radius)
13
+ * - system tokens: `shape`
14
+ * */
15
+ borderTopLeftRadius?: SystemPropValues['shape'];
16
+ /**
17
+ * - sets [CSS border-top-right-radius property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius)
18
+ * - system tokens: `shape`
19
+ * */
20
+ borderTopRightRadius?: SystemPropValues['shape'];
21
+ /**
22
+ * - sets [CSS border-bottom-left-radius property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-left-radius)
23
+ * - system tokens: `shape`
24
+ * */
25
+ borderBottomLeftRadius?: SystemPropValues['shape'];
26
+ /**
27
+ * - sets [CSS border-bottom-right-radius property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-right-radius)
28
+ * - system tokens: `shape`
29
+ * */
30
+ borderBottomRightRadius?: SystemPropValues['shape'];
31
+ };
32
+
33
+ export const borderRadiusStyleFnConfigs: StyleFnConfig[] = [
34
+ {
35
+ name: 'borderRadius',
36
+ properties: ['borderRadius'],
37
+ system: 'shape',
38
+ },
39
+ {
40
+ name: 'borderTopLeftRadius',
41
+ properties: ['borderTopLeftRadius'],
42
+ system: 'shape',
43
+ },
44
+ {
45
+ name: 'borderTopRightRadius',
46
+ properties: ['borderTopRightRadius'],
47
+ system: 'shape',
48
+ },
49
+ {
50
+ name: 'borderBottomLeftRadius',
51
+ properties: ['borderBottomLeftRadius'],
52
+ system: 'shape',
53
+ },
54
+ {
55
+ name: 'borderBottomRightRadius',
56
+ properties: ['borderBottomRightRadius'],
57
+ system: 'shape',
58
+ },
59
+ ];
60
+
61
+ export const borderRadiusFns = buildStyleFns(borderRadiusStyleFnConfigs);
@@ -0,0 +1,73 @@
1
+ import {Property} from 'csstype';
2
+
3
+ import {buildStyleFns, StyleFnConfig} from '../buildStyleFns';
4
+
5
+ /** style props to set CSS border properties */
6
+ export type BorderShorthandStyleProps = {
7
+ /** sets [CSS border property](https://developer.mozilla.org/en-US/docs/Web/CSS/border) */
8
+ border?: Property.Border;
9
+ /** sets [CSS border-top property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) */
10
+ borderTop?: Property.BorderTop;
11
+ /**
12
+ * - sets [CSS border-right property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right)
13
+ * - no bidirectional support
14
+ * */
15
+ borderRight?: Property.BorderRight;
16
+ /** sets [CSS border-bottom property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) */
17
+ borderBottom?: Property.BorderBottom;
18
+ /**
19
+ * - sets [CSS border-left property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left)
20
+ * - no bidirectional support
21
+ * */
22
+ borderLeft?: Property.BorderLeft;
23
+ /**
24
+ * - sets [CSS border-inline-start property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start)
25
+ * - bidirectional support
26
+ * */
27
+ borderInlineStart?: Property.BorderInlineStart;
28
+ /**
29
+ * - sets [CSS border-inline-end property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end)
30
+ * - bidirectional support
31
+ * */
32
+ borderInlineEnd?: Property.BorderInlineEnd;
33
+ };
34
+
35
+ export const borderShorthandStyleFnConfigs: StyleFnConfig[] = [
36
+ {
37
+ name: 'border',
38
+ properties: ['border'],
39
+ system: 'none',
40
+ },
41
+ {
42
+ name: 'borderTop',
43
+ properties: ['borderTop'],
44
+ system: 'none',
45
+ },
46
+ {
47
+ name: 'borderRight',
48
+ properties: ['borderRight'],
49
+ system: 'none',
50
+ },
51
+ {
52
+ name: 'borderBottom',
53
+ properties: ['borderBottom'],
54
+ system: 'none',
55
+ },
56
+ {
57
+ name: 'borderLeft',
58
+ properties: ['borderLeft'],
59
+ system: 'none',
60
+ },
61
+ {
62
+ name: 'borderInlineStart',
63
+ properties: ['borderInlineStart'],
64
+ system: 'none',
65
+ },
66
+ {
67
+ name: 'borderInlineEnd',
68
+ properties: ['borderInlineEnd'],
69
+ system: 'none',
70
+ },
71
+ ];
72
+
73
+ export const borderShorthandFns = buildStyleFns(borderShorthandStyleFnConfigs);
@@ -0,0 +1,73 @@
1
+ import {Property} from 'csstype';
2
+
3
+ import {buildStyleFns, StyleFnConfig} from '../buildStyleFns';
4
+
5
+ /** style props to set CSS border width properties */
6
+ export type BorderWidthStyleProps = {
7
+ /** sets [CSS border-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-width) */
8
+ borderWidth?: Property.BorderWidth | number;
9
+ /** sets [CSS border-top-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-width) */
10
+ borderTopWidth?: Property.BorderTopWidth | number;
11
+ /**
12
+ * - sets [CSS border-right-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-width)
13
+ * - no bidirectional support
14
+ * */
15
+ borderRightWidth?: Property.BorderRightWidth | number;
16
+ /** sets [CSS border-bottom-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-width) */
17
+ borderBottomWidth?: Property.BorderBottomWidth | number;
18
+ /**
19
+ * - sets [CSS border-left-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-width)
20
+ * - no bidirectional support
21
+ * */
22
+ borderLeftWidth?: Property.BorderLeftWidth | number;
23
+ /**
24
+ * - sets [CSS border-inline-start-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-width)
25
+ * - bidirectional support
26
+ * */
27
+ borderInlineStartWidth?: Property.BorderInlineStartWidth | number;
28
+ /**
29
+ * - sets [CSS border-inline-end property](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end)
30
+ * - bidirectional support
31
+ * */
32
+ borderInlineEndWidth?: Property.BorderInlineEndWidth | number;
33
+ };
34
+
35
+ export const borderWidthStyleFnConfigs: StyleFnConfig[] = [
36
+ {
37
+ name: 'borderWidth',
38
+ properties: ['borderWidth'],
39
+ system: 'none',
40
+ },
41
+ {
42
+ name: 'borderTopWidth',
43
+ properties: ['borderTopWidth'],
44
+ system: 'none',
45
+ },
46
+ {
47
+ name: 'borderRightWidth',
48
+ properties: ['borderRightWidth'],
49
+ system: 'none',
50
+ },
51
+ {
52
+ name: 'borderBottomWidth',
53
+ properties: ['borderBottomWidth'],
54
+ system: 'none',
55
+ },
56
+ {
57
+ name: 'borderLeftWidth',
58
+ properties: ['borderLeftWidth'],
59
+ system: 'none',
60
+ },
61
+ {
62
+ name: 'borderInlineStartWidth',
63
+ properties: ['borderInlineStartWidth'],
64
+ system: 'none',
65
+ },
66
+ {
67
+ name: 'borderInlineEndWidth',
68
+ properties: ['borderInlineEndWidth'],
69
+ system: 'none',
70
+ },
71
+ ];
72
+
73
+ export const borderWidthFns = buildStyleFns(borderWidthStyleFnConfigs);
@@ -0,0 +1,117 @@
1
+ import {
2
+ borderRadius as borderRadiusTokens,
3
+ colors as colorTokens,
4
+ depth as depthTokens,
5
+ space as spaceTokens,
6
+ type as typeTokens,
7
+ } from '@workday/canvas-kit-react/tokens';
8
+
9
+ import {CanvasSystemPropValues, SystemPropNames, SystemPropValues} from './systemProps';
10
+
11
+ export type StyleFnConfig = {
12
+ name: string;
13
+ properties: string[];
14
+ system: SystemPropNames | 'none';
15
+ };
16
+
17
+ export type StyleFns = {
18
+ [key: string]: (value: unknown) => {};
19
+ };
20
+
21
+ const getColor = (value: SystemPropValues['color']) => {
22
+ return colorTokens[value] || value;
23
+ };
24
+
25
+ const getDepth = (value: SystemPropValues['depth']) => {
26
+ return depthTokens[value];
27
+ };
28
+
29
+ const getShape = (value: SystemPropValues['shape']) => {
30
+ return borderRadiusTokens[value as CanvasSystemPropValues['shape']] || value;
31
+ };
32
+
33
+ const getSpace = (value: SystemPropValues['space']) => {
34
+ return spaceTokens[value as CanvasSystemPropValues['space']] || value;
35
+ };
36
+
37
+ const getFont = (value: SystemPropValues['font']) => {
38
+ return typeTokens.properties.fontFamilies[value as CanvasSystemPropValues['font']] || value;
39
+ };
40
+
41
+ const getFontSize = (value: SystemPropValues['fontSize'] | string) => {
42
+ return typeTokens.properties.fontSizes[value as CanvasSystemPropValues['fontSize']] || value;
43
+ };
44
+
45
+ const getFontWeight = (value: SystemPropValues['fontWeight'] | string) => {
46
+ return typeTokens.properties.fontWeights[value as CanvasSystemPropValues['fontWeight']] || value;
47
+ };
48
+
49
+ export function buildStyleFns(styleFnConfigs: StyleFnConfig[]): StyleFns {
50
+ return styleFnConfigs.reduce((styleFns = {}, styleFnConfig) => {
51
+ const styleFn = (value: unknown) => {
52
+ return styleFnConfig.properties.reduce((styles = {}, property: string) => {
53
+ if (styleFnConfig.system === 'color') {
54
+ return {...styles, [property]: getColor(value as SystemPropValues['color'])};
55
+ }
56
+
57
+ if (styleFnConfig.system === 'depth') {
58
+ // Depth tokens return the style property (box-shadow) and the value
59
+ const depthStyle = getDepth(value as SystemPropValues['depth']);
60
+ return {...styles, ...depthStyle};
61
+ }
62
+
63
+ if (styleFnConfig.system === 'font') {
64
+ return {
65
+ ...styles,
66
+ [property]: getFont(value as SystemPropValues['font']),
67
+ };
68
+ }
69
+
70
+ if (styleFnConfig.system === 'fontSize') {
71
+ return {
72
+ ...styles,
73
+ [property]: getFontSize(value as SystemPropValues['fontSize']),
74
+ };
75
+ }
76
+
77
+ if (styleFnConfig.system === 'fontWeight') {
78
+ return {
79
+ ...styles,
80
+ [property]: getFontWeight(value as SystemPropValues['fontWeight']),
81
+ };
82
+ }
83
+
84
+ if (styleFnConfig.system === 'shape') {
85
+ return {
86
+ ...styles,
87
+ [property]: getShape(value as SystemPropValues['shape']),
88
+ };
89
+ }
90
+
91
+ if (styleFnConfig.system === 'space') {
92
+ return {...styles, [property]: getSpace(value as SystemPropValues['space'])};
93
+ }
94
+
95
+ return {...styles, [property]: value};
96
+ }, {});
97
+ };
98
+
99
+ return {...styleFns, [styleFnConfig.name]: styleFn};
100
+ }, {});
101
+ }
102
+
103
+ export function buildStylePropFn<P extends {}>(styleFns: StyleFns) {
104
+ return (props: P) => {
105
+ let styles = {};
106
+ for (const key in props) {
107
+ if (key in props && key in styleFns) {
108
+ const styleFn = styleFns[key];
109
+ const value = props[key];
110
+ const style = styleFn(value);
111
+ styles = {...styles, ...style};
112
+ continue;
113
+ }
114
+ }
115
+ return styles;
116
+ };
117
+ }