@workday/canvas-kit-react 8.0.0-alpha.204-next.4 → 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 +102 -2
  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 +103 -3
  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 +117 -4
  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
@@ -1,129 +1,166 @@
1
1
  import {Property} from 'csstype';
2
- import {space as spaceTokens, CanvasSpace, CanvasSpaceKeys} from '@workday/canvas-kit-react/tokens';
3
2
 
4
- export type GridSpacePropsValues = CanvasSpaceKeys | number | (string & {});
3
+ import {buildStyleFns, buildStylePropFn, StyleFnConfig} from './buildStyleFns';
4
+ import {SystemPropValues} from './systemProps';
5
5
 
6
- /** style props to for grid container properties */
6
+ /** style props to for CSS grid container properties */
7
7
  export type GridStyleProps = {
8
- /** sets `align-items` property */
8
+ /** sets [CSS align-items property](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) */
9
9
  alignItems?: Property.AlignItems;
10
- /** sets `align-content` property */
10
+ /** sets [CSS align-content property](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) */
11
11
  alignContent?: Property.AlignContent;
12
12
  /**
13
- * sets `display` property
14
- * @default 'grid'
13
+ * - sets [CSS display property](https://developer.mozilla.org/en-US/docs/Web/CSS/display)
14
+ * - @default 'grid'
15
15
  * */
16
16
  display?: 'grid' | 'inline-grid';
17
- /** sets `justify-items` property */
17
+ /** sets [CSS justify-items property](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) */
18
18
  justifyItems?: Property.JustifyItems;
19
- /** sets `justify-content` property */
19
+ /** sets [CSS justify-content property](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) */
20
20
  justifyContent?: Property.JustifyContent;
21
-
22
- // Container Types
23
- /** sets `grid-template` property */
21
+ /** sets [CSS grid-template property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template) */
24
22
  gridTemplate?: Property.GridTemplate;
25
- /** sets `grid-template-area` property */
23
+ /** sets [CSS grid-template-areas property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) */
26
24
  gridTemplateAreas?: Property.GridTemplateAreas;
27
- /** sets `grid-template-columns` property */
25
+ /** sets [CSS grid-template-columns property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) */
28
26
  gridTemplateColumns?: Property.GridTemplateColumns;
29
- /** sets `grid-template-rows` property */
27
+ /** sets [CSS grid-template-rows property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows) */
30
28
  gridTemplateRows?: Property.GridTemplateRows;
31
- /** sets `column-gap` property */
32
- gridColumnGap?: Property.GridColumnGap | GridSpacePropsValues;
33
- /** sets `row-gap` property */
34
- gridRowGap?: Property.GridRowGap | GridSpacePropsValues;
35
- /** sets `gap` property */
36
- gridGap?: Property.GridGap | GridSpacePropsValues;
37
- /** sets `place-items` property */
29
+ /**
30
+ * - sets [CSS column-gap property](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap)
31
+ * - system tokens: `space`
32
+ * */
33
+ gridColumnGap?: Property.GridColumnGap | SystemPropValues['space'];
34
+ /**
35
+ * - sets [CSS row-gap property](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap)
36
+ * - system tokens: `space`
37
+ * */
38
+ gridRowGap?: Property.GridRowGap | SystemPropValues['space'];
39
+ /**
40
+ * - sets [CSS grid-gap property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-gap)
41
+ * - system tokens: `space`
42
+ * */
43
+ gridGap?: Property.GridGap | SystemPropValues['space'];
44
+ /** sets [CSS place-items property](https://developer.mozilla.org/en-US/docs/Web/CSS/place-items) */
38
45
  gridPlaceItems?: Property.PlaceItems;
39
- /** sets `grid-auto-columns` property */
46
+ /** sets [CSS grid-auto-columns property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) */
40
47
  gridAutoColumns?: Property.GridAutoColumns;
41
- /** sets `grid-auto-rows` property */
48
+ /** sets [CSS grid-auto-rows property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) */
42
49
  gridAutoRows?: Property.GridAutoRows;
43
- /** sets `grid-area` property */
50
+ /** sets [CSS grid-area property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) */
44
51
  gridArea?: Property.GridArea;
45
- /** sets `grid-auto-flow` property */
52
+ /** sets [CSS grid-auto-flow property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) */
46
53
  gridAutoFlow?: Property.GridAutoFlow;
47
- /** sets `grid` property */
54
+ /** sets [CSS grid property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid) */
48
55
  grid?: Property.Grid;
49
56
  };
50
57
 
51
- export type gridSpaceProps = {
52
- /** sets `gap` property */
53
- gridGap?: Property.GridGap | GridSpacePropsValues;
54
- };
55
-
56
- const gridGap = (value: GridSpacePropsValues) => {
57
- return {gridGap: spaceTokens[value as keyof CanvasSpace] || value};
58
- };
59
- const gridRowGap = (value: GridSpacePropsValues) => {
60
- return {gridRowGap: spaceTokens[value as keyof CanvasSpace] || value};
61
- };
62
- const gridColumnGap = (value: GridSpacePropsValues) => {
63
- return {gridColumnGap: spaceTokens[value as keyof CanvasSpace] || value};
64
- };
65
-
66
- const gridSpaceStyleProps = {
67
- gridGap,
68
- gridRowGap,
69
- gridColumnGap,
70
- };
71
-
72
- export type SpaceStyleProps = gridSpaceProps & GridStyleProps;
73
-
74
- const gridProps = {
75
- alignContent: 'alignContent',
76
- alignItems: 'alignItems',
77
- display: 'display',
78
- justifyContent: 'justifyContent',
79
- justifyItems: 'justifyItems',
80
- gridTemplateAreas: 'gridTemplateAreas',
81
- gridTemplate: 'gridTemplate',
82
- gridTemplateColumns: 'gridTemplateColumns',
83
- gridTemplateRows: 'gridTemplateRows',
84
- gridColumnGap: 'gridColumnGap',
85
- gridRowGap: 'gridRowGap',
86
- gridGap: 'gridGap',
87
- gridPlaceItems: 'gridPlaceItems',
88
- gridAutoColumns: 'gridAutoColumns',
89
- gridAutoRows: 'gridAutoRows',
90
- gridAutoFlow: 'gridAutoFlow',
91
- gridArea: 'gridArea',
92
- grid: 'grid',
93
- };
58
+ export const gridStyleFnConfigs: StyleFnConfig[] = [
59
+ {
60
+ name: 'gridGap',
61
+ properties: ['gridGap'],
62
+ system: 'space',
63
+ },
64
+ {
65
+ name: 'gridRowGap',
66
+ properties: ['gridRowGap'],
67
+ system: 'space',
68
+ },
69
+ {
70
+ name: 'gridColumnGap',
71
+ properties: ['gridColumnGap'],
72
+ system: 'space',
73
+ },
74
+ {
75
+ name: 'alignContent',
76
+ properties: ['alignContent'],
77
+ system: 'none',
78
+ },
79
+ {
80
+ name: 'alignItems',
81
+ properties: ['alignItems'],
82
+ system: 'none',
83
+ },
84
+ {
85
+ name: 'display',
86
+ properties: ['display'],
87
+ system: 'none',
88
+ },
89
+ {
90
+ name: 'justifyContent',
91
+ properties: ['justifyContent'],
92
+ system: 'none',
93
+ },
94
+ {
95
+ name: 'justifyItems',
96
+ properties: ['justifyItems'],
97
+ system: 'none',
98
+ },
99
+ {
100
+ name: 'gridTemplateAreas',
101
+ properties: ['gridTemplateAreas'],
102
+ system: 'none',
103
+ },
104
+ {
105
+ name: 'gridTemplate',
106
+ properties: ['gridTemplate'],
107
+ system: 'none',
108
+ },
109
+ {
110
+ name: 'gridTemplateColumns',
111
+ properties: ['gridTemplateColumns'],
112
+ system: 'none',
113
+ },
114
+ {
115
+ name: 'gridTemplateRows',
116
+ properties: ['gridTemplateRows'],
117
+ system: 'none',
118
+ },
119
+ {
120
+ name: 'gridPlaceItems',
121
+ properties: ['gridPlaceItems'],
122
+ system: 'none',
123
+ },
124
+ {
125
+ name: 'gridAutoColumns',
126
+ properties: ['gridAutoColumns'],
127
+ system: 'none',
128
+ },
129
+ {
130
+ name: 'gridAutoRows',
131
+ properties: ['gridAutoRows'],
132
+ system: 'none',
133
+ },
134
+ {
135
+ name: 'gridAutoFlow',
136
+ properties: ['gridAutoFlow'],
137
+ system: 'none',
138
+ },
139
+ {
140
+ name: 'gridArea',
141
+ properties: ['gridArea'],
142
+ system: 'none',
143
+ },
144
+ {
145
+ name: 'grid',
146
+ properties: ['grid'],
147
+ system: 'none',
148
+ },
149
+ ];
94
150
 
151
+ export const gridStyleFns = buildStyleFns(gridStyleFnConfigs);
95
152
  /**
96
153
  * A style prop function that takes component props and returns grid styles.
97
154
  * If no `GridStyleProps` are found, it returns an empty object.
98
- * Space tokens are available for `gridGap`, `gridRowGap`, `gridColumnGap` (`zero`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`).
99
- * Values: `zero: 0px`, `xxxs: 4px`, `xxs: 8px`, `xs: 12px`, `s: 16px`, `m: 24px`, `l: 32px`, `xl: 40px`, `xxl: 64px`, `xxxl: 80px`.
155
+ * Space tokens are available for gridGap, gridRowGap, gridColumnGap props.
100
156
  *
101
157
  * @example
102
- * // You'll most likely use `grid` with low-level, styled components
158
+ * ```tsx
103
159
  * const GridExample = () => (
104
160
  * <Grid gridAutoFlow="row" justifyContent="center" alignItems="center">
105
161
  * Hello, Grid!
106
162
  * </Grid>
107
163
  * );
108
- *
164
+ * ```
109
165
  */
110
- export function grid<P extends SpaceStyleProps>(props: P) {
111
- let styles = {};
112
- for (const key in props) {
113
- if (props.hasOwnProperty(key)) {
114
- if (key in gridProps) {
115
- const attr = gridProps[key as keyof GridStyleProps];
116
- const value = props[key];
117
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
118
- styles[attr] = value;
119
- }
120
- if (key in gridSpaceStyleProps) {
121
- const value = props[key as keyof gridSpaceProps] as GridSpacePropsValues;
122
- const spaceFn = gridSpaceStyleProps[key as keyof gridSpaceProps];
123
- const style = spaceFn(value);
124
- styles = {...styles, ...style};
125
- }
126
- }
127
- }
128
- return styles;
129
- }
166
+ export const grid = buildStylePropFn<GridStyleProps>(gridStyleFns);
@@ -1,68 +1,96 @@
1
1
  import {Property} from 'csstype';
2
2
 
3
- /** style props to for grid item properties */
3
+ import {buildStyleFns, buildStylePropFn, StyleFnConfig} from './buildStyleFns';
4
+
5
+ /** style props to for CSS grid item properties */
4
6
  export type GridItemStyleProps = {
5
- // Child Types
6
- /** sets `grid-column-start` property */
7
+ /** sets [CSS grid-column-start property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start) */
7
8
  gridColumnStart?: Property.GridColumnStart;
8
- /** sets `grid-column-end` property */
9
+ /** sets [CSS grid-column-end property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end) */
9
10
  gridColumnEnd?: Property.GridColumnEnd;
10
- /** sets `grid-row-start` property */
11
+ /** sets [CSS grid-row-start property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start) */
11
12
  gridRowStart?: Property.GridRowStart;
12
- /** sets `grid-row-end` property */
13
+ /** sets [CSS grid-row-end property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end) */
13
14
  gridRowEnd?: Property.GridRowEnd;
14
- /** sets `grid-column` property */
15
+ /** sets [CSS grid-column property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) */
15
16
  gridColumn?: Property.GridColumn;
16
- /** sets `grid-row` property */
17
+ /** sets [CSS grid-row property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) */
17
18
  gridRow?: Property.GridRow;
18
- /** sets `grid-area` property */
19
+ /** sets [CSS grid-area property](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) */
19
20
  gridArea?: Property.GridArea;
20
- /** sets `justify-self` property */
21
+ /** sets [CSS justify-self property](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) */
21
22
  justifySelf?: Property.JustifySelf;
22
- /** sets `align-self` property */
23
+ /** sets [CSS align-self property](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) */
23
24
  alignSelf?: Property.AlignSelf;
24
- /** sets `place-self` property */
25
+ /** sets [CSS place-self property](https://developer.mozilla.org/en-US/docs/Web/CSS/place-self) */
25
26
  placeSelf?: Property.PlaceSelf;
26
27
  };
27
28
 
28
- /** style props to for grid item properties */
29
- const gridItemProps = {
30
- //Child Props
31
- gridColumnStart: 'gridColumnStart',
32
- gridColumnEnd: 'gridColumnEnd',
33
- gridRowStart: 'gridRowStart',
34
- gridRowEnd: 'gridRowEnd',
35
- gridColumn: 'gridColumn',
36
- gridRow: 'gridRow',
37
- gridArea: 'gridArea',
38
- justifySelf: 'justifySelf',
39
- alignSelf: 'alignSelf',
40
- placeSelf: 'placeSelf',
41
- };
29
+ export const gridItemStyleFnConfigs: StyleFnConfig[] = [
30
+ {
31
+ name: 'gridColumnStart',
32
+ properties: ['gridColumnStart'],
33
+ system: 'none',
34
+ },
35
+ {
36
+ name: 'gridColumnEnd',
37
+ properties: ['gridColumnEnd'],
38
+ system: 'none',
39
+ },
40
+ {
41
+ name: 'gridRowStart',
42
+ properties: ['gridRowStart'],
43
+ system: 'none',
44
+ },
45
+ {
46
+ name: 'gridRowEnd',
47
+ properties: ['gridRowEnd'],
48
+ system: 'none',
49
+ },
50
+ {
51
+ name: 'gridColumn',
52
+ properties: ['gridColumn'],
53
+ system: 'none',
54
+ },
55
+ {
56
+ name: 'gridRow',
57
+ properties: ['gridRow'],
58
+ system: 'none',
59
+ },
60
+ {
61
+ name: 'gridArea',
62
+ properties: ['gridArea'],
63
+ system: 'none',
64
+ },
65
+ {
66
+ name: 'justifySelf',
67
+ properties: ['justifySelf'],
68
+ system: 'none',
69
+ },
70
+ {
71
+ name: 'alignSelf',
72
+ properties: ['alignSelf'],
73
+ system: 'none',
74
+ },
75
+ {
76
+ name: 'placeSelf',
77
+ properties: ['placeSelf'],
78
+ system: 'none',
79
+ },
80
+ ];
42
81
 
82
+ export const gridItemStyleFns = buildStyleFns(gridItemStyleFnConfigs);
43
83
  /**
44
84
  * A style prop function that takes component props and returns grid styles.
45
85
  * If no `GridItemStyleProps` are found, it returns an empty object.
46
86
  *
47
87
  * @example
48
- * // You'll most likely use `grid item` with low-level, styled components
88
+ * ```tsx
49
89
  * const GridItemExample = () => (
50
90
  * <Grid.Item gridRowStart="1" justifySelf="center" gridArea="Card">
51
91
  * Hello, Grid Item!
52
92
  * </Grid.Item>
53
93
  * );
54
- *
94
+ * ```
55
95
  */
56
-
57
- export function gridItem<P extends GridItemStyleProps>(props: P) {
58
- const styles = {};
59
- for (const key in props) {
60
- if (key in gridItemProps) {
61
- const attr = gridItemProps[key as keyof GridItemStyleProps];
62
- const value = props[key];
63
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
64
- styles[attr] = value;
65
- }
66
- }
67
- return styles;
68
- }
96
+ export const gridItem = buildStylePropFn<GridItemStyleProps>(gridItemStyleFns);
@@ -1,70 +1,129 @@
1
1
  import {Property} from 'csstype';
2
2
 
3
- /** style props to for layout properties */
3
+ import {buildStyleFns, buildStylePropFn, StyleFnConfig} from './buildStyleFns';
4
+ import {SystemPropValues} from './systemProps';
5
+
6
+ /** style props to for CSS layout properties */
4
7
  export type LayoutStyleProps = {
5
- /** sets `display` property */
8
+ /** sets [CSS display property](https://developer.mozilla.org/en-US/docs/Web/CSS/displaydisplay) */
6
9
  display?: Property.Display;
7
- /** sets `height` property */
8
- height?: number | string;
9
- /** sets `list-style property */
10
+ /**
11
+ * - sets [CSS height property](https://developer.mozilla.org/en-US/docs/Web/CSS/height)
12
+ * - system tokens: `space`
13
+ * */
14
+ height?: SystemPropValues['space'];
15
+ /** sets [CSS list-style property](https://developer.mozilla.org/en-US/docs/Web/CSS/list-style) */
10
16
  listStyle?: Property.ListStyle;
11
- /** sets `max-height` property */
12
- maxHeight?: number | string;
13
- /** sets `max-width` property */
14
- maxWidth?: number | string;
15
- /** sets `min-height` property */
16
- minHeight?: number | string;
17
- /** sets `min-width` property */
18
- minWidth?: number | string;
19
- /** sets `overflow` property */
17
+ /**
18
+ * - sets [CSS max-height property](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height)
19
+ * - system tokens: `space`
20
+ * */
21
+ maxHeight?: SystemPropValues['space'];
22
+ /**
23
+ * - sets [CSS max-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width)
24
+ * - system tokens: `space`
25
+ * */
26
+ maxWidth?: SystemPropValues['space'];
27
+ /**
28
+ * - sets [CSS min-height property](https://developer.mozilla.org/en-US/docs/Web/CSS/min-height)
29
+ * - system tokens: `space`
30
+ * */
31
+ minHeight?: SystemPropValues['space'];
32
+ /**
33
+ * - sets [CSS min-width property](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width)
34
+ * - system tokens: `space`
35
+ * */
36
+ minWidth?: SystemPropValues['space'];
37
+ /** sets [CSS overflow property](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) */
20
38
  overflow?: Property.Overflow;
21
- /** sets `overflow-x` property */
39
+ /** sets [CSS overflow-x property](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-x) */
22
40
  overflowX?: Property.OverflowX;
23
- /** sets `overflow-y` property */
41
+ /** sets [CSS overflow-y property](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y) */
24
42
  overflowY?: Property.OverflowY;
25
- /** sets `vertical-align` property */
43
+ /** sets [CSS vertical-align property](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) */
26
44
  verticalAlign?: Property.VerticalAlign;
27
- /** sets `width` property */
28
- width?: number | string;
45
+ /**
46
+ * - sets [CSS width property](https://developer.mozilla.org/en-US/docs/Web/CSS/width)
47
+ * - system tokens: `space`
48
+ * */
49
+ width?: SystemPropValues['space'];
29
50
  };
30
51
 
31
- const layoutProps = {
32
- display: 'display',
33
- height: 'height',
34
- listStyle: 'listStyle',
35
- maxHeight: 'maxHeight',
36
- maxWidth: 'maxWidth',
37
- minHeight: 'minHeight',
38
- minWidth: 'minWidth',
39
- overflow: 'overflow',
40
- overflowX: 'overflowX',
41
- overflowY: 'overflowY',
42
- verticalAlign: 'verticalAlign',
43
- width: 'width',
44
- };
52
+ export const layoutStyleFnConfigs: StyleFnConfig[] = [
53
+ {
54
+ name: 'display',
55
+ properties: ['display'],
56
+ system: 'none',
57
+ },
58
+ {
59
+ name: 'height',
60
+ properties: ['height'],
61
+ system: 'space',
62
+ },
63
+ {
64
+ name: 'listStyle',
65
+ properties: ['listStyle'],
66
+ system: 'none',
67
+ },
68
+ {
69
+ name: 'maxHeight',
70
+ properties: ['maxHeight'],
71
+ system: 'space',
72
+ },
73
+ {
74
+ name: 'maxWidth',
75
+ properties: ['maxWidth'],
76
+ system: 'space',
77
+ },
78
+ {
79
+ name: 'minHeight',
80
+ properties: ['minHeight'],
81
+ system: 'space',
82
+ },
83
+ {
84
+ name: 'minWidth',
85
+ properties: ['minWidth'],
86
+ system: 'space',
87
+ },
88
+ {
89
+ name: 'overflow',
90
+ properties: ['overflow'],
91
+ system: 'none',
92
+ },
93
+ {
94
+ name: 'overflowX',
95
+ properties: ['overflowX'],
96
+ system: 'none',
97
+ },
98
+ {
99
+ name: 'overflowY',
100
+ properties: ['overflowY'],
101
+ system: 'none',
102
+ },
103
+ {
104
+ name: 'verticalAlign',
105
+ properties: ['verticalAlign'],
106
+ system: 'none',
107
+ },
108
+ {
109
+ name: 'width',
110
+ properties: ['width'],
111
+ system: 'space',
112
+ },
113
+ ];
45
114
 
115
+ export const layoutStyleFns = buildStyleFns(layoutStyleFnConfigs);
46
116
  /**
47
- * A style prop function that takes components props and returns layout styles.
117
+ * A style prop function that takes component props and returns layout styles.
48
118
  * If no `LayoutStyleProps` are found, it returns an empty object.
49
119
  *
50
120
  * @example
51
- * // You'll most likely use `layout` with low-level, styled components
52
- * const BoxExample = () => (
121
+ * ```tsx
122
+ * const LayoutExample = () => (
53
123
  * <Box display="inline-block" height="50%">
54
- * Hello, positions!
124
+ * Hello, layout!
55
125
  * </Box>
56
126
  * );
57
- *
127
+ * ```
58
128
  */
59
- export function layout<P extends LayoutStyleProps>(props: P) {
60
- const styles = {};
61
- for (const key in props) {
62
- if (key in layoutProps) {
63
- const attr = layoutProps[key as keyof LayoutStyleProps];
64
- const value = props[key];
65
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
66
- styles[attr] = value;
67
- }
68
- }
69
- return styles;
70
- }
129
+ export const layout = buildStylePropFn<LayoutStyleProps>(layoutStyleFns);