@workday/canvas-kit-react 6.0.0-alpha.0-next.26 → 6.0.0-alpha.0-next.30

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 (88) hide show
  1. package/action-bar/lib/ActionBar.tsx +43 -30
  2. package/button/lib/PrimaryButton.tsx +110 -32
  3. package/button/lib/SecondaryButton.tsx +31 -16
  4. package/button/lib/parts/ButtonContainer.tsx +16 -5
  5. package/button/lib/parts/ButtonLabelIcon.tsx +34 -14
  6. package/button/lib/types.ts +10 -0
  7. package/common/lib/theming/README.md +189 -25
  8. package/common/lib/theming/breakpoints.ts +296 -16
  9. package/common/lib/theming/types.ts +191 -1
  10. package/dist/commonjs/action-bar/lib/ActionBar.d.ts.map +1 -1
  11. package/dist/commonjs/action-bar/lib/ActionBar.js +35 -27
  12. package/dist/commonjs/button/lib/PrimaryButton.d.ts +80 -6
  13. package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
  14. package/dist/commonjs/button/lib/PrimaryButton.js +80 -26
  15. package/dist/commonjs/button/lib/SecondaryButton.d.ts +8 -5
  16. package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
  17. package/dist/commonjs/button/lib/SecondaryButton.js +22 -12
  18. package/dist/commonjs/button/lib/parts/ButtonContainer.d.ts +5 -3
  19. package/dist/commonjs/button/lib/parts/ButtonContainer.d.ts.map +1 -1
  20. package/dist/commonjs/button/lib/parts/ButtonContainer.js +11 -9
  21. package/dist/commonjs/button/lib/parts/ButtonLabel.d.ts +1 -1
  22. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
  23. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  24. package/dist/commonjs/button/lib/parts/ButtonLabelIcon.js +28 -13
  25. package/dist/commonjs/button/lib/types.d.ts +8 -0
  26. package/dist/commonjs/button/lib/types.d.ts.map +1 -1
  27. package/dist/commonjs/common/lib/theming/breakpoints.d.ts +287 -6
  28. package/dist/commonjs/common/lib/theming/breakpoints.d.ts.map +1 -1
  29. package/dist/commonjs/common/lib/theming/breakpoints.js +192 -10
  30. package/dist/commonjs/common/lib/theming/types.d.ts +191 -1
  31. package/dist/commonjs/common/lib/theming/types.d.ts.map +1 -1
  32. package/dist/commonjs/common/lib/utils/components.d.ts +1 -1
  33. package/dist/commonjs/pagination/lib/Pagination/PageList.d.ts +1 -1
  34. package/dist/commonjs/pagination/lib/Pagination/Pagination.d.ts +5 -5
  35. package/dist/commonjs/pagination/lib/Pagination/common/List.d.ts +1 -1
  36. package/dist/commonjs/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
  37. package/dist/es6/action-bar/lib/ActionBar.d.ts.map +1 -1
  38. package/dist/es6/action-bar/lib/ActionBar.js +33 -22
  39. package/dist/es6/button/lib/PrimaryButton.d.ts +80 -6
  40. package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
  41. package/dist/es6/button/lib/PrimaryButton.js +81 -27
  42. package/dist/es6/button/lib/SecondaryButton.d.ts +8 -5
  43. package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
  44. package/dist/es6/button/lib/SecondaryButton.js +22 -12
  45. package/dist/es6/button/lib/parts/ButtonContainer.d.ts +5 -3
  46. package/dist/es6/button/lib/parts/ButtonContainer.d.ts.map +1 -1
  47. package/dist/es6/button/lib/parts/ButtonContainer.js +11 -9
  48. package/dist/es6/button/lib/parts/ButtonLabel.d.ts +1 -1
  49. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
  50. package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
  51. package/dist/es6/button/lib/parts/ButtonLabelIcon.js +28 -13
  52. package/dist/es6/button/lib/types.d.ts +8 -0
  53. package/dist/es6/button/lib/types.d.ts.map +1 -1
  54. package/dist/es6/common/lib/theming/breakpoints.d.ts +287 -6
  55. package/dist/es6/common/lib/theming/breakpoints.d.ts.map +1 -1
  56. package/dist/es6/common/lib/theming/breakpoints.js +192 -10
  57. package/dist/es6/common/lib/theming/types.d.ts +191 -1
  58. package/dist/es6/common/lib/theming/types.d.ts.map +1 -1
  59. package/dist/es6/pagination/lib/Pagination/PageList.d.ts +1 -1
  60. package/dist/es6/pagination/lib/Pagination/Pagination.d.ts +5 -5
  61. package/dist/es6/pagination/lib/Pagination/common/List.d.ts +1 -1
  62. package/dist/es6/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
  63. package/package.json +5 -5
  64. package/ts3.5/dist/commonjs/button/lib/PrimaryButton.d.ts +80 -6
  65. package/ts3.5/dist/commonjs/button/lib/SecondaryButton.d.ts +8 -5
  66. package/ts3.5/dist/commonjs/button/lib/parts/ButtonContainer.d.ts +5 -3
  67. package/ts3.5/dist/commonjs/button/lib/parts/ButtonLabel.d.ts +1 -1
  68. package/ts3.5/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
  69. package/ts3.5/dist/commonjs/button/lib/types.d.ts +8 -0
  70. package/ts3.5/dist/commonjs/common/lib/theming/breakpoints.d.ts +287 -6
  71. package/ts3.5/dist/commonjs/common/lib/theming/types.d.ts +191 -1
  72. package/ts3.5/dist/commonjs/common/lib/utils/components.d.ts +1 -1
  73. package/ts3.5/dist/commonjs/pagination/lib/Pagination/PageList.d.ts +1 -1
  74. package/ts3.5/dist/commonjs/pagination/lib/Pagination/Pagination.d.ts +5 -5
  75. package/ts3.5/dist/commonjs/pagination/lib/Pagination/common/List.d.ts +1 -1
  76. package/ts3.5/dist/commonjs/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
  77. package/ts3.5/dist/es6/button/lib/PrimaryButton.d.ts +80 -6
  78. package/ts3.5/dist/es6/button/lib/SecondaryButton.d.ts +8 -5
  79. package/ts3.5/dist/es6/button/lib/parts/ButtonContainer.d.ts +5 -3
  80. package/ts3.5/dist/es6/button/lib/parts/ButtonLabel.d.ts +1 -1
  81. package/ts3.5/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
  82. package/ts3.5/dist/es6/button/lib/types.d.ts +8 -0
  83. package/ts3.5/dist/es6/common/lib/theming/breakpoints.d.ts +287 -6
  84. package/ts3.5/dist/es6/common/lib/theming/types.d.ts +191 -1
  85. package/ts3.5/dist/es6/pagination/lib/Pagination/PageList.d.ts +1 -1
  86. package/ts3.5/dist/es6/pagination/lib/Pagination/Pagination.d.ts +5 -5
  87. package/ts3.5/dist/es6/pagination/lib/Pagination/common/List.d.ts +1 -1
  88. package/ts3.5/dist/es6/pagination/lib/Pagination/common/utils/space.d.ts +28 -28
@@ -36,12 +36,202 @@ export interface CanvasTheme {
36
36
  success: CanvasThemePalette;
37
37
  neutral: CanvasThemePalette;
38
38
  };
39
+ /**
40
+ * ### Theme Breakpoints
41
+ *
42
+ * Breakpoints are used by media queries to conditionally apply or modify styles based on the viewport width.
43
+ * This allows the UI to be responsive to various screen sizes.
44
+ *
45
+ * This breakpoints object contains `values` and several helper functions: `up`, `down`, `between`, and `only`.
46
+ * You can find more detailed information by inspecting individual values and functions.
47
+ */
39
48
  breakpoints: {
49
+ /**
50
+ * ### Breakpoint Values
51
+ *
52
+ * This object provides five breakpoint values
53
+ * that correspond to the min-widths of our standard screen sizes.
54
+ *
55
+ * - `zero`: 0
56
+ * - `s`: 320
57
+ * - `m`: 768
58
+ * - `l`: 1024
59
+ * - `xl`: 1440
60
+ *
61
+ * And these are our standard screen size ranges:
62
+ *
63
+ * - `small` (320px - 767px) Used for mobile-sized screens
64
+ * - `medium` (768px - 1023px) Used for tablet-sized screens
65
+ * - `large` - (1024px - 1439px) Used for laptop and small desktop screens
66
+ * - `extra-large` (≥1440px) Used for very large screens
67
+ *
68
+ * Note: Some applications may only require a subset of screen sizes and not use all breakpoints.
69
+ *
70
+ */
40
71
  values: CanvasBreakpoints;
72
+ /**
73
+ * ### Up
74
+ *
75
+ * _Returns a media query above the `min-width` for the range of a given breakpoint_
76
+ *
77
+ * Given a `start` breakpoint key ("zero", "s", "m", "l", "xl"),
78
+ * this function returns a media query (string) using a `min-width`.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * import { useTheme } from '@workday/canvas-kit-react/common';
83
+ * import { space } from '@workday/canvas-kit-react/tokens';
84
+ *
85
+ * const theme = useTheme();
86
+ * const { up } = theme.canvas.breakpoints;
87
+ * const mediaQuery = up('l'); // Returns '@media (min-width: 1024px)'
88
+ * const styles = {
89
+ * [mediaQuery]: {
90
+ * padding: space.m,
91
+ * }
92
+ * };
93
+ * ```
94
+ */
41
95
  up: (key: BreakpointFnParam) => string;
96
+ /**
97
+ * ### Down
98
+ *
99
+ * _Returns a media query below the `max-width` for the range of a given breakpoint_
100
+ *
101
+ * Given an `end` breakpoint key ("zero", "s", "m", "l", "xl"),
102
+ * this function returns a media query (string) using a `max-width`.
103
+ *
104
+ * Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions.
105
+ * For example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
106
+ *
107
+ * If the `xl` breakpoint is provided, this function returns a media query with only a `min-width` of `0`,
108
+ * as seen in the second example below.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { useTheme } from '@workday/canvas-kit-react/common';
113
+ * import { space } from '@workday/canvas-kit-react/tokens';
114
+ *
115
+ * const theme = useTheme();
116
+ * const { down } = theme.canvas.breakpoints;
117
+ * const mediaQuery = down('m'); // Returns '@media (max-width: 1023.5px)'
118
+ * const styles = {
119
+ * [mediaQuery]: {
120
+ * padding: space.m,
121
+ * }
122
+ * };
123
+ * ```
124
+ *
125
+ * This example uses the `xl` breakpoint and only adds a `min-width` of `0` to the media query.
126
+ * @example
127
+ * ```ts
128
+ * import { useTheme } from '@workday/canvas-kit-react/common';
129
+ * import { space } from '@workday/canvas-kit-react/tokens';
130
+ *
131
+ * const theme = useTheme();
132
+ * const { down } = theme.canvas.breakpoints;
133
+ * const mediaQuery = down('xl'); // Returns '@media (min-width: 0)'
134
+ * const styles = {
135
+ * [mediaQuery]: {
136
+ * padding: space.m,
137
+ * }
138
+ * };
139
+ * ```
140
+ */
42
141
  down: (key: BreakpointFnParam) => string;
43
- only: (key: BreakpointFnParam) => string;
142
+ /**
143
+ * ### Between
144
+ *
145
+ * _Returns a media query between two given breakpoints_
146
+ *
147
+ * Given `start` and `end` breakpoint keys ("zero", "s", "m", "l", "xl"),
148
+ * this function returns a media query (string) using a min-width and max-width.
149
+ *
150
+ * Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions.
151
+ * For example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
152
+ *
153
+ * If the `xl` breakpoint is provided, this function returns a media query with only a `min-width`,
154
+ * as seen in the second example below.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * import { useTheme } from '@workday/canvas-kit-react/common';
159
+ * import { space } from '@workday/canvas-kit-react/tokens';
160
+ *
161
+ * const theme = useTheme();
162
+ * const { between } = theme.canvas.breakpoints;
163
+ * // Returns '@media (min-width: 320px) and (max-width: 1023.5px)'
164
+ * const mediaQuery = between('s', 'm');
165
+ * const styles = {
166
+ * [mediaQuery]: {
167
+ * padding: space.s,
168
+ * }
169
+ * };
170
+ * ```
171
+ *
172
+ * This example uses `xl` as the `end` breakpoint and only adds a min-width to the media query.
173
+ * @example
174
+ * ```ts
175
+ * import { useTheme } from '@workday/canvas-kit-react/common';
176
+ * import { space } from '@workday/canvas-kit-react/tokens';
177
+ *
178
+ * const theme = useTheme();
179
+ * const { between } = theme.canvas.breakpoints;
180
+ * const mediaQuery = between('m', 'xl'); // Returns '@media (min-width: 768px)'
181
+ * const styles = {
182
+ * [mediaQuery]: {
183
+ * padding: space.s,
184
+ * }
185
+ * };
186
+ * ```
187
+ */
44
188
  between: (start: BreakpointFnParam, end: BreakpointFnParam) => string;
189
+ /**
190
+ * ### Only
191
+ *
192
+ * _Returns a media query with a `min-width` and `max-width` for a given breakpoint_
193
+ *
194
+ * Given a breakpoint key ("zero", "s", "m", "l", "xl"),
195
+ * this function returns a media query (string) using a `min-width` and `max-width`.
196
+ *
197
+ * Note: This function subtracts `0.5px` from the next breakpoint value to prevent collisions.
198
+ * For example, `breakpoints.values.s`, has a `min-width` of `320px`, and the `max-width` is `767.5px`).
199
+ *
200
+ * If the `xl` breakpoint is provided, this function returns a media query with only a `min-width` of `1440px`,
201
+ * as seen in the second example below.
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * import { useTheme } from '@workday/canvas-kit-react/common';
206
+ * import { space } from '@workday/canvas-kit-react/tokens';
207
+ *
208
+ * const theme = useTheme();
209
+ * const { only } = theme.canvas.breakpoints;
210
+ * const mediaQuery = only('s'); // Returns '@media (min-width: 320px) and (max-width: 767.5px)'
211
+ * const styles = {
212
+ * [mediaQuery]: {
213
+ * padding: space.s,
214
+ * }
215
+ * };
216
+ * ```
217
+ *
218
+ * This example uses the `xl` breakpoint and only adds a `min-width` of `1440px` to the media query.
219
+ * @example
220
+ * ```ts
221
+ * import { useTheme } from '@workday/canvas-kit-react/common';
222
+ * import { space } from '@workday/canvas-kit-react/tokens';
223
+ *
224
+ * const theme = useTheme();
225
+ * const { only } = theme.canvas.breakpoints;
226
+ * const mediaQuery = only('xl'); // Returns '@media (min-width: 1440px)'
227
+ * const styles = {
228
+ * [mediaQuery]: {
229
+ * padding: space.s,
230
+ * }
231
+ * };
232
+ * ```
233
+ */
234
+ only: (key: BreakpointFnParam) => string;
45
235
  };
46
236
  direction: ContentDirection;
47
237
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../../../action-bar/lib/ActionBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC1E;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA0CD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IAC7D,MAAM;CASd"}
1
+ {"version":3,"file":"ActionBar.d.ts","sourceRoot":"","sources":["../../../../action-bar/lib/ActionBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC1E;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAuDD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC;IAC7D,MAAM;CASd"}
@@ -41,49 +41,57 @@ var __importStar = (this && this.__importStar) || function (mod) {
41
41
  result["default"] = mod;
42
42
  return result;
43
43
  };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
44
  Object.defineProperty(exports, "__esModule", { value: true });
48
45
  var React = __importStar(require("react"));
49
- var styled_1 = __importDefault(require("@emotion/styled"));
46
+ var common_1 = require("@workday/canvas-kit-react/common");
50
47
  var tokens_1 = require("@workday/canvas-kit-react/tokens");
51
- var ActionBarContainer = styled_1.default('div')({
48
+ function getFixedStyles(fixed) {
49
+ if (fixed === void 0) { fixed = false; }
50
+ return fixed
51
+ ? {
52
+ position: 'fixed',
53
+ left: 0,
54
+ bottom: 0,
55
+ right: 0,
56
+ }
57
+ : {};
58
+ }
59
+ var ActionBarContainer = common_1.styled('div')({
52
60
  borderTop: "solid 1px " + tokens_1.colors.soap400,
53
61
  background: tokens_1.commonColors.background,
54
62
  padding: tokens_1.space.s,
55
63
  boxShadow: '0 -2px 4px rgba(0, 0, 0, 0.08)',
56
- '@media (max-width: 575px)': {
57
- padding: tokens_1.space.xxs,
58
- },
59
64
  }, function (_a) {
60
- var fixed = _a.fixed;
61
- return fixed && {
62
- position: 'fixed',
63
- left: 0,
64
- bottom: 0,
65
- right: 0,
66
- };
65
+ var _b;
66
+ var fixed = _a.fixed, theme = _a.theme;
67
+ return __assign(__assign({}, getFixedStyles(fixed)), (_b = {}, _b[theme.canvas.breakpoints.down('s')] = {
68
+ padding: tokens_1.space.xxs,
69
+ }, _b));
67
70
  });
68
- var ChildrenContainer = styled_1.default('div')({
71
+ var ChildrenContainer = common_1.styled('div')({
69
72
  display: 'inline-block',
70
73
  padding: "0 " + tokens_1.space.m,
71
74
  '*:not(:first-of-type)': {
72
75
  marginLeft: tokens_1.space.s,
73
76
  },
74
- '@media (max-width: 575px)': {
75
- display: 'flex',
76
- padding: tokens_1.space.xxs,
77
- justifyContent: 'center',
78
- flexDirection: 'row-reverse',
79
- '> *': {
80
- flex: 1,
81
- '&:not(:first-of-type)': {
82
- marginRight: tokens_1.space.s,
83
- marginLeft: 0,
77
+ }, function (_a) {
78
+ var _b;
79
+ var theme = _a.theme;
80
+ return (_b = {},
81
+ _b[theme.canvas.breakpoints.down('s')] = {
82
+ display: 'flex',
83
+ padding: tokens_1.space.xxs,
84
+ justifyContent: 'center',
85
+ flexDirection: 'row-reverse',
86
+ '> *': {
87
+ flex: 1,
88
+ '&:not(:first-of-type)': {
89
+ marginRight: tokens_1.space.s,
90
+ marginLeft: 0,
91
+ },
84
92
  },
85
93
  },
86
- },
94
+ _b);
87
95
  });
88
96
  var ActionBar = /** @class */ (function (_super) {
89
97
  __extends(ActionBar, _super);
@@ -1,13 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import { GrowthBehavior, Themeable, EmotionCanvasTheme } from '@workday/canvas-kit-react/common';
3
3
  import { CanvasSystemIcon } from '@workday/design-assets-types';
4
- import { ButtonColors } from './types';
4
+ import { ButtonSizes, IconPositions } from './types';
5
5
  export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
6
6
  /**
7
- * The size of the Button.
7
+ * The variant of the PrimaryButton.
8
+ * @default undefined
9
+ */
10
+ variant?: 'inverse';
11
+ /**
12
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
13
+ * If no size is provided, it will default to `medium`.
14
+ *
8
15
  * @default 'medium'
9
16
  */
10
- size?: 'small' | 'medium' | 'large';
17
+ size?: ButtonSizes;
11
18
  /**
12
19
  * The data label of the Button.
13
20
  * Note: not displayed at `small` size
@@ -19,10 +26,11 @@ export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
19
26
  */
20
27
  icon?: CanvasSystemIcon;
21
28
  /**
22
- * The position of the TertiaryButton icon.
29
+ * Button icon positions can either be `left` or `right`.
30
+ * If no value is provided, it defaults to `left`.
23
31
  * @default 'left'
24
32
  */
25
- iconPosition?: 'left' | 'right';
33
+ iconPosition?: IconPositions;
26
34
  /**
27
35
  * If set to `true`, transform the icon's x-axis to mirror the graphic
28
36
  * @default false
@@ -31,5 +39,71 @@ export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
31
39
  children?: React.ReactNode;
32
40
  }
33
41
  export declare const PrimaryButton: import("../../common").ElementComponent<"button", PrimaryButtonProps>;
34
- export declare const getPrimaryButtonColors: ({ canvas: { palette: { primary: themePrimary }, }, }: EmotionCanvasTheme) => ButtonColors;
42
+ export declare const getPrimaryButtonColors: (variant: "inverse" | undefined, theme: EmotionCanvasTheme) => {
43
+ default: {
44
+ background: string;
45
+ icon: string;
46
+ label: string;
47
+ labelData?: undefined;
48
+ };
49
+ hover: {
50
+ background: string;
51
+ icon?: undefined;
52
+ label?: undefined;
53
+ labelData?: undefined;
54
+ };
55
+ active: {
56
+ background: string;
57
+ icon?: undefined;
58
+ label?: undefined;
59
+ labelData?: undefined;
60
+ };
61
+ focus: {
62
+ background: string;
63
+ border?: undefined;
64
+ icon?: undefined;
65
+ label?: undefined;
66
+ labelData?: undefined;
67
+ focusRing?: undefined;
68
+ };
69
+ disabled: {
70
+ background: string;
71
+ icon?: undefined;
72
+ label?: undefined;
73
+ labelData?: undefined;
74
+ };
75
+ } | {
76
+ default: {
77
+ background: string;
78
+ icon: string;
79
+ label: string;
80
+ labelData: string;
81
+ };
82
+ hover: {
83
+ background: string;
84
+ icon: string;
85
+ label: string;
86
+ labelData: string;
87
+ };
88
+ active: {
89
+ background: string;
90
+ icon: string;
91
+ label: string;
92
+ labelData: string;
93
+ };
94
+ focus: {
95
+ background: string;
96
+ border: string;
97
+ icon: string;
98
+ label: string;
99
+ labelData: string;
100
+ focusRing: import("@emotion/serialize").CSSObject;
101
+ };
102
+ disabled: {
103
+ background: string;
104
+ icon: string;
105
+ label: string;
106
+ labelData: string;
107
+ };
108
+ };
35
109
  //# sourceMappingURL=PrimaryButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/PrimaryButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,cAAc,EAEd,SAAS,EACT,kBAAkB,EAEnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAGrC,MAAM,WAAW,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IACnE;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,uEA6CxB,CAAC;AAEH,eAAO,MAAM,sBAAsB,4FAsBjC,CAAC"}
1
+ {"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/PrimaryButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EACL,cAAc,EAEd,SAAS,EACT,kBAAkB,EAGnB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAEnD,MAAM,WAAW,kBAAmB,SAAQ,SAAS,EAAE,cAAc;IACnE;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAYD,eAAO,MAAM,aAAa,uEA+CxB,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ElC,CAAC"}
@@ -31,7 +31,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
32
  var React = __importStar(require("react"));
33
33
  var common_1 = require("@workday/canvas-kit-react/common");
34
+ var tokens_1 = require("@workday/canvas-kit-react/tokens");
34
35
  var parts_1 = require("./parts");
36
+ // Button sizes where data labels are enabled
37
+ var dataLabelSizes = ['medium', 'large'];
38
+ // All disabled buttons are set to 40% opacity.
39
+ // This will eventually live in the ButtonContainer styles, but for now we're scoping it to Primary, Secondary, and Tertiary buttons.
40
+ var disabledButtonOpacity = {
41
+ '&:disabled, &:disabled:active': {
42
+ opacity: 0.4,
43
+ },
44
+ };
35
45
  exports.PrimaryButton = common_1.createComponent('button')({
36
46
  displayName: 'PrimaryButton',
37
47
  Component: function (_a, ref, Element) {
@@ -41,33 +51,77 @@ exports.PrimaryButton = common_1.createComponent('button')({
41
51
  _b = _a.theme,
42
52
  // TODO: Fix useTheme and make it a real hook
43
53
  // eslint-disable-next-line react-hooks/rules-of-hooks
44
- theme = _b === void 0 ? common_1.useTheme() : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, _d = _a.iconPosition, iconPosition = _d === void 0 ? 'left' : _d, dataLabel = _a.dataLabel, icon = _a.icon, _e = _a.shouldMirrorIcon, shouldMirrorIcon = _e === void 0 ? false : _e, children = _a.children, elemProps = __rest(_a, ["theme", "size", "iconPosition", "dataLabel", "icon", "shouldMirrorIcon", "children"]);
45
- return (React.createElement(parts_1.ButtonContainer, __assign({ ref: ref, as: Element, colors: exports.getPrimaryButtonColors(theme), size: size }, elemProps),
46
- icon && size !== 'small' && iconPosition === 'left' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
54
+ theme = _b === void 0 ? common_1.useTheme() : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, _d = _a.iconPosition, iconPosition = _d === void 0 ? 'left' : _d, variant = _a.variant, dataLabel = _a.dataLabel, icon = _a.icon, _e = _a.shouldMirrorIcon, shouldMirrorIcon = _e === void 0 ? false : _e, children = _a.children, elemProps = __rest(_a, ["theme", "size", "iconPosition", "variant", "dataLabel", "icon", "shouldMirrorIcon", "children"]);
55
+ return (React.createElement(parts_1.ButtonContainer, __assign({ ref: ref, as: Element, colors: exports.getPrimaryButtonColors(variant, theme), size: size, extraStyles: disabledButtonOpacity }, elemProps),
56
+ icon && iconPosition === 'left' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
47
57
  React.createElement(parts_1.ButtonLabel, null, children),
48
- dataLabel && size !== 'small' && React.createElement(parts_1.ButtonLabelData, null, dataLabel),
49
- icon && size !== 'small' && iconPosition === 'right' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
58
+ dataLabel && dataLabelSizes.includes(size) && React.createElement(parts_1.ButtonLabelData, null, dataLabel),
59
+ icon && iconPosition === 'right' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
50
60
  },
51
61
  });
52
- exports.getPrimaryButtonColors = function (_a) {
53
- var themePrimary = _a.canvas.palette.primary;
54
- return ({
55
- default: {
56
- background: themePrimary.main,
57
- icon: themePrimary.contrast,
58
- label: themePrimary.contrast,
59
- },
60
- hover: {
61
- background: themePrimary.dark,
62
- },
63
- active: {
64
- background: themePrimary.darkest,
65
- },
66
- focus: {
67
- background: themePrimary.main,
68
- },
69
- disabled: {
70
- background: themePrimary.light,
71
- },
72
- });
62
+ exports.getPrimaryButtonColors = function (variant, theme) {
63
+ var themePrimary = theme.canvas.palette.primary;
64
+ switch (variant) {
65
+ case undefined:
66
+ default:
67
+ return {
68
+ default: {
69
+ background: themePrimary.main,
70
+ icon: themePrimary.contrast,
71
+ label: themePrimary.contrast,
72
+ },
73
+ hover: {
74
+ background: themePrimary.dark,
75
+ },
76
+ active: {
77
+ background: themePrimary.darkest,
78
+ },
79
+ focus: {
80
+ background: themePrimary.main,
81
+ },
82
+ disabled: {
83
+ background: themePrimary.main,
84
+ },
85
+ };
86
+ case 'inverse':
87
+ return {
88
+ default: {
89
+ background: tokens_1.colors.frenchVanilla100,
90
+ icon: tokens_1.colors.blackPepper400,
91
+ label: tokens_1.colors.blackPepper400,
92
+ labelData: tokens_1.colors.blackPepper400,
93
+ },
94
+ hover: {
95
+ background: tokens_1.colors.soap300,
96
+ icon: tokens_1.colors.blackPepper500,
97
+ label: tokens_1.colors.blackPepper500,
98
+ labelData: tokens_1.colors.blackPepper500,
99
+ },
100
+ active: {
101
+ background: tokens_1.colors.soap300,
102
+ icon: tokens_1.colors.blackPepper500,
103
+ label: tokens_1.colors.blackPepper500,
104
+ labelData: tokens_1.colors.blackPepper500,
105
+ },
106
+ focus: {
107
+ background: tokens_1.colors.frenchVanilla100,
108
+ border: tokens_1.colors.blackPepper400,
109
+ icon: tokens_1.colors.blackPepper400,
110
+ label: tokens_1.colors.blackPepper400,
111
+ labelData: tokens_1.colors.blackPepper400,
112
+ focusRing: common_1.focusRing({
113
+ separation: 1,
114
+ innerColor: tokens_1.colors.blackPepper500,
115
+ outerColor: tokens_1.colors.frenchVanilla100,
116
+ }, theme),
117
+ },
118
+ // Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
119
+ disabled: {
120
+ background: tokens_1.colors.frenchVanilla100,
121
+ icon: tokens_1.colors.blackPepper400,
122
+ label: tokens_1.colors.blackPepper400,
123
+ labelData: tokens_1.colors.blackPepper400,
124
+ },
125
+ };
126
+ }
73
127
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { GrowthBehavior, Themeable, EmotionCanvasTheme } from '@workday/canvas-kit-react/common';
3
3
  import { CanvasSystemIcon } from '@workday/design-assets-types';
4
- import { ButtonColors } from './types';
4
+ import { ButtonColors, ButtonSizes, IconPositions } from './types';
5
5
  export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
6
6
  /**
7
7
  * The variant of the SecondaryButton.
@@ -9,10 +9,12 @@ export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
9
9
  */
10
10
  variant?: 'inverse' | undefined;
11
11
  /**
12
- * The size of the Button.
12
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
13
+ * If no size is provided, it will default to `medium`.
14
+ *
13
15
  * @default 'medium'
14
16
  */
15
- size?: 'small' | 'medium' | 'large';
17
+ size?: ButtonSizes;
16
18
  /**
17
19
  * The data label of the Button.
18
20
  * Note: not displayed at `small` size
@@ -24,10 +26,11 @@ export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
24
26
  */
25
27
  icon?: CanvasSystemIcon;
26
28
  /**
27
- * The position of the TertiaryButton icon.
29
+ * Button icon positions can either be `left` or `right`.
30
+ * If no value is provided, it defaults to `left`.
28
31
  * @default 'left'
29
32
  */
30
- iconPosition?: 'left' | 'right';
33
+ iconPosition?: IconPositions;
31
34
  /**
32
35
  * If set to `true`, transform the icon's x-axis to mirror the graphic
33
36
  * @default false
@@ -1 +1 @@
1
- {"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/SecondaryButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,cAAc,EAEd,SAAS,EACT,kBAAkB,EAGnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAGrC,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACpC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,eAAO,MAAM,eAAe,yEA8C1B,CAAC;AAEH,eAAO,MAAM,wBAAwB,6EA8FpC,CAAC"}
1
+ {"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/SecondaryButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EACL,cAAc,EAEd,SAAS,EACT,kBAAkB,EAGnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAC,MAAM,SAAS,CAAC;AAGjE,MAAM,WAAW,oBAAqB,SAAQ,SAAS,EAAE,cAAc;IACrE;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAYD,eAAO,MAAM,eAAe,yEA+C1B,CAAC;AAEH,eAAO,MAAM,wBAAwB,6EA+FpC,CAAC"}
@@ -33,6 +33,15 @@ var React = __importStar(require("react"));
33
33
  var tokens_1 = require("@workday/canvas-kit-react/tokens");
34
34
  var common_1 = require("@workday/canvas-kit-react/common");
35
35
  var parts_1 = require("./parts");
36
+ // Button sizes where data labels are enabled
37
+ var dataLabelSizes = ['medium', 'large'];
38
+ // All disabled buttons are set to 40% opacity.
39
+ // This will eventually live in the ButtonContainer styles, but for now we're scoping it to Primary, Secondary, and Tertiary buttons.
40
+ var disabledButtonOpacity = {
41
+ '&:disabled, &:disabled:active': {
42
+ opacity: 0.4,
43
+ },
44
+ };
36
45
  exports.SecondaryButton = common_1.createComponent('button')({
37
46
  displayName: 'SecondaryButton',
38
47
  Component: function (_a, ref, Element) {
@@ -43,11 +52,11 @@ exports.SecondaryButton = common_1.createComponent('button')({
43
52
  // TODO: Fix useTheme and make it a real hook
44
53
  // eslint-disable-next-line react-hooks/rules-of-hooks
45
54
  theme = _b === void 0 ? common_1.useTheme() : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, _d = _a.iconPosition, iconPosition = _d === void 0 ? 'left' : _d, variant = _a.variant, dataLabel = _a.dataLabel, icon = _a.icon, _e = _a.shouldMirrorIcon, shouldMirrorIcon = _e === void 0 ? false : _e, children = _a.children, elemProps = __rest(_a, ["theme", "size", "iconPosition", "variant", "dataLabel", "icon", "shouldMirrorIcon", "children"]);
46
- return (React.createElement(parts_1.ButtonContainer, __assign({ ref: ref, as: Element, colors: exports.getSecondaryButtonColors(variant, theme), size: size }, elemProps),
47
- icon && size !== 'small' && iconPosition === 'left' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
55
+ return (React.createElement(parts_1.ButtonContainer, __assign({ ref: ref, as: Element, colors: exports.getSecondaryButtonColors(variant, theme), size: size, extraStyles: disabledButtonOpacity }, elemProps),
56
+ icon && iconPosition === 'left' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
48
57
  React.createElement(parts_1.ButtonLabel, null, children),
49
- dataLabel && size !== 'small' && React.createElement(parts_1.ButtonLabelData, null, dataLabel),
50
- icon && size !== 'small' && iconPosition === 'right' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
58
+ dataLabel && dataLabelSizes.includes(size) && React.createElement(parts_1.ButtonLabelData, null, dataLabel),
59
+ icon && iconPosition === 'right' && (React.createElement(parts_1.ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
51
60
  },
52
61
  });
53
62
  exports.getSecondaryButtonColors = function (variant, theme) {
@@ -83,12 +92,13 @@ exports.getSecondaryButtonColors = function (variant, theme) {
83
92
  label: tokens_1.colors.blackPepper400,
84
93
  labelData: tokens_1.colors.blackPepper400,
85
94
  },
95
+ // Identical to 'default' styles. ButtonContainer will set opacity to 40%
86
96
  disabled: {
87
97
  background: 'transparent',
88
- border: 'rgba(30, 30, 30, 0.4)',
89
- icon: 'rgba(30, 30, 30, 0.4)',
90
- label: 'rgba(30, 30, 30, 0.4)',
91
- labelData: 'rgba(30, 30, 30, 0.4)',
98
+ border: tokens_1.colors.blackPepper400,
99
+ icon: tokens_1.colors.blackPepper400,
100
+ label: tokens_1.colors.blackPepper400,
101
+ labelData: tokens_1.colors.blackPepper400,
92
102
  },
93
103
  };
94
104
  case 'inverse':
@@ -124,12 +134,12 @@ exports.getSecondaryButtonColors = function (variant, theme) {
124
134
  outerColor: tokens_1.colors.frenchVanilla100,
125
135
  }, theme),
126
136
  },
137
+ // Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
127
138
  disabled: {
128
139
  background: 'transparent',
129
- border: 'rgba(255, 255, 255, 0.4)',
130
- icon: 'rgba(255, 255, 255, 0.4)',
131
- label: 'rgba(255, 255, 255, 0.4)',
132
- labelData: 'rgba(255, 255, 255, 0.4)',
140
+ border: tokens_1.colors.frenchVanilla100,
141
+ icon: tokens_1.colors.frenchVanilla100,
142
+ label: tokens_1.colors.frenchVanilla100,
133
143
  },
134
144
  };
135
145
  }