@workday/canvas-kit-react 10.0.0-alpha.538-next.0 → 10.0.0-alpha.540-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 (155) hide show
  1. package/button/index.ts +8 -11
  2. package/button/lib/BaseButton.tsx +274 -256
  3. package/button/lib/Button.tsx +67 -0
  4. package/button/lib/DeleteButton.tsx +42 -58
  5. package/button/lib/PrimaryButton.tsx +82 -149
  6. package/button/lib/SecondaryButton.tsx +87 -173
  7. package/button/lib/TertiaryButton.tsx +158 -223
  8. package/button/lib/ToolbarDropdownButton.tsx +11 -2
  9. package/button/lib/ToolbarIconButton.tsx +10 -2
  10. package/button/lib/parts/ButtonLabelIcon.tsx +1 -7
  11. package/button/lib/types.ts +6 -8
  12. package/checkbox/lib/Checkbox.tsx +24 -33
  13. package/common/lib/CanvasProvider.tsx +50 -24
  14. package/dist/commonjs/button/index.d.ts +8 -5
  15. package/dist/commonjs/button/index.d.ts.map +1 -1
  16. package/dist/commonjs/button/index.js +9 -13
  17. package/dist/commonjs/button/lib/BaseButton.d.ts +69 -5
  18. package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
  19. package/dist/commonjs/button/lib/BaseButton.js +199 -192
  20. package/dist/commonjs/button/lib/Button.d.ts +17 -0
  21. package/dist/commonjs/button/lib/Button.d.ts.map +1 -0
  22. package/dist/commonjs/button/lib/Button.js +42 -0
  23. package/dist/commonjs/button/lib/DeleteButton.d.ts +7 -9
  24. package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
  25. package/dist/commonjs/button/lib/DeleteButton.js +29 -19
  26. package/dist/commonjs/button/lib/PrimaryButton.d.ts +15 -36
  27. package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
  28. package/dist/commonjs/button/lib/PrimaryButton.js +67 -79
  29. package/dist/commonjs/button/lib/SecondaryButton.d.ts +16 -43
  30. package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
  31. package/dist/commonjs/button/lib/SecondaryButton.js +71 -96
  32. package/dist/commonjs/button/lib/TertiaryButton.d.ts +35 -47
  33. package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
  34. package/dist/commonjs/button/lib/TertiaryButton.js +136 -134
  35. package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
  36. package/dist/commonjs/button/lib/ToolbarDropdownButton.js +11 -2
  37. package/dist/commonjs/button/lib/ToolbarIconButton.d.ts.map +1 -1
  38. package/dist/commonjs/button/lib/ToolbarIconButton.js +10 -2
  39. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
  40. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  41. package/dist/commonjs/button/lib/types.d.ts +6 -7
  42. package/dist/commonjs/button/lib/types.d.ts.map +1 -1
  43. package/dist/commonjs/card/lib/Card.d.ts +1 -1
  44. package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
  45. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  46. package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
  47. package/dist/commonjs/checkbox/lib/Checkbox.js +13 -17
  48. package/dist/commonjs/common/lib/CanvasProvider.d.ts +1 -8
  49. package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
  50. package/dist/commonjs/common/lib/CanvasProvider.js +31 -13
  51. package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
  52. package/dist/commonjs/layout/lib/Box.d.ts +3 -2
  53. package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
  54. package/dist/commonjs/layout/lib/Box.js +2 -1
  55. package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
  56. package/dist/commonjs/layout/lib/Grid.d.ts +1 -1
  57. package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
  58. package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
  59. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
  60. package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
  61. package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
  62. package/dist/commonjs/radio/lib/Radio.js +17 -22
  63. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
  64. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +3 -1
  65. package/dist/commonjs/table/lib/Table.d.ts +1 -2
  66. package/dist/commonjs/table/lib/Table.d.ts.map +1 -1
  67. package/dist/commonjs/table/lib/Table.js +1 -2
  68. package/dist/commonjs/table/lib/TableRow.d.ts +3 -6
  69. package/dist/commonjs/table/lib/TableRow.d.ts.map +1 -1
  70. package/dist/commonjs/table/lib/TableRow.js +3 -5
  71. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  72. package/dist/commonjs/text-area/lib/TextArea.d.ts.map +1 -1
  73. package/dist/commonjs/text-area/lib/TextArea.js +1 -1
  74. package/dist/commonjs/text-input/lib/TextInput.js +1 -1
  75. package/dist/commonjs/tokens/lib/space.d.ts +44 -31
  76. package/dist/commonjs/tokens/lib/space.d.ts.map +1 -1
  77. package/dist/commonjs/tokens/lib/space.js +22 -29
  78. package/dist/commonjs/tooltip/lib/TooltipContainer.js +2 -2
  79. package/dist/es6/button/index.d.ts +8 -5
  80. package/dist/es6/button/index.d.ts.map +1 -1
  81. package/dist/es6/button/index.js +8 -5
  82. package/dist/es6/button/lib/BaseButton.d.ts +69 -5
  83. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  84. package/dist/es6/button/lib/BaseButton.js +199 -192
  85. package/dist/es6/button/lib/Button.d.ts +17 -0
  86. package/dist/es6/button/lib/Button.d.ts.map +1 -0
  87. package/dist/es6/button/lib/Button.js +20 -0
  88. package/dist/es6/button/lib/DeleteButton.d.ts +7 -9
  89. package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
  90. package/dist/es6/button/lib/DeleteButton.js +31 -21
  91. package/dist/es6/button/lib/PrimaryButton.d.ts +15 -36
  92. package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
  93. package/dist/es6/button/lib/PrimaryButton.js +67 -79
  94. package/dist/es6/button/lib/SecondaryButton.d.ts +16 -43
  95. package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
  96. package/dist/es6/button/lib/SecondaryButton.js +71 -95
  97. package/dist/es6/button/lib/TertiaryButton.d.ts +35 -47
  98. package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
  99. package/dist/es6/button/lib/TertiaryButton.js +137 -135
  100. package/dist/es6/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
  101. package/dist/es6/button/lib/ToolbarDropdownButton.js +11 -2
  102. package/dist/es6/button/lib/ToolbarIconButton.d.ts.map +1 -1
  103. package/dist/es6/button/lib/ToolbarIconButton.js +10 -2
  104. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
  105. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  106. package/dist/es6/button/lib/types.d.ts +6 -7
  107. package/dist/es6/button/lib/types.d.ts.map +1 -1
  108. package/dist/es6/card/lib/Card.d.ts +1 -1
  109. package/dist/es6/card/lib/CardBody.d.ts +1 -1
  110. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  111. package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
  112. package/dist/es6/checkbox/lib/Checkbox.js +14 -18
  113. package/dist/es6/common/lib/CanvasProvider.d.ts +1 -8
  114. package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
  115. package/dist/es6/common/lib/CanvasProvider.js +31 -13
  116. package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
  117. package/dist/es6/layout/lib/Box.d.ts +3 -2
  118. package/dist/es6/layout/lib/Box.d.ts.map +1 -1
  119. package/dist/es6/layout/lib/Box.js +2 -1
  120. package/dist/es6/layout/lib/Flex.d.ts +1 -1
  121. package/dist/es6/layout/lib/Grid.d.ts +1 -1
  122. package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
  123. package/dist/es6/popup/lib/Popup.d.ts +1 -1
  124. package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
  125. package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
  126. package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
  127. package/dist/es6/radio/lib/Radio.js +18 -23
  128. package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
  129. package/dist/es6/segmented-control/lib/SegmentedControlButton.js +3 -1
  130. package/dist/es6/table/lib/Table.d.ts +1 -2
  131. package/dist/es6/table/lib/Table.d.ts.map +1 -1
  132. package/dist/es6/table/lib/Table.js +1 -2
  133. package/dist/es6/table/lib/TableRow.d.ts +3 -6
  134. package/dist/es6/table/lib/TableRow.d.ts.map +1 -1
  135. package/dist/es6/table/lib/TableRow.js +4 -6
  136. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  137. package/dist/es6/text-area/lib/TextArea.d.ts.map +1 -1
  138. package/dist/es6/text-area/lib/TextArea.js +2 -2
  139. package/dist/es6/text-input/lib/TextInput.js +2 -2
  140. package/dist/es6/tokens/lib/space.d.ts +44 -31
  141. package/dist/es6/tokens/lib/space.d.ts.map +1 -1
  142. package/dist/es6/tokens/lib/space.js +22 -29
  143. package/dist/es6/tooltip/lib/TooltipContainer.js +3 -3
  144. package/layout/lib/Box.tsx +6 -4
  145. package/package.json +5 -3
  146. package/popup/lib/PopupCloseIcon.tsx +1 -1
  147. package/radio/lib/Radio.tsx +18 -34
  148. package/segmented-control/lib/SegmentedControlButton.tsx +3 -1
  149. package/table/lib/Table.tsx +1 -2
  150. package/table/lib/TableRow.tsx +5 -8
  151. package/text-area/lib/TextArea.tsx +2 -8
  152. package/text-input/lib/TextInput.tsx +2 -2
  153. package/tokens/README.md +25 -28
  154. package/tokens/lib/space.ts +53 -40
  155. package/tooltip/lib/TooltipContainer.tsx +3 -3
@@ -19,227 +19,234 @@ var __importStar = (this && this.__importStar) || function (mod) {
19
19
  return result;
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.BaseButton = exports.getPaddingStyles = exports.getMinWidthStyles = void 0;
22
+ exports.BaseButton = exports.getIconPosition = exports.capitalize = exports.buttonModifiers = exports.buttonVars = void 0;
23
23
  const React = __importStar(require("react"));
24
- const ButtonLabelIcon_1 = require("./parts/ButtonLabelIcon");
25
- const ButtonLabel_1 = require("./parts/ButtonLabel");
24
+ const ButtonLabelIcon_1 = require("../lib/parts/ButtonLabelIcon");
25
+ const ButtonLabel_1 = require("../lib/parts/ButtonLabel");
26
26
  const common_1 = require("@workday/canvas-kit-react/common");
27
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
27
28
  const layout_1 = require("@workday/canvas-kit-react/layout");
28
29
  const tokens_1 = require("@workday/canvas-kit-react/tokens");
29
- function getIconColorSelectors({ canvas: { palette: { primary: themePrimary }, }, }, color, fill) {
30
- return {
31
- '&:focus span, &:hover span, & span': {
32
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
33
- fill: color,
34
- },
35
- '.wd-icon-background': {
36
- fill: fill ? color : undefined,
37
- },
38
- '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
39
- fill: fill
40
- ? color === themePrimary.contrast
41
- ? themePrimary.main
42
- : themePrimary.contrast
43
- : color,
44
- },
45
- },
46
- };
47
- }
48
- const ButtonContainer = common_1.styled('button')({
49
- ...tokens_1.type.levels.subtext.large,
30
+ const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
31
+ /**
32
+ * Factory function for creating Button vars.
33
+ */
34
+ const createButtonVars = () => canvas_kit_styling_1.createVars('background', 'border', 'boxShadowInner', 'boxShadowOuter', 'icon', 'label', 'opacity', 'borderRadius');
35
+ /**
36
+ * Temporary css variables to be used across all Buttons.
37
+ */
38
+ exports.buttonVars = {
39
+ default: createButtonVars(),
40
+ hover: createButtonVars(),
41
+ active: createButtonVars(),
42
+ focus: createButtonVars(),
43
+ disabled: createButtonVars(),
44
+ };
45
+ /**
46
+ * Base styles for Buttons.
47
+ */
48
+ const baseButtonStyles = canvas_kit_styling_1.createStyles({
49
+ fontFamily: '"Roboto", "Helvetica Neue", "Helvetica", Arial, sans-serif',
50
+ fontSize: '0.875rem',
51
+ lineHeight: 'normal',
52
+ letterSpacing: '0.015rem',
53
+ fontWeight: 'bold',
54
+ backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.default.background, 'transparent'),
55
+ color: canvas_kit_styling_1.cssVar(exports.buttonVars.default.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
56
+ borderWidth: '1px',
57
+ borderStyle: 'solid',
58
+ gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2, tokens_1.space.xxs),
59
+ borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.default.border, 'transparent'),
50
60
  cursor: 'pointer',
51
61
  display: 'inline-flex',
62
+ boxShadow: 'none',
52
63
  alignItems: 'center',
53
64
  justifyContent: 'center',
54
65
  boxSizing: 'border-box',
55
- boxShadow: 'none',
56
- outline: 'none',
57
- fontWeight: tokens_1.type.properties.fontWeights.bold,
58
- lineHeight: 'normal',
66
+ outline: '2px transparent',
59
67
  whiteSpace: 'nowrap',
60
68
  WebkitFontSmoothing: 'antialiased',
61
69
  MozOsxFontSmoothing: 'grayscale',
62
- borderRadius: tokens_1.borderRadius.circle,
70
+ borderRadius: canvas_kit_styling_1.cssVar(exports.buttonVars.default.borderRadius, canvas_tokens_web_1.system.shape.circle),
63
71
  position: 'relative',
64
72
  verticalAlign: 'middle',
65
73
  overflow: 'hidden',
66
- border: '1px solid transparent',
67
- background: 'transparent',
68
74
  transition: 'box-shadow 120ms linear, border 120ms linear, background-color 120ms linear, color 120ms linear',
69
75
  '&:disabled, &:disabled:active': {
70
76
  cursor: 'default',
71
77
  boxShadow: 'none',
72
- opacity: 0.4,
78
+ opacity: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.opacity, '1'),
73
79
  },
74
- '&:hover:active': { transitionDuration: '40ms' },
75
- '& > *:first-of-type': {
76
- marginLeft: '0',
80
+ '& span .wd-icon-fill': {
81
+ transitionDuration: '40ms',
82
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.default.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
77
83
  },
78
- '& > *:last-of-type': {
79
- marginRight: 0,
84
+ '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
85
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.default.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
80
86
  },
81
- }, ({ size }) => {
82
- switch (size) {
83
- case 'large':
84
- return {
85
- ...tokens_1.type.levels.body.small,
86
- fontWeight: tokens_1.type.properties.fontWeights.bold,
87
- height: '48px',
88
- '& > * ': {
89
- margin: `0 ${tokens_1.space.xxxs}`,
90
- },
91
- };
92
- case 'medium':
93
- default:
94
- return {
95
- height: tokens_1.space.xl,
96
- '& > * ': {
97
- margin: `0 ${tokens_1.space.xxxs}`,
98
- },
99
- };
100
- case 'small':
101
- return {
102
- height: tokens_1.space.l,
103
- '& > * ': {
104
- margin: `0 ${tokens_1.spaceNumbers.xxxs / 2}rem`,
105
- },
106
- };
107
- case 'extraSmall':
108
- return {
109
- ...tokens_1.type.levels.subtext.medium,
110
- fontWeight: tokens_1.type.properties.fontWeights.bold,
111
- height: tokens_1.space.m,
112
- '& > * ': {
113
- margin: `0 ${tokens_1.spaceNumbers.xxxs / 2}rem`,
114
- },
115
- };
116
- }
117
- }, ({ grow }) => grow && { width: '100%', maxWidth: '100%' }, ({ colors, fillIcon, theme }) => {
118
- if (!colors) {
119
- return;
120
- }
121
- const baseStyles = {
122
- ...(colors.default.icon && {
123
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2, .wd-icon-background': {
124
- transition: 'fill 120ms ease-in',
125
- },
126
- ...getIconColorSelectors(theme, colors.default.icon, fillIcon),
87
+ '&:focus-visible, &.focus': {
88
+ backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.background, 'transparent'),
89
+ borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.border, 'transparent'),
90
+ color: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
91
+ '& span .wd-icon-fill': {
92
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
93
+ },
94
+ '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
95
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
96
+ },
97
+ ...common_1.focusRing({
98
+ width: 2,
99
+ separation: 2,
100
+ innerColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.boxShadowInner, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.frenchVanilla100)),
101
+ outerColor: canvas_kit_styling_1.cssVar(exports.buttonVars.focus.boxShadowOuter, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.primary.base)),
127
102
  }),
128
- backgroundColor: colors.default.background,
129
- borderColor: colors.default.border,
130
- color: colors.default.label,
131
- };
132
- const hoverStyles = {
133
- '&:hover': {
134
- ...(colors.hover.icon && getIconColorSelectors(theme, colors.hover.icon, fillIcon)),
135
- backgroundColor: colors.hover.background,
136
- borderColor: colors.hover.border,
137
- color: colors.hover.label,
103
+ },
104
+ '&:hover, &.hover': {
105
+ backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.background, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
106
+ borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.border, 'transparent'),
107
+ color: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
108
+ '& span .wd-icon-fill': {
109
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
138
110
  },
139
- };
140
- const activeStyles = {
141
- '&:active, &:focus:active, &:hover:active': {
142
- ...(colors.active.icon && getIconColorSelectors(theme, colors.active.icon, fillIcon)),
143
- backgroundColor: colors.active.background,
144
- borderColor: colors.active.border,
145
- color: colors.active.label,
111
+ '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
112
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.hover.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper500)),
146
113
  },
147
- };
148
- return {
149
- ...baseStyles,
150
- '&:focus': {
151
- ...(colors.focus.focusRing || common_1.focusRing({ separation: 2 }, theme)),
152
- ...(colors.focus.icon && getIconColorSelectors(theme, colors.focus.icon, fillIcon)),
153
- backgroundColor: colors.focus.background,
154
- borderColor: colors.focus.border,
155
- color: colors.focus.label,
114
+ },
115
+ '&:hover:active': { transitionDuration: '40ms' },
116
+ '&:active, &.active': {
117
+ backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.active.background, 'transparent'),
118
+ borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.active.border, 'transparent'),
119
+ color: canvas_kit_styling_1.cssVar(exports.buttonVars.active.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
120
+ '& span .wd-icon-fill': {
121
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.active.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
156
122
  },
157
- ...activeStyles,
158
- ...hoverStyles,
159
- '&:disabled, &:active:disabled, &:focus:disabled, &:hover:disabled': {
160
- ...(colors.disabled.icon && getIconColorSelectors(theme, colors.disabled.icon, fillIcon)),
161
- backgroundColor: colors.disabled.background,
162
- borderColor: colors.disabled.border,
163
- color: colors.disabled.label,
164
- opacity: colors.disabled.opacity,
123
+ '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
124
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.active.icon),
125
+ },
126
+ },
127
+ '&:disabled': {
128
+ backgroundColor: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.background, 'transparent'),
129
+ borderColor: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.border, 'transparent'),
130
+ color: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.label, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
131
+ '& span .wd-icon-fill': {
132
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
165
133
  },
166
- ...common_1.mouseFocusBehavior({
167
- '&:focus': {
168
- ...baseStyles,
169
- ...hoverStyles,
170
- ...activeStyles,
171
- outline: 'none',
172
- boxShadow: 'none',
173
- animation: 'none',
174
- },
134
+ '.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
135
+ fill: canvas_kit_styling_1.cssVar(exports.buttonVars.disabled.icon, canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.blackPepper400)),
136
+ },
137
+ },
138
+ });
139
+ /**
140
+ * Button modifiers that will overwrite the base styles of Buttons.
141
+ * - `Size`: These modifiers will dictate a size of a Button and has a set of styles to associated with it.
142
+ * - `iconPosition`: These modifiers will override the existing `Size` styles. These are specific to icon locations
143
+ * within a button or if there is only an icon and no text.
144
+ */
145
+ exports.buttonModifiers = canvas_kit_styling_1.createModifiers({
146
+ size: {
147
+ large: canvas_kit_styling_1.createStyles({
148
+ fontSize: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
149
+ lineHeight: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
150
+ letterSpacing: '0.01rem',
151
+ height: '48px',
152
+ paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
153
+ minWidth: '112px',
175
154
  }),
176
- };
177
- }, layout_1.boxStyleFn);
178
- const getMinWidthStyles = (children, size) => {
179
- switch (size) {
180
- case 'large':
181
- return children ? '112px' : '48px';
182
- case 'medium':
183
- return children ? '96px' : tokens_1.space.xl;
184
- case 'small':
185
- return children ? tokens_1.space.xxxl : tokens_1.space.l;
186
- case 'extraSmall':
187
- return children ? 'auto' : tokens_1.space.m;
188
- default:
189
- return children ? '96px' : tokens_1.space.xl;
190
- }
191
- };
192
- exports.getMinWidthStyles = getMinWidthStyles;
193
- const getPaddingStyles = (children, size, icon, iconPosition) => {
194
- // In order to calculate the correct padding, we need to know its children
195
- // and what side the icon is on and if there's an icon provided
196
- if (!children) {
197
- // icon buttons do not have any padding
198
- return 0;
199
- }
200
- // If there are children AND an icon
201
- // 1. We check what side the icon is in
202
- // 2. Adjust padding to visually center the icon and text
203
- // If there is children (most likely just text)
204
- // 1. We keep the padding the same on both side
205
- switch (size) {
206
- case 'large':
207
- return icon
208
- ? iconPosition === 'start'
209
- ? `0 ${tokens_1.space.l} 0 ${tokens_1.space.m}`
210
- : `0 ${tokens_1.space.m} 0 ${tokens_1.space.l}`
211
- : `0 ${tokens_1.space.l}`;
212
- case 'medium':
213
- return icon
214
- ? iconPosition === 'start'
215
- ? `0 ${tokens_1.space.m} 0 20px`
216
- : `0 20px 0 ${tokens_1.space.m}`
217
- : `0 ${tokens_1.space.m}`;
218
- case 'small':
219
- return icon
220
- ? iconPosition === 'start'
221
- ? `0 ${tokens_1.space.s} 0 ${tokens_1.space.xs}`
222
- : `0 ${tokens_1.space.xs} 0 ${tokens_1.space.s}`
223
- : `0 ${tokens_1.space.s}`;
224
- case 'extraSmall':
225
- return icon
226
- ? iconPosition === 'start'
227
- ? `0 ${tokens_1.space.xs} 0 ${tokens_1.space.xxs}`
228
- : `0 ${tokens_1.space.xxs} 0 ${tokens_1.space.xs}`
229
- : `0 ${tokens_1.space.xs}`;
230
- default:
231
- return icon
232
- ? iconPosition === 'start'
233
- ? `0 ${tokens_1.space.m} 0 20px`
234
- : `0 20px 0 ${tokens_1.space.m}`
235
- : `0 ${tokens_1.space.m}`;
236
- }
237
- };
238
- exports.getPaddingStyles = getPaddingStyles;
155
+ medium: canvas_kit_styling_1.createStyles({
156
+ fontSize: '0.875rem',
157
+ letterSpacing: '0.015rem',
158
+ minWidth: '96px',
159
+ paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
160
+ height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x10),
161
+ }),
162
+ small: canvas_kit_styling_1.createStyles({
163
+ fontSize: '0.875rem',
164
+ letterSpacing: '0.015rem',
165
+ height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
166
+ minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x20),
167
+ paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
168
+ gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x1),
169
+ }),
170
+ extraSmall: canvas_kit_styling_1.createStyles({
171
+ fontSize: '0.75rem',
172
+ lineHeight: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
173
+ letterSpacing: '0.02rem',
174
+ height: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
175
+ minWidth: 'auto',
176
+ paddingInline: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
177
+ gap: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x1),
178
+ }),
179
+ },
180
+ iconPosition: {
181
+ largeOnly: canvas_kit_styling_1.createStyles({
182
+ padding: '0',
183
+ minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x12),
184
+ }),
185
+ largeStart: canvas_kit_styling_1.createStyles({
186
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
187
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
188
+ }),
189
+ largeEnd: canvas_kit_styling_1.createStyles({
190
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8),
191
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
192
+ }),
193
+ mediumOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x10, tokens_1.space.xl) }),
194
+ mediumStart: canvas_kit_styling_1.createStyles({
195
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x5),
196
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
197
+ }),
198
+ mediumEnd: canvas_kit_styling_1.createStyles({
199
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6),
200
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x5),
201
+ }),
202
+ smallOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x8, tokens_1.space.l) }),
203
+ smallStart: canvas_kit_styling_1.createStyles({
204
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
205
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
206
+ }),
207
+ smallEnd: canvas_kit_styling_1.createStyles({
208
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x4),
209
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
210
+ }),
211
+ extraSmallOnly: canvas_kit_styling_1.createStyles({ padding: '0', minWidth: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x6, tokens_1.space.m) }),
212
+ extraSmallStart: canvas_kit_styling_1.createStyles({
213
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2),
214
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
215
+ }),
216
+ extraSmallEnd: canvas_kit_styling_1.createStyles({
217
+ paddingInlineStart: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x3),
218
+ paddingInlineEnd: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.space.x2),
219
+ }),
220
+ },
221
+ });
222
+ function capitalize(string = '') {
223
+ return string.charAt(0).toUpperCase() + string.substring(1);
224
+ }
225
+ exports.capitalize = capitalize;
226
+ function getIconPosition(size, iconPosition, children) {
227
+ return `${size}${capitalize(iconPosition)}`;
228
+ }
229
+ exports.getIconPosition = getIconPosition;
230
+ /**
231
+ * The base button which all other buttons are built.
232
+ */
239
233
  exports.BaseButton = common_1.createComponent('button')({
240
- displayName: 'Button',
241
- Component: ({ children, ...elemProps }, ref, Element) => {
242
- return (React.createElement(ButtonContainer, Object.assign({ as: Element, ref: ref, type: "button" }, elemProps), children));
234
+ displayName: 'BaseButton',
235
+ Component: ({ children, cs, size, fillIcon, iconPosition, icon, colors, shouldMirrorIcon = false, ...elemProps }, ref, Element) => {
236
+ // console.log('iconPosition', children, getIconPosition(size, iconPosition));
237
+ return (React.createElement(layout_1.Box, Object.assign({ as: Element, ref: ref, type: "button", cs: [
238
+ baseButtonStyles,
239
+ exports.buttonModifiers({
240
+ size: size,
241
+ iconPosition: getIconPosition(size, iconPosition, children),
242
+ }),
243
+ exports.buttonVars.default((colors === null || colors === void 0 ? void 0 : colors.default) || {}),
244
+ exports.buttonVars.focus((colors === null || colors === void 0 ? void 0 : colors.focus) || {}),
245
+ exports.buttonVars.hover((colors === null || colors === void 0 ? void 0 : colors.hover) || {}),
246
+ exports.buttonVars.active((colors === null || colors === void 0 ? void 0 : colors.active) || {}),
247
+ exports.buttonVars.disabled((colors === null || colors === void 0 ? void 0 : colors.disabled) || {}),
248
+ cs,
249
+ ] }, elemProps), children));
243
250
  },
244
251
  subComponents: {
245
252
  Icon: ButtonLabelIcon_1.ButtonLabelIcon,
@@ -0,0 +1,17 @@
1
+ import { ButtonContainerProps } from './BaseButton';
2
+ /**
3
+ * Extends all the style properties from Box to our buttons as well as props from ButtonContainerProps.
4
+ * We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
5
+ * Use this type to extend and customize any one off buttons that you want full control over styling.
6
+ */
7
+ export interface ButtonProps extends Omit<ButtonContainerProps, 'ref'> {
8
+ /**
9
+ * Button icon positions can either be `start` or `end`.
10
+ * If no value is provided, it defaults to `start`.
11
+ *
12
+ * @default 'start'
13
+ */
14
+ iconPosition?: 'start' | 'end';
15
+ }
16
+ export declare const Button: import("@workday/canvas-kit-react/common").ElementComponent<"button", ButtonProps>;
17
+ //# sourceMappingURL=Button.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../button/lib/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAa,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAG9D;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,oBAAoB,EAAE,KAAK,CAAC;IACpE;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CAChC;AAED,eAAO,MAAM,MAAM,oFA8CjB,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Button = void 0;
23
+ const React = __importStar(require("react"));
24
+ const BaseButton_1 = require("./BaseButton");
25
+ const common_1 = require("@workday/canvas-kit-react/common");
26
+ exports.Button = common_1.createComponent('button')({
27
+ displayName: 'Button',
28
+ Component: ({ children, icon, colors, iconPosition, shouldMirrorIcon, size = 'medium', ...elemProps }, ref, Element) => {
29
+ const baseIconPosition = iconPosition
30
+ ? iconPosition
31
+ : icon
32
+ ? children
33
+ ? 'start'
34
+ : 'only'
35
+ : undefined;
36
+ return (React.createElement(BaseButton_1.BaseButton, Object.assign({ as: Element, ref: ref, size: size, icon: icon, iconPosition: baseIconPosition }, elemProps),
37
+ icon && baseIconPosition === 'start' && (React.createElement(BaseButton_1.BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
38
+ children && React.createElement(BaseButton_1.BaseButton.Label, null, children),
39
+ icon && baseIconPosition === 'only' && (React.createElement(BaseButton_1.BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
40
+ icon && baseIconPosition === 'end' && (React.createElement(BaseButton_1.BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
41
+ },
42
+ });
@@ -1,12 +1,10 @@
1
- import * as React from 'react';
2
- import { BaseButtonProps } from './BaseButton';
3
- import { GrowthBehavior, Themeable } from '@workday/canvas-kit-react/common';
4
- export interface DeleteButtonProps extends Themeable, GrowthBehavior, BaseButtonProps {
5
- /**
6
- * The size of the Button.
7
- */
8
- size?: 'small' | 'medium' | 'large';
9
- children?: React.ReactNode;
1
+ import { ButtonProps } from './Button';
2
+ /**
3
+ * Extends all the style properties from Box to our buttons as well as props from ButtonProps.
4
+ * We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
5
+ * Use this type to extend and customize any one off buttons that you want full control over styling.
6
+ */
7
+ export interface DeleteButtonProps extends ButtonProps {
10
8
  }
11
9
  /**
12
10
  * Use sparingly for destructive actions that will result in data loss, can’t be undone, or will
@@ -1 +1 @@
1
- {"version":3,"file":"DeleteButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/DeleteButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAa,eAAe,EAAsC,MAAM,cAAc,CAAC;AAC9F,OAAO,EACL,cAAc,EAEd,SAAS,EAGV,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,iBAAkB,SAAQ,SAAS,EAAE,cAAc,EAAE,eAAe;IACnF;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0BD;;;;GAIG;AACH,eAAO,MAAM,YAAY,0FA0BvB,CAAC"}
1
+ {"version":3,"file":"DeleteButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/DeleteButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAS,WAAW,EAAC,MAAM,UAAU,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;CAAG;AA+BzD;;;;GAIG;AACH,eAAO,MAAM,YAAY,0FASvB,CAAC"}
@@ -23,23 +23,35 @@ exports.DeleteButton = void 0;
23
23
  const React = __importStar(require("react"));
24
24
  const BaseButton_1 = require("./BaseButton");
25
25
  const common_1 = require("@workday/canvas-kit-react/common");
26
- const getDeleteButtonColors = ({ canvas: { palette: { error: themeError }, }, }) => ({
27
- default: {
28
- background: themeError.main,
29
- label: themeError.contrast,
26
+ const canvas_kit_styling_1 = require("@workday/canvas-kit-styling");
27
+ const canvas_tokens_web_1 = require("@workday/canvas-tokens-web");
28
+ const Button_1 = require("./Button");
29
+ const deleteStyles = canvas_kit_styling_1.createStyles({
30
+ [BaseButton_1.buttonVars.default.background]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.base),
31
+ [BaseButton_1.buttonVars.default.border]: 'transparent',
32
+ [BaseButton_1.buttonVars.default.borderRadius]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.system.shape.circle),
33
+ [BaseButton_1.buttonVars.default.label]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.accent),
34
+ '&:hover, &.hover': {
35
+ [BaseButton_1.buttonVars.hover.background]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.dark),
36
+ [BaseButton_1.buttonVars.hover.border]: 'transparent',
37
+ [BaseButton_1.buttonVars.hover.label]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.accent),
30
38
  },
31
- hover: {
32
- background: themeError.dark,
39
+ '&:focus-visible, &.focus': {
40
+ [BaseButton_1.buttonVars.focus.background]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.base),
41
+ [BaseButton_1.buttonVars.focus.border]: 'transparent',
42
+ [BaseButton_1.buttonVars.focus.label]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.accent),
43
+ [BaseButton_1.buttonVars.focus.boxShadowInner]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.base.frenchVanilla100),
44
+ [BaseButton_1.buttonVars.focus.boxShadowOuter]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.common.focusOutline),
33
45
  },
34
- active: {
35
- background: themeError.darkest,
46
+ '&:active, &.active': {
47
+ [BaseButton_1.buttonVars.active.background]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.darkest),
48
+ [BaseButton_1.buttonVars.active.border]: 'transparent',
49
+ [BaseButton_1.buttonVars.active.label]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.accent),
36
50
  },
37
- focus: {
38
- background: themeError.main,
39
- },
40
- disabled: {
41
- background: themeError.light,
42
- opacity: '1', // allows for overriding the default opacity of 0.4
51
+ '&:disabled, &:active:disabled, &:focus:disabled, &:hover:disabled': {
52
+ [BaseButton_1.buttonVars.disabled.background]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.light),
53
+ [BaseButton_1.buttonVars.disabled.label]: canvas_kit_styling_1.cssVar(canvas_tokens_web_1.brand.error.accent),
54
+ opacity: 1,
43
55
  },
44
56
  });
45
57
  /**
@@ -49,9 +61,7 @@ const getDeleteButtonColors = ({ canvas: { palette: { error: themeError }, }, })
49
61
  */
50
62
  exports.DeleteButton = common_1.createComponent('button')({
51
63
  displayName: 'DeleteButton',
52
- Component: ({
53
- // TODO: Fix useTheme and make it a real hook
54
- // eslint-disable-next-line react-hooks/rules-of-hooks
55
- theme = common_1.useTheme(), size = 'medium', children, ...elemProps }, ref, Element) => (React.createElement(BaseButton_1.BaseButton, Object.assign({ padding: BaseButton_1.getPaddingStyles(children, size, undefined, undefined), minWidth: BaseButton_1.getMinWidthStyles(children, size), ref: ref, as: Element, colors: getDeleteButtonColors(theme), size: size }, elemProps),
56
- React.createElement(BaseButton_1.BaseButton.Label, null, children))),
64
+ Component: ({ children, cs, size, ...elemProps }, ref, Element) => {
65
+ return (React.createElement(Button_1.Button, Object.assign({ as: Element, ref: ref, size: size, cs: [deleteStyles, cs] }, elemProps), children));
66
+ },
57
67
  });