@workday/canvas-kit-react 11.0.0-alpha.726-next.0 → 11.0.0-alpha.760-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/breadcrumbs/lib/BreadcrumbsItem.tsx +1 -1
  2. package/breadcrumbs/lib/BreadcrumbsOverflowButton.tsx +1 -1
  3. package/button/lib/BaseButton.tsx +16 -1
  4. package/button/lib/DeleteButton.tsx +12 -11
  5. package/button/lib/ExternalHyperlink.tsx +1 -1
  6. package/button/lib/PrimaryButton.tsx +52 -45
  7. package/button/lib/SecondaryButton.tsx +58 -75
  8. package/button/lib/TertiaryButton.tsx +63 -54
  9. package/card/index.ts +3 -1
  10. package/card/lib/Card.tsx +12 -9
  11. package/card/lib/CardBody.tsx +12 -4
  12. package/card/lib/CardHeading.tsx +14 -17
  13. package/collection/lib/ListBox.tsx +9 -3
  14. package/combobox/lib/ComboboxMenuList.tsx +3 -4
  15. package/dist/commonjs/badge/lib/CountBadge.js +6 -6
  16. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  17. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  18. package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
  19. package/dist/commonjs/button/lib/BaseButton.js +18 -17
  20. package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
  21. package/dist/commonjs/button/lib/DeleteButton.js +2 -1
  22. package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
  23. package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
  24. package/dist/commonjs/button/lib/PrimaryButton.js +3 -2
  25. package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
  26. package/dist/commonjs/button/lib/SecondaryButton.js +3 -2
  27. package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
  28. package/dist/commonjs/button/lib/TertiaryButton.js +16 -15
  29. package/dist/commonjs/card/index.d.ts +3 -1
  30. package/dist/commonjs/card/index.d.ts.map +1 -1
  31. package/dist/commonjs/card/index.js +6 -1
  32. package/dist/commonjs/card/lib/Card.d.ts +1 -0
  33. package/dist/commonjs/card/lib/Card.d.ts.map +1 -1
  34. package/dist/commonjs/card/lib/Card.js +6 -3
  35. package/dist/commonjs/card/lib/CardBody.d.ts +103 -0
  36. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  37. package/dist/commonjs/card/lib/CardBody.js +10 -2
  38. package/dist/commonjs/card/lib/CardHeading.d.ts +103 -0
  39. package/dist/commonjs/card/lib/CardHeading.d.ts.map +1 -1
  40. package/dist/commonjs/card/lib/CardHeading.js +8 -3
  41. package/dist/commonjs/checkbox/lib/CheckBackground.js +5 -5
  42. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +9 -9
  43. package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
  44. package/dist/commonjs/checkbox/lib/CheckboxInput.js +11 -11
  45. package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
  46. package/dist/commonjs/collection/lib/ListBox.d.ts.map +1 -1
  47. package/dist/commonjs/collection/lib/ListBox.js +14 -8
  48. package/dist/commonjs/combobox/lib/ComboboxMenuItem.js +4 -4
  49. package/dist/commonjs/combobox/lib/ComboboxMenuList.d.ts.map +1 -1
  50. package/dist/commonjs/combobox/lib/ComboboxMenuList.js +4 -5
  51. package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
  52. package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
  53. package/dist/commonjs/icon/index.d.ts +1 -1
  54. package/dist/commonjs/icon/index.d.ts.map +1 -1
  55. package/dist/commonjs/icon/index.js +4 -1
  56. package/dist/commonjs/icon/lib/AccentIcon.d.ts +30 -4
  57. package/dist/commonjs/icon/lib/AccentIcon.d.ts.map +1 -1
  58. package/dist/commonjs/icon/lib/AccentIcon.js +28 -4
  59. package/dist/commonjs/icon/lib/AppletIcon.d.ts +31 -2
  60. package/dist/commonjs/icon/lib/AppletIcon.d.ts.map +1 -1
  61. package/dist/commonjs/icon/lib/AppletIcon.js +27 -4
  62. package/dist/commonjs/icon/lib/Graphic.d.ts +20 -1
  63. package/dist/commonjs/icon/lib/Graphic.d.ts.map +1 -1
  64. package/dist/commonjs/icon/lib/Graphic.js +25 -3
  65. package/dist/commonjs/icon/lib/Svg.d.ts +12 -2
  66. package/dist/commonjs/icon/lib/Svg.d.ts.map +1 -1
  67. package/dist/commonjs/icon/lib/Svg.js +25 -10
  68. package/dist/commonjs/icon/lib/SystemIcon.d.ts +79 -16
  69. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  70. package/dist/commonjs/icon/lib/SystemIcon.js +51 -14
  71. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts +2 -3
  72. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts.map +1 -1
  73. package/dist/commonjs/icon/lib/SystemIconCircle.js +20 -30
  74. package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
  75. package/dist/commonjs/menu/lib/MenuCard.js +2 -2
  76. package/dist/commonjs/menu/lib/MenuList.js +5 -5
  77. package/dist/commonjs/select/lib/Select.js +7 -7
  78. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +4 -1
  79. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts.map +1 -1
  80. package/dist/commonjs/select/lib/hooks/useSelectInput.js +14 -5
  81. package/dist/commonjs/switch/lib/Switch.js +13 -13
  82. package/dist/commonjs/table/lib/Table.js +2 -2
  83. package/dist/commonjs/table/lib/TableBody.js +2 -2
  84. package/dist/commonjs/table/lib/TableCaption.js +2 -2
  85. package/dist/commonjs/table/lib/TableCell.js +2 -2
  86. package/dist/commonjs/table/lib/TableFooter.js +2 -2
  87. package/dist/commonjs/table/lib/TableHead.js +2 -2
  88. package/dist/commonjs/table/lib/TableHeader.js +2 -2
  89. package/dist/commonjs/table/lib/TableRow.js +2 -2
  90. package/dist/commonjs/tabs/lib/TabsItem.d.ts.map +1 -1
  91. package/dist/commonjs/tabs/lib/TabsItem.js +4 -12
  92. package/dist/commonjs/tabs/lib/useTabsModel.d.ts.map +1 -1
  93. package/dist/commonjs/text/lib/LabelText.d.ts.map +1 -1
  94. package/dist/commonjs/text/lib/LabelText.js +11 -27
  95. package/dist/commonjs/text/lib/Text.d.ts +103 -0
  96. package/dist/commonjs/text/lib/Text.d.ts.map +1 -1
  97. package/dist/commonjs/text/lib/Text.js +30 -27
  98. package/dist/commonjs/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
  99. package/dist/commonjs/tooltip/lib/OverflowTooltip.js +2 -3
  100. package/dist/es6/badge/lib/CountBadge.js +6 -6
  101. package/dist/es6/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  102. package/dist/es6/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  103. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  104. package/dist/es6/button/lib/BaseButton.js +18 -17
  105. package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
  106. package/dist/es6/button/lib/DeleteButton.js +2 -1
  107. package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
  108. package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
  109. package/dist/es6/button/lib/PrimaryButton.js +3 -2
  110. package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
  111. package/dist/es6/button/lib/SecondaryButton.js +3 -2
  112. package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
  113. package/dist/es6/button/lib/TertiaryButton.js +16 -15
  114. package/dist/es6/card/index.d.ts +3 -1
  115. package/dist/es6/card/index.d.ts.map +1 -1
  116. package/dist/es6/card/index.js +3 -1
  117. package/dist/es6/card/lib/Card.d.ts +1 -0
  118. package/dist/es6/card/lib/Card.d.ts.map +1 -1
  119. package/dist/es6/card/lib/Card.js +7 -4
  120. package/dist/es6/card/lib/CardBody.d.ts +103 -0
  121. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  122. package/dist/es6/card/lib/CardBody.js +10 -2
  123. package/dist/es6/card/lib/CardHeading.d.ts +103 -0
  124. package/dist/es6/card/lib/CardHeading.d.ts.map +1 -1
  125. package/dist/es6/card/lib/CardHeading.js +9 -4
  126. package/dist/es6/checkbox/lib/CheckBackground.js +5 -5
  127. package/dist/es6/checkbox/lib/CheckboxCheck.js +9 -9
  128. package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
  129. package/dist/es6/checkbox/lib/CheckboxInput.js +11 -11
  130. package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
  131. package/dist/es6/collection/lib/ListBox.d.ts.map +1 -1
  132. package/dist/es6/collection/lib/ListBox.js +15 -9
  133. package/dist/es6/combobox/lib/ComboboxMenuItem.js +4 -4
  134. package/dist/es6/combobox/lib/ComboboxMenuList.d.ts.map +1 -1
  135. package/dist/es6/combobox/lib/ComboboxMenuList.js +5 -6
  136. package/dist/es6/common/lib/AccessibleHide.js +1 -1
  137. package/dist/es6/common/lib/CanvasProvider.js +1 -1
  138. package/dist/es6/icon/index.d.ts +1 -1
  139. package/dist/es6/icon/index.d.ts.map +1 -1
  140. package/dist/es6/icon/index.js +1 -1
  141. package/dist/es6/icon/lib/AccentIcon.d.ts +30 -4
  142. package/dist/es6/icon/lib/AccentIcon.d.ts.map +1 -1
  143. package/dist/es6/icon/lib/AccentIcon.js +27 -3
  144. package/dist/es6/icon/lib/AppletIcon.d.ts +31 -2
  145. package/dist/es6/icon/lib/AppletIcon.d.ts.map +1 -1
  146. package/dist/es6/icon/lib/AppletIcon.js +26 -3
  147. package/dist/es6/icon/lib/Graphic.d.ts +20 -1
  148. package/dist/es6/icon/lib/Graphic.d.ts.map +1 -1
  149. package/dist/es6/icon/lib/Graphic.js +24 -2
  150. package/dist/es6/icon/lib/Svg.d.ts +12 -2
  151. package/dist/es6/icon/lib/Svg.d.ts.map +1 -1
  152. package/dist/es6/icon/lib/Svg.js +25 -11
  153. package/dist/es6/icon/lib/SystemIcon.d.ts +79 -16
  154. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  155. package/dist/es6/icon/lib/SystemIcon.js +50 -13
  156. package/dist/es6/icon/lib/SystemIconCircle.d.ts +2 -3
  157. package/dist/es6/icon/lib/SystemIconCircle.d.ts.map +1 -1
  158. package/dist/es6/icon/lib/SystemIconCircle.js +23 -30
  159. package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
  160. package/dist/es6/menu/lib/MenuCard.js +2 -2
  161. package/dist/es6/menu/lib/MenuList.js +5 -5
  162. package/dist/es6/select/lib/Select.js +7 -7
  163. package/dist/es6/select/lib/hooks/useSelectInput.d.ts +4 -1
  164. package/dist/es6/select/lib/hooks/useSelectInput.d.ts.map +1 -1
  165. package/dist/es6/select/lib/hooks/useSelectInput.js +14 -5
  166. package/dist/es6/switch/lib/Switch.js +13 -13
  167. package/dist/es6/table/lib/Table.js +2 -2
  168. package/dist/es6/table/lib/TableBody.js +2 -2
  169. package/dist/es6/table/lib/TableCaption.js +2 -2
  170. package/dist/es6/table/lib/TableCell.js +2 -2
  171. package/dist/es6/table/lib/TableFooter.js +2 -2
  172. package/dist/es6/table/lib/TableHead.js +2 -2
  173. package/dist/es6/table/lib/TableHeader.js +2 -2
  174. package/dist/es6/table/lib/TableRow.js +2 -2
  175. package/dist/es6/tabs/lib/TabsItem.d.ts.map +1 -1
  176. package/dist/es6/tabs/lib/TabsItem.js +5 -13
  177. package/dist/es6/tabs/lib/useTabsModel.d.ts.map +1 -1
  178. package/dist/es6/text/lib/LabelText.d.ts.map +1 -1
  179. package/dist/es6/text/lib/LabelText.js +12 -28
  180. package/dist/es6/text/lib/Text.d.ts +103 -0
  181. package/dist/es6/text/lib/Text.d.ts.map +1 -1
  182. package/dist/es6/text/lib/Text.js +31 -28
  183. package/dist/es6/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
  184. package/dist/es6/tooltip/lib/OverflowTooltip.js +2 -3
  185. package/icon/index.ts +1 -1
  186. package/icon/lib/AccentIcon.tsx +48 -10
  187. package/icon/lib/AppletIcon.tsx +53 -12
  188. package/icon/lib/Graphic.tsx +43 -10
  189. package/icon/lib/Svg.tsx +36 -19
  190. package/icon/lib/SystemIcon.tsx +134 -39
  191. package/icon/lib/SystemIconCircle.tsx +42 -47
  192. package/package.json +5 -5
  193. package/select/lib/hooks/useSelectInput.ts +24 -8
  194. package/tabs/lib/TabsItem.tsx +6 -13
  195. package/tabs/lib/useTabsModel.tsx +0 -1
  196. package/text/lib/LabelText.tsx +11 -63
  197. package/text/lib/Text.tsx +65 -62
  198. package/tooltip/lib/OverflowTooltip.tsx +2 -3
  199. package/dist/commonjs/icon/lib/Icon.d.ts +0 -9
  200. package/dist/commonjs/icon/lib/Icon.d.ts.map +0 -1
  201. package/dist/commonjs/icon/lib/Icon.js +0 -40
  202. package/dist/es6/icon/lib/Icon.d.ts +0 -9
  203. package/dist/es6/icon/lib/Icon.d.ts.map +0 -1
  204. package/dist/es6/icon/lib/Icon.js +0 -18
  205. package/icon/lib/Icon.tsx +0 -38
@@ -2,9 +2,14 @@ import * as React from 'react';
2
2
  import {colors, BrandingColor, CanvasColor} from '@workday/canvas-kit-react/tokens';
3
3
  import {CanvasAppletIcon, CanvasIconTypes} from '@workday/design-assets-types';
4
4
  import {CSSObject} from '@emotion/styled';
5
- import {Icon, IconProps} from './Icon';
5
+ import {Svg, SvgProps, svgStencil} from './Svg';
6
6
  import {createComponent} from '@workday/canvas-kit-react/common';
7
+ import {handleCsProp, createStencil, px2rem, cssVar} from '@workday/canvas-kit-styling';
8
+ import {base} from '@workday/canvas-tokens-web';
7
9
 
10
+ /**
11
+ * @deprecated Interface `AppletIconStyles` will be removed in a future version. All props will be moved inside `AppletIconProps`.
12
+ */
8
13
  export interface AppletIconStyles {
9
14
  /**
10
15
  * The icon color hue. Must use a member of the `AppletIcon.Colors` static enum.
@@ -13,6 +18,9 @@ export interface AppletIconStyles {
13
18
  color?: BrandingColor;
14
19
  }
15
20
 
21
+ /**
22
+ * @deprecated `appletIconStyles` will be removed in in a future version as a part of implementation of stencils and new tokens. Consider to use `appletIconStencil` instead.
23
+ */
16
24
  export const appletIconStyles = ({
17
25
  color = BrandingColor.Blueberry,
18
26
  }: AppletIconStyles): CSSObject => {
@@ -55,7 +63,7 @@ export const appletIconStyles = ({
55
63
  };
56
64
  };
57
65
 
58
- export interface AppletIconProps extends AppletIconStyles, Pick<IconProps, 'shouldMirror'> {
66
+ export interface AppletIconProps extends AppletIconStyles, Pick<SvgProps, 'shouldMirror' | 'cs'> {
59
67
  /**
60
68
  * The icon to display from `@workday/canvas-applet-icons-web`.
61
69
  */
@@ -67,23 +75,56 @@ export interface AppletIconProps extends AppletIconStyles, Pick<IconProps, 'shou
67
75
  size?: number;
68
76
  }
69
77
 
78
+ export const appletIconStencil = createStencil({
79
+ extends: svgStencil,
80
+ vars: {
81
+ color200: '',
82
+ color300: '',
83
+ color400: '',
84
+ color500: '',
85
+ },
86
+ base: ({color200, color300, color400, color500, size}) => ({
87
+ [size]: px2rem(92),
88
+ '& .color-100': {
89
+ fill: base.frenchVanilla100,
90
+ },
91
+ '& .color-200': {
92
+ fill: cssVar(color200, base.blueberry200),
93
+ },
94
+ '& .color-300': {
95
+ fill: cssVar(color300, base.blueberry300),
96
+ },
97
+ '& .color-400': {
98
+ fill: cssVar(color400, base.blueberry400),
99
+ },
100
+ '& .color-400-alpha-20': {
101
+ fill: cssVar(color400, base.blueberry400),
102
+ },
103
+ '& .color-500': {
104
+ fill: cssVar(color500, base.blueberry400),
105
+ },
106
+ }),
107
+ });
108
+
70
109
  export const AppletIcon = createComponent('span')({
71
110
  displayName: 'AppletIcon',
72
- Component: (
73
- {size = 92, icon, color, shouldMirror, ...elemProps}: AppletIconProps,
74
- ref,
75
- Element
76
- ) => {
111
+ Component: ({size, icon, color, ...elemProps}: AppletIconProps, ref, Element) => {
112
+ const colors = color && {
113
+ color200: base[`${color}200` as const],
114
+ color300: base[`${color}300` as const],
115
+ color400: base[`${color}400` as const],
116
+ color500: base[`${color}500` as const],
117
+ };
118
+
77
119
  return (
78
- <Icon
120
+ <Svg
79
121
  src={icon}
80
122
  type={CanvasIconTypes.Applet}
81
- styles={appletIconStyles({color})}
82
123
  as={Element}
83
- size={size}
84
124
  ref={ref}
85
- shouldMirror={shouldMirror}
86
- {...elemProps}
125
+ {...handleCsProp(elemProps, [
126
+ appletIconStencil({...colors, size: size ? px2rem(size) : undefined}),
127
+ ])}
87
128
  />
88
129
  );
89
130
  },
@@ -3,16 +3,22 @@ import {CanvasGraphic, CanvasIconTypes} from '@workday/design-assets-types';
3
3
  import {CSSObject} from '@emotion/styled';
4
4
  import {Svg, SvgProps} from './Svg';
5
5
  import {createComponent} from '@workday/canvas-kit-react/common';
6
+ import {createStencil, createVars, cssVar, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
6
7
 
8
+ /**
9
+ * @deprecated Interface `GraphicStyles` will be removed in a future version. `grow` prop will be moved inside `GraphicProps`.
10
+ */
7
11
  export interface GraphicStyles {
8
12
  /**
9
13
  * The width of the Graphic in `px`. The Graphic's `width` takes precedence over its `height` in order to preserve its proportions.
10
14
  * @default width of graphic
15
+ * @deprecated Use `cs` to set width, `cs={{"& svg": {width: '1rem'}}}`
11
16
  */
12
17
  width?: number | string;
13
18
  /**
14
19
  * The height of the Graphic in `px`. If the Graphic's `height` is set, its `width` will be set to `100%`.
15
20
  * @default height of graphic
21
+ * @deprecated Use `cs` to set height, `cs={{"& svg": {height: '1rem'}}}`
16
22
  */
17
23
  height?: number | string;
18
24
  /**
@@ -22,13 +28,16 @@ export interface GraphicStyles {
22
28
  grow?: boolean;
23
29
  }
24
30
 
25
- export interface GraphicProps extends GraphicStyles, Pick<SvgProps, 'shouldMirror'> {
31
+ export interface GraphicProps extends GraphicStyles, Pick<SvgProps, 'shouldMirror' | 'cs'> {
26
32
  /**
27
33
  * The graphic to display from `@workday/canvas-graphics-web`.
28
34
  */
29
35
  src: CanvasGraphic;
30
36
  }
31
37
 
38
+ /**
39
+ * @deprecated `graphicStyles` will be removed in in a future version as a part of implementation of stencils and new tokens. Consider to use `graphicStencil` instead.
40
+ */
32
41
  export const graphicStyles = ({width, height, grow}: GraphicStyles): CSSObject => {
33
42
  if (grow) {
34
43
  return {
@@ -59,22 +68,46 @@ export const graphicStyles = ({width, height, grow}: GraphicStyles): CSSObject =
59
68
  return {};
60
69
  };
61
70
 
71
+ /**
72
+ * @deprecated Part of supporting deprecated `height` and `width` props
73
+ */
74
+ const graphicVars = createVars('height', 'width');
75
+
76
+ export const graphicStencil = createStencil({
77
+ base: {
78
+ '& svg': {
79
+ width: cssVar(graphicVars.width, '100%'),
80
+ height: cssVar(graphicVars.height, '100%'),
81
+ },
82
+ },
83
+ modifiers: {
84
+ grow: {
85
+ true: {
86
+ width: '100%',
87
+ '& svg': {
88
+ width: '100%',
89
+ height: '100%',
90
+ },
91
+ },
92
+ },
93
+ },
94
+ });
95
+
62
96
  export const Graphic = createComponent('span')({
63
97
  displayName: 'Graphic',
64
- Component: (
65
- {grow = false, src, width, height, shouldMirror, ...elemProps}: GraphicProps,
66
- ref,
67
- Element
68
- ) => {
98
+ Component: ({grow, width, height, ...elemProps}: GraphicProps, ref, Element) => {
69
99
  return (
70
100
  <Svg
71
- src={src}
72
- styles={graphicStyles({width, height, grow})}
73
101
  type={CanvasIconTypes.Graphic}
74
102
  as={Element}
75
103
  ref={ref}
76
- shouldMirror={shouldMirror}
77
- {...elemProps}
104
+ {...handleCsProp(elemProps, [
105
+ graphicStencil({grow}),
106
+ {
107
+ [graphicVars.height]: typeof height === 'number' ? px2rem(height) : height,
108
+ [graphicVars.width]: typeof width === 'number' ? px2rem(width) : width,
109
+ },
110
+ ])}
78
111
  />
79
112
  );
80
113
  },
package/icon/lib/Svg.tsx CHANGED
@@ -1,13 +1,13 @@
1
- import {CSSObject} from '@emotion/styled';
2
1
  import * as React from 'react';
3
2
  import {CanvasIcon, CanvasIconTypes} from '@workday/design-assets-types';
4
3
  import {validateIconType} from './utils';
5
- import {createComponent, styled, StyledType} from '@workday/canvas-kit-react/common';
6
- import {Box, BoxProps} from '@workday/canvas-kit-react/layout';
4
+ import {createComponent} from '@workday/canvas-kit-react/common';
5
+ import {BoxProps, mergeStyles} from '@workday/canvas-kit-react/layout';
6
+ import {createStencil} from '@workday/canvas-kit-styling';
7
+ import {base} from '@workday/canvas-tokens-web';
7
8
 
8
9
  export interface SvgProps extends BoxProps {
9
10
  src: CanvasIcon;
10
- styles?: CSSObject;
11
11
  type: CanvasIconTypes;
12
12
  /**
13
13
  * If set to `true`, transform the SVG's x-axis to mirror the graphic
@@ -16,22 +16,40 @@ export interface SvgProps extends BoxProps {
16
16
  shouldMirror?: boolean;
17
17
  }
18
18
 
19
- const StyledIconSpan = styled(Box.as('span'))<
20
- StyledType & Pick<SvgProps, 'shouldMirror' | 'styles'>
21
- >(
22
- {
19
+ export const svgStencil = createStencil({
20
+ vars: {
21
+ /** set width and height of svg element */
22
+ size: '',
23
+ },
24
+ base: ({size}) => ({
25
+ boxSizing: 'border-box',
23
26
  display: 'inline-block',
24
- '> svg': {display: 'block'},
27
+ '> svg': {
28
+ display: 'block',
29
+ width: size,
30
+ height: size,
31
+ },
32
+ }),
33
+ modifiers: {
34
+ shouldMirror: {
35
+ true: {
36
+ transform: 'scaleX(-1)',
37
+ },
38
+ },
25
39
  },
26
- ({shouldMirror, styles}) => ({
27
- ...styles,
28
- transform: shouldMirror ? 'scaleX(-1)' : undefined,
29
- })
30
- );
40
+ });
41
+
42
+ /** @deprecated */
43
+ export const transformColorNameToToken = (color?: string) => {
44
+ if (color && color in base) {
45
+ return base[color as keyof typeof base];
46
+ }
47
+ return color;
48
+ };
31
49
 
32
50
  export const Svg = createComponent('span')({
33
51
  displayName: 'Svg',
34
- Component: ({src, type, ...elemProps}: SvgProps, ref, Element) => {
52
+ Component: ({shouldMirror, src, type, ...elemProps}: SvgProps, ref, Element) => {
35
53
  try {
36
54
  validateIconType(src, type);
37
55
  } catch (e) {
@@ -40,11 +58,10 @@ export const Svg = createComponent('span')({
40
58
  }
41
59
 
42
60
  return (
43
- <StyledIconSpan
44
- as={Element}
45
- dangerouslySetInnerHTML={{__html: src.svg}}
46
- {...elemProps}
61
+ <Element
47
62
  ref={ref}
63
+ dangerouslySetInnerHTML={{__html: src.svg}}
64
+ {...mergeStyles(elemProps, svgStencil({shouldMirror}))}
48
65
  />
49
66
  );
50
67
  },
@@ -2,52 +2,81 @@ import * as React from 'react';
2
2
  import {iconColors} from '@workday/canvas-kit-react/tokens';
3
3
  import {CanvasSystemIcon, CanvasIconTypes} from '@workday/design-assets-types';
4
4
  import {CSSObject} from '@emotion/styled';
5
- import {Icon, IconProps} from './Icon';
6
5
  import {createComponent, getColor} from '@workday/canvas-kit-react/common';
7
- import {SystemPropValues} from '@workday/canvas-kit-react/layout';
6
+ import {cssVar, createStencil, handleCsProp, px2rem, createVars} from '@workday/canvas-kit-styling';
7
+ import {base} from '@workday/canvas-tokens-web';
8
+ import {Svg, SvgProps, svgStencil, transformColorNameToToken} from './Svg';
8
9
 
10
+ /**
11
+ * @deprecated Interface `SystemIconStyles` will be removed in a future version. `accent`, `color`, background props will be moved inside `GraphicProps`.
12
+ */
9
13
  export interface SystemIconStyles {
10
14
  /**
11
15
  * The accent color of the SystemIcon. This overrides `color`.
12
16
  */
13
- accent?: SystemPropValues['color'];
17
+ accent?: string;
14
18
  /**
15
19
  * The accent color of the SystemIcon on hover. This overrides `colorHover`.
20
+ * @deprecated `accentHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
21
+ * ```tsx
22
+ * '&:hover': {
23
+ * [systemIconStencil.vars.accent]: desiredAccentHoverColor
24
+ * }
25
+ * ```
16
26
  */
17
- accentHover?: SystemPropValues['color'];
27
+ accentHover?: string;
18
28
  /**
19
29
  * The background color of the SystemIcon.
20
30
  * @default transparent
21
31
  */
22
- background?: SystemPropValues['color'];
32
+ background?: string;
23
33
  /**
24
34
  * The background color of the SystemIcon on hover.
25
35
  * @default transparent
36
+ * @deprecated `backgroundHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
37
+ * ```tsx
38
+ * '&:hover': {
39
+ * [systemIconStencil.vars.background]: desiredBackgroundHoverColor
40
+ * }
41
+ * ```
26
42
  */
27
- backgroundHover?: SystemPropValues['color'];
43
+ backgroundHover?: string;
28
44
  /**
29
- * The color of the SystemIcon. This defines `accent` and `fill`. `color` may be overriden by `accent` and `fill`.
30
- * @default iconColors.standard
45
+ * The color of the SystemIcon. This defines `accent` and `fill`. `color` may be overwritten by `accent` and `fill`.
46
+ * @default base.licorice200
31
47
  */
32
- color?: SystemPropValues['color'];
48
+ color?: string;
33
49
  /**
34
- * The hover color of the SystemIcon. This defines `accentHover` and `fillHover`. `colorHover` may be overriden by `accentHover` and `fillHover`.
35
- * @default iconColors.hover
50
+ * The hover color of the SystemIcon. This defines `accentHover` and `fillHover`. `colorHover` may be overwritten by `accentHover` and `fillHover`.
51
+ * @default base.licorice200
52
+ * @deprecated `colorHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
53
+ * ```tsx
54
+ * '&:hover': {
55
+ * [systemIconStencil.vars.color]: desiredColorHoverColor
56
+ * }
57
+ * ```
36
58
  */
37
- colorHover?: SystemPropValues['color'];
59
+ colorHover?: string;
38
60
  /**
39
61
  * The fill color of the SystemIcon. This overrides `color`.
62
+ * @deprecated `fill` is deprecated and will be removed in a future version. Please use `color` and specify `accent` color if you want `accent` to be different from `color`.
40
63
  */
41
- fill?: SystemPropValues['color'];
64
+ fill?: string;
42
65
  /**
43
66
  * The fill color of the SystemIcon on hover. This overrides `colorHover`.
67
+ * @deprecated `fillHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
68
+ * ```tsx
69
+ * '&:hover': {
70
+ * [systemIconStencil.vars.fill]: desiredFillHoverColor
71
+ * }
72
+ * ```
44
73
  */
45
- fillHover?: SystemPropValues['color'];
74
+ fillHover?: string;
46
75
  }
47
76
 
48
77
  export interface SystemIconProps
49
78
  extends SystemIconStyles,
50
- Omit<IconProps, 'src' | 'fill' | 'type'> {
79
+ Omit<SvgProps, 'src' | 'type' | 'fill' | 'background' | 'color'> {
51
80
  /**
52
81
  * The icon to display from `@workday/canvas-system-icons-web`.
53
82
  */
@@ -55,9 +84,18 @@ export interface SystemIconProps
55
84
  /**
56
85
  * The size of the SystemIcon in `px`.
57
86
  */
58
- size?: number | string | undefined;
87
+ size?: number | string;
59
88
  }
60
89
 
90
+ /**
91
+ * @deprecated This style utility function is deprecated and will be removed in a future version. We'll track usage over time to prevent unnecessary burden on upgrading. Most of the time, this function is used in conjunction with styling `SystemIcon`. There are a few ways to override the colors used in `SystemIcon`.
92
+ * - Pass props directly to the `SystemIcon` component: `<SystemIcon color={color} {...etc} />
93
+ * - Style overrides using the `systemIconStencil`:
94
+ * ```tsx
95
+ * // styling container
96
+ *
97
+ * ```
98
+ */
61
99
  export const systemIconStyles = ({
62
100
  accent,
63
101
  accentHover,
@@ -88,47 +126,104 @@ export const systemIconStyles = ({
88
126
  },
89
127
  });
90
128
 
129
+ /**
130
+ * @deprecated These variables are being used for backward compatibility with existing hover props. Please use the following instead:
131
+ * ```tsx
132
+ * '&:hover': {
133
+ * [systemIconStencil.vars.color]: desiredHoverColor
134
+ * }
135
+ * ```
136
+ */
137
+ const deprecatedSystemIconVars = createVars(
138
+ 'colorHover',
139
+ 'fillHover',
140
+ 'accentHover',
141
+ 'backgroundHover'
142
+ );
143
+
144
+ export const systemIconStencil = createStencil({
145
+ extends: svgStencil,
146
+ vars: {
147
+ /**
148
+ * This will set the icon's color (both `.wd-icon-fill` and `.wd-icon-accent` SVG layers). Most
149
+ * of the time, this is the only color you need to change. Icons also have an accent layer. If you
150
+ * wish to change the accent layer independently, also set the `accentColor` variable
151
+ */
152
+ color: '',
153
+ accentColor: '',
154
+ backgroundColor: 'transparent',
155
+ },
156
+ base: ({accentColor, backgroundColor, color}) => ({
157
+ '& .wd-icon-fill': {
158
+ fill: cssVar(color, base.licorice200),
159
+ },
160
+ '& .wd-icon-accent, & .wd-icon-accent2': {
161
+ fill: cssVar(accentColor, cssVar(color, base.licorice200)),
162
+ },
163
+ '& .wd-icon-background': {
164
+ fill: backgroundColor,
165
+ },
166
+ // will be removed eventually
167
+ '&:where(:hover, .hover) .wd-icon-fill': {
168
+ fill: cssVar(
169
+ deprecatedSystemIconVars.fillHover,
170
+ cssVar(deprecatedSystemIconVars.colorHover, cssVar(color, base.licorice200))
171
+ ),
172
+ },
173
+ '&:where(:hover, .hover) .wd-icon-accent, & .wd-icon-accent2': {
174
+ fill: cssVar(
175
+ deprecatedSystemIconVars.accentHover,
176
+ cssVar(
177
+ deprecatedSystemIconVars.colorHover,
178
+ cssVar(accentColor, cssVar(color, base.licorice200))
179
+ )
180
+ ),
181
+ },
182
+ '&:where(:hover, .hover) .wd-icon-background': {
183
+ fill: cssVar(deprecatedSystemIconVars.backgroundHover, backgroundColor),
184
+ },
185
+ }),
186
+ });
187
+
91
188
  export const SystemIcon = createComponent('span')({
92
189
  displayName: 'SystemIcon',
93
190
  Component: (
94
191
  {
95
- background = 'transparent',
96
- backgroundHover = 'transparent',
97
- color = iconColors.standard,
98
- colorHover = iconColors.hover,
192
+ size,
193
+ background,
194
+ backgroundHover,
195
+ color,
196
+ colorHover,
99
197
  icon,
100
198
  accent,
101
199
  accentHover,
102
200
  fill,
103
201
  fillHover,
104
- size,
105
- shouldMirror,
106
202
  ...elemProps
107
203
  }: SystemIconProps,
108
204
  ref,
109
205
  Element
110
206
  ) => {
111
- const style = systemIconStyles({
112
- accent,
113
- accentHover,
114
- background,
115
- backgroundHover,
116
- color,
117
- colorHover,
118
- fill,
119
- fillHover,
120
- });
121
-
122
207
  return (
123
- <Icon
208
+ <Svg
209
+ as={Element}
124
210
  src={icon}
125
211
  type={CanvasIconTypes.System}
126
- size={size}
127
- as={Element}
128
- shouldMirror={shouldMirror}
129
212
  ref={ref}
130
- styles={style}
131
- {...elemProps}
213
+ {...handleCsProp(elemProps, [
214
+ systemIconStencil({
215
+ size: typeof size === 'number' ? px2rem(size) : size,
216
+ color: transformColorNameToToken(fill || color),
217
+ accentColor: transformColorNameToToken(accent || color),
218
+ backgroundColor: transformColorNameToToken(background),
219
+ }),
220
+ {
221
+ [deprecatedSystemIconVars.colorHover]: colorHover && cssVar(colorHover),
222
+ [deprecatedSystemIconVars.fillHover]: fillHover && cssVar(fillHover),
223
+ [deprecatedSystemIconVars.accentHover]: accentHover && cssVar(accentHover),
224
+ [deprecatedSystemIconVars.backgroundHover]: backgroundHover && cssVar(backgroundHover),
225
+ },
226
+ ])}
132
227
  />
133
228
  );
134
229
  },
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import isPropValid from '@emotion/is-prop-valid';
4
- import {colors, borderRadius} from '@workday/canvas-kit-react/tokens';
5
- import {SystemIcon, SystemIconProps} from './SystemIcon';
2
+ import {colors} from '@workday/canvas-kit-react/tokens';
3
+ import {SystemIcon, SystemIconProps, systemIconStencil} from './SystemIcon';
6
4
  import {CanvasSystemIcon} from '@workday/design-assets-types';
7
- import {createComponent, getColor, pickForegroundColor} from '@workday/canvas-kit-react/common';
8
- import {SystemPropValues} from '@workday/canvas-kit-react/layout';
5
+ import {createComponent, pickForegroundColor} from '@workday/canvas-kit-react/common';
6
+ import {calc, createStencil, cssVar, px2rem} from '@workday/canvas-kit-styling';
7
+ import {base, system} from '@workday/canvas-tokens-web';
8
+ import {transformColorNameToToken} from './Svg';
9
9
 
10
10
  export enum SystemIconCircleSize {
11
11
  xs = 16,
@@ -19,9 +19,9 @@ export enum SystemIconCircleSize {
19
19
  export interface SystemIconCircleProps extends Pick<SystemIconProps, 'shouldMirror'> {
20
20
  /**
21
21
  * The background color of the SystemIconCircle from `@workday/canvas-colors-web`.
22
- * @default colors.soap300
22
+ * @default base.soap300
23
23
  */
24
- background?: SystemPropValues['color'];
24
+ background?: string;
25
25
  /**
26
26
  * The icon to display from `@workday/canvas-accent-icons-web`.
27
27
  */
@@ -33,60 +33,55 @@ export interface SystemIconCircleProps extends Pick<SystemIconProps, 'shouldMirr
33
33
  size?: SystemIconCircleSize | number;
34
34
  }
35
35
 
36
- const Container = styled('div', {
37
- shouldForwardProp: prop => isPropValid(prop) && prop !== 'size',
38
- })<Pick<SystemIconCircleProps, 'background' | 'size'>>(
39
- {
36
+ const systemIconCircleStencil = createStencil({
37
+ vars: {
38
+ containerSize: '',
39
+ backgroundColor: '',
40
+ iconColor: '',
41
+ },
42
+ base: ({backgroundColor, containerSize, iconColor}) => ({
43
+ background: cssVar(backgroundColor, base.soap200),
40
44
  display: 'flex',
41
45
  alignItems: 'center',
42
46
  justifyContent: 'center',
43
- padding: 0,
44
- border: 0,
45
- borderRadius: borderRadius.circle,
47
+ padding: system.space.zero,
48
+ border: 'none',
49
+ borderRadius: system.shape.round,
46
50
  boxSizing: 'border-box',
47
51
  overflow: 'hidden',
52
+ width: cssVar(containerSize, system.space.x10),
53
+ height: cssVar(containerSize, system.space.x10),
54
+ [systemIconStencil.vars.size]: calc.multiply(cssVar(containerSize, system.space.x10), 0.625),
55
+ [systemIconStencil.vars.color]: iconColor,
48
56
  '& img': {
49
57
  width: '100%',
50
58
  height: '100%',
51
59
  },
52
- },
53
- ({background}) => ({
54
- background: getColor(background),
55
60
  }),
56
- ({size}) => ({
57
- width: size,
58
- height: size,
59
- })
60
- );
61
+ });
61
62
 
62
63
  export const SystemIconCircle = createComponent('span')({
63
64
  displayName: 'SystemIconCircle',
64
- Component: (
65
- {
66
- background = colors.soap200,
67
- size = SystemIconCircleSize.l,
68
- icon,
65
+ Component: ({background, size, icon, shouldMirror}: SystemIconCircleProps, ref, Element) => {
66
+ // `pickForegroundColor` hasn't support to use css variables to generate foregroundColor
67
+ const backgroundFallback =
68
+ background && !background.startsWith('--') ? background : colors.soap200;
69
+ const iconColor = pickForegroundColor(
70
+ backgroundFallback,
71
+ 'rgba(0,0,0,0.65)',
72
+ colors.frenchVanilla100
73
+ );
69
74
 
70
- shouldMirror,
71
- ...elemProps
72
- }: SystemIconCircleProps,
73
- ref,
74
- Element
75
- ) => {
76
- const iconColor = pickForegroundColor(background, 'rgba(0,0,0,0.65)', colors.frenchVanilla100);
77
- const iconSize = size * 0.625;
78
75
  return (
79
- <Container background={background} size={size} {...elemProps}>
80
- <SystemIcon
81
- icon={icon}
82
- color={iconColor}
83
- colorHover={iconColor}
84
- as={Element}
85
- size={iconSize}
86
- ref={ref}
87
- shouldMirror={shouldMirror}
88
- />
89
- </Container>
76
+ <div
77
+ {...systemIconCircleStencil({
78
+ containerSize: typeof size === 'number' ? px2rem(size) : size,
79
+ backgroundColor: transformColorNameToToken(background),
80
+ iconColor,
81
+ })}
82
+ >
83
+ <SystemIcon as={Element} ref={ref} icon={icon} shouldMirror={shouldMirror} />
84
+ </div>
90
85
  );
91
86
  },
92
87
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "11.0.0-alpha.726-next.0",
3
+ "version": "11.0.0-alpha.760-next.0",
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,10 +49,10 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^11.0.0-alpha.726-next.0",
53
- "@workday/canvas-kit-styling": "^11.0.0-alpha.726-next.0",
52
+ "@workday/canvas-kit-popup-stack": "^11.0.0-alpha.760-next.0",
53
+ "@workday/canvas-kit-styling": "^11.0.0-alpha.760-next.0",
54
54
  "@workday/canvas-system-icons-web": "^3.0.0",
55
- "@workday/canvas-tokens-web": "^1.0.2",
55
+ "@workday/canvas-tokens-web": "^1.3.0",
56
56
  "@workday/design-assets-types": "^0.2.8",
57
57
  "chroma-js": "^2.1.0",
58
58
  "csstype": "^3.0.2",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "92313a01b7703822a67e7c7f7aff5460237f8ce7"
70
+ "gitHead": "567f7f389a35212b6f58050c9e0bf5f9834589c8"
71
71
  }