@workday/canvas-kit-react 10.0.0-alpha.446-next.0 → 10.0.0-alpha.449-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 (70) hide show
  1. package/button/lib/BaseButton.tsx +4 -4
  2. package/checkbox/lib/Checkbox.tsx +18 -12
  3. package/dist/commonjs/button/lib/BaseButton.d.ts +1 -1
  4. package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
  5. package/dist/commonjs/button/lib/BaseButton.js +4 -4
  6. package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
  7. package/dist/commonjs/checkbox/lib/Checkbox.js +11 -11
  8. package/dist/commonjs/popup/lib/Popper.d.ts +4 -4
  9. package/dist/commonjs/popup/lib/Popper.d.ts.map +1 -1
  10. package/dist/commonjs/popup/lib/Popper.js +2 -2
  11. package/dist/commonjs/popup/lib/fallbackPlacements.d.ts +3 -3
  12. package/dist/commonjs/popup/lib/fallbackPlacements.d.ts.map +1 -1
  13. package/dist/commonjs/popup/lib/fallbackPlacements.js +3 -22
  14. package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
  15. package/dist/commonjs/radio/lib/Radio.js +13 -13
  16. package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
  17. package/dist/commonjs/select/lib/Select.js +1 -1
  18. package/dist/commonjs/table/lib/TableRow.js +1 -1
  19. package/dist/commonjs/text-area/lib/TextArea.d.ts.map +1 -1
  20. package/dist/commonjs/text-area/lib/TextArea.js +3 -3
  21. package/dist/commonjs/text-input/lib/TextInput.js +1 -1
  22. package/dist/commonjs/tokens/index.d.ts.map +1 -1
  23. package/dist/commonjs/tokens/lib/depth.d.ts +6 -6
  24. package/dist/commonjs/tokens/lib/depth.d.ts.map +1 -1
  25. package/dist/commonjs/tokens/lib/depth.js +6 -6
  26. package/dist/commonjs/tokens/lib/space.d.ts +65 -27
  27. package/dist/commonjs/tokens/lib/space.d.ts.map +1 -1
  28. package/dist/commonjs/tokens/lib/space.js +61 -23
  29. package/dist/commonjs/tooltip/lib/TooltipContainer.js +8 -8
  30. package/dist/es6/button/lib/BaseButton.d.ts +1 -1
  31. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  32. package/dist/es6/button/lib/BaseButton.js +4 -4
  33. package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
  34. package/dist/es6/checkbox/lib/Checkbox.js +12 -12
  35. package/dist/es6/popup/lib/Popper.d.ts +4 -4
  36. package/dist/es6/popup/lib/Popper.d.ts.map +1 -1
  37. package/dist/es6/popup/lib/Popper.js +2 -2
  38. package/dist/es6/popup/lib/fallbackPlacements.d.ts +3 -3
  39. package/dist/es6/popup/lib/fallbackPlacements.d.ts.map +1 -1
  40. package/dist/es6/popup/lib/fallbackPlacements.js +3 -3
  41. package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
  42. package/dist/es6/radio/lib/Radio.js +14 -14
  43. package/dist/es6/select/lib/Select.d.ts.map +1 -1
  44. package/dist/es6/select/lib/Select.js +2 -2
  45. package/dist/es6/table/lib/TableRow.js +1 -1
  46. package/dist/es6/text-area/lib/TextArea.d.ts.map +1 -1
  47. package/dist/es6/text-area/lib/TextArea.js +4 -4
  48. package/dist/es6/text-input/lib/TextInput.js +1 -1
  49. package/dist/es6/tokens/index.d.ts.map +1 -1
  50. package/dist/es6/tokens/index.js +1 -1
  51. package/dist/es6/tokens/lib/depth.d.ts +6 -6
  52. package/dist/es6/tokens/lib/depth.d.ts.map +1 -1
  53. package/dist/es6/tokens/lib/depth.js +6 -6
  54. package/dist/es6/tokens/lib/space.d.ts +65 -27
  55. package/dist/es6/tokens/lib/space.d.ts.map +1 -1
  56. package/dist/es6/tokens/lib/space.js +61 -23
  57. package/dist/es6/tooltip/lib/TooltipContainer.js +8 -8
  58. package/package.json +3 -3
  59. package/popup/lib/Popper.tsx +6 -6
  60. package/popup/lib/fallbackPlacements.ts +16 -8
  61. package/radio/lib/Radio.tsx +20 -14
  62. package/select/lib/Select.tsx +2 -9
  63. package/table/lib/TableRow.tsx +1 -1
  64. package/text-area/lib/TextArea.tsx +10 -4
  65. package/text-input/lib/TextInput.tsx +1 -1
  66. package/tokens/README.md +19 -19
  67. package/tokens/index.ts +1 -2
  68. package/tokens/lib/depth.ts +16 -12
  69. package/tokens/lib/space.ts +84 -46
  70. package/tooltip/lib/TooltipContainer.tsx +8 -8
@@ -33,7 +33,7 @@ const StyledTextInput = styled('input')<
33
33
  boxSizing: 'border-box',
34
34
  height: 40,
35
35
  transition: '0.2s box-shadow, 0.2s border-color',
36
- padding: spaceNumbers.xxs, // Compensate for border
36
+ padding: `${spaceNumbers.xxs}rem`, // Compensate for border
37
37
  margin: 0, // Fix Safari
38
38
  '&::placeholder': {
39
39
  color: inputColors.placeholder,
package/tokens/README.md CHANGED
@@ -133,42 +133,42 @@ Border Radius variables are in a "t-shirt size" format. Border Radius values are
133
133
  Space variables are in a "t-shirt size" format. Space values are in `px` format (`space`) or number
134
134
  format (`spaceNumbers`).
135
135
 
136
- | Variable | Size (px) | Size (number) |
137
- | -------- | --------- | ------------- |
138
- | `xxxs` | `'4px'` | `4` |
139
- | `xxs` | `'8px'` | `8` |
140
- | `xs` | `'12px'` | `12` |
141
- | `s` | `'16px'` | `16` |
142
- | `m` | `'24px'` | `24` |
143
- | `l` | `'32px'` | `32` |
144
- | `xl` | `'40px'` | `40` |
145
- | `xxl` | `'64px'` | `64` |
146
- | `xxxl` | `'80px'` | `80` |
136
+ | Variable | Size (rem) | Size (number) |
137
+ | -------- | ----------- | ------------- |
138
+ | `xxxs` | `'0.25rem'` | `0.25` |
139
+ | `xxs` | `'0.5rem'` | `0.5` |
140
+ | `xs` | `'0.75rem'` | `0.75` |
141
+ | `s` | `'1rem'` | `1` |
142
+ | `m` | `'1.5rem'` | `1.5` |
143
+ | `l` | `'2rem'` | `2` |
144
+ | `xl` | `'2.5rem'` | `2.5` |
145
+ | `xxl` | `'4rem'` | `4` |
146
+ | `xxxl` | `'5rem'` | `5` |
147
147
 
148
148
  The following space types are also provided: `CanvasSpace`, `CanvasSpaceValues`,
149
149
  `CanvasSpaceNumbers`, `CanvasSpaceNumberValues`
150
150
 
151
151
  Below are descriptions of these types:
152
152
 
153
- | Name | Description |
154
- | ------------------------- | -------------------------------------------- |
155
- | `CanvasSpace` | `space` object with string px values |
156
- | `CanvasSpaceValues` | string px values for CanvasSpace |
157
- | `CanvasSpaceNumbers` | `spaceNumbers` object with numeric px values |
158
- | `CanvasSpaceNumberValues` | numeric px values for CanvasSpaceNumbers |
153
+ | Name | Description |
154
+ | ------------------------- | --------------------------------------------- |
155
+ | `CanvasSpace` | `space` object with string rem values |
156
+ | `CanvasSpaceValues` | string rem values for CanvasSpace |
157
+ | `CanvasSpaceNumbers` | `spaceNumbers` object with numeric rem values |
158
+ | `CanvasSpaceNumberValues` | numeric rem values for CanvasSpaceNumbers |
159
159
 
160
160
  ### Usage
161
161
 
162
162
  ```tsx
163
163
  import {space, spaceNumbers} from '@workday/canvas-kit-react/tokens';
164
164
 
165
- const iconSize = 20;
165
+ const iconSize = 1.25;
166
166
 
167
167
  const buttonSyles = {
168
168
  paddingTop: space.xs,
169
169
  paddingRight: space.s,
170
170
  paddingBottom: space.xs,
171
- paddingLeft: spaceNumbers.s + iconSize,
171
+ paddingLeft: `${spaceNumbers.s + iconSize}rem`,
172
172
  };
173
173
  ```
174
174
 
package/tokens/index.ts CHANGED
@@ -21,8 +21,7 @@ import {
21
21
  CanvasSpaceValues,
22
22
  CanvasSpaceNumberValues,
23
23
  CanvasSpaceNumbers,
24
- spaceNumbers,
25
- } from './lib/space';
24
+ spaceNumbers} from './lib/space';
26
25
  import {type,
27
26
  fontFamily,
28
27
  monoFontFamily,
@@ -29,7 +29,7 @@ export type CanvasDepth = {
29
29
  * ```
30
30
  */
31
31
  1: {
32
- boxShadow: '0px 1px 4px rgba(31, 38, 46, 0.12), 0px 2px 8px rgba(31, 38, 46, 0.08)';
32
+ boxShadow: '0 0.0625rem 0.25rem rgba(31, 38, 46, 0.12), 0 0.125rem 0.5rem rgba(31, 38, 46, 0.08)';
33
33
  };
34
34
  /**
35
35
  * ### Depth 2
@@ -45,7 +45,7 @@ export type CanvasDepth = {
45
45
  * ```
46
46
  */
47
47
  2: {
48
- boxShadow: '0px 2px 8px rgba(31, 38, 46, 0.12), 0px 4px 16px rgba(31, 38, 46, 0.08)';
48
+ boxShadow: '0 0.125rem 0.5rem rgba(31, 38, 46, 0.12), 0 0.25rem 1rem rgba(31, 38, 46, 0.08)';
49
49
  };
50
50
  /**
51
51
  * ### Depth 3
@@ -61,7 +61,7 @@ export type CanvasDepth = {
61
61
  * ```
62
62
  */
63
63
  3: {
64
- boxShadow: '0px 3px 12px rgba(31, 38, 46, 0.12), 0px 6px 24px rgba(31, 38, 46, 0.08)';
64
+ boxShadow: '0 0.1875rem 0.75rem rgba(31, 38, 46, 0.12), 0 0.375rem 1.5rem rgba(31, 38, 46, 0.08)';
65
65
  };
66
66
  /**
67
67
  * ### Depth 4
@@ -76,7 +76,7 @@ export type CanvasDepth = {
76
76
  * ```
77
77
  */
78
78
  4: {
79
- boxShadow: '0px 4px 16px rgba(31, 38, 46, 0.12), 0px 8px 32px rgba(31, 38, 46, 0.08)';
79
+ boxShadow: '0 0.25rem 1rem rgba(31, 38, 46, 0.12), 0 0.5rem 2rem rgba(31, 38, 46, 0.08)';
80
80
  };
81
81
  /**
82
82
  * ### Depth 5
@@ -92,7 +92,7 @@ export type CanvasDepth = {
92
92
  * ```
93
93
  */
94
94
  5: {
95
- boxShadow: '0px 5px 20px rgba(31, 38, 46, 0.12), 0px 10px 40px rgba(31, 38, 46, 0.08)';
95
+ boxShadow: '0 0.3125rem 1.25rem rgba(31, 38, 46, 0.12), 0 0.625rem 2.5rem rgba(31, 38, 46, 0.08)';
96
96
  };
97
97
  /**
98
98
  * ### Depth 6
@@ -108,7 +108,7 @@ export type CanvasDepth = {
108
108
  * ```
109
109
  */
110
110
  6: {
111
- boxShadow: '0px 6px 24px rgba(31, 38, 46, 0.12), 0px 12px 48px rgba(31, 38, 46, 0.08)';
111
+ boxShadow: '0 0.375rem 1.5rem rgba(31, 38, 46, 0.12), 0 0.75rem 3rem rgba(31, 38, 46, 0.08)';
112
112
  };
113
113
  };
114
114
 
@@ -137,26 +137,30 @@ export type CanvasDepthValues = ValueOf<CanvasDepth>;
137
137
  * ```
138
138
  *
139
139
  */
140
+
140
141
  export const depth: CanvasDepth = {
141
142
  none: {
142
143
  boxShadow: 'none',
143
144
  },
144
145
  1: {
145
- boxShadow: '0px 1px 4px rgba(31, 38, 46, 0.12), 0px 2px 8px rgba(31, 38, 46, 0.08)',
146
+ boxShadow:
147
+ '0 0.0625rem 0.25rem rgba(31, 38, 46, 0.12), 0 0.125rem 0.5rem rgba(31, 38, 46, 0.08)',
146
148
  },
147
149
  2: {
148
- boxShadow: '0px 2px 8px rgba(31, 38, 46, 0.12), 0px 4px 16px rgba(31, 38, 46, 0.08)',
150
+ boxShadow: '0 0.125rem 0.5rem rgba(31, 38, 46, 0.12), 0 0.25rem 1rem rgba(31, 38, 46, 0.08)',
149
151
  },
150
152
  3: {
151
- boxShadow: '0px 3px 12px rgba(31, 38, 46, 0.12), 0px 6px 24px rgba(31, 38, 46, 0.08)',
153
+ boxShadow:
154
+ '0 0.1875rem 0.75rem rgba(31, 38, 46, 0.12), 0 0.375rem 1.5rem rgba(31, 38, 46, 0.08)',
152
155
  },
153
156
  4: {
154
- boxShadow: '0px 4px 16px rgba(31, 38, 46, 0.12), 0px 8px 32px rgba(31, 38, 46, 0.08)',
157
+ boxShadow: '0 0.25rem 1rem rgba(31, 38, 46, 0.12), 0 0.5rem 2rem rgba(31, 38, 46, 0.08)',
155
158
  },
156
159
  5: {
157
- boxShadow: '0px 5px 20px rgba(31, 38, 46, 0.12), 0px 10px 40px rgba(31, 38, 46, 0.08)',
160
+ boxShadow:
161
+ '0 0.3125rem 1.25rem rgba(31, 38, 46, 0.12), 0 0.625rem 2.5rem rgba(31, 38, 46, 0.08)',
158
162
  },
159
163
  6: {
160
- boxShadow: '0px 6px 24px rgba(31, 38, 46, 0.12), 0px 12px 48px rgba(31, 38, 46, 0.08)',
164
+ boxShadow: '0 0.375rem 1.5rem rgba(31, 38, 46, 0.12), 0 0.75rem 3rem rgba(31, 38, 46, 0.08)',
161
165
  },
162
166
  };
@@ -5,73 +5,111 @@ type ValueOf<T> = T[keyof T];
5
5
  // but writing it this way removes the `readonly` in the hint,
6
6
  // which adds a lot of visual noise and can be confusing for folks.
7
7
 
8
- /** Type for the `space` object with keys and px values (strings) */
8
+ /** Type for the `space` object with keys and rem values (strings) */
9
9
  export type CanvasSpace = {
10
- zero: '0px';
11
- xxxs: '4px';
12
- xxs: '8px';
13
- xs: '12px';
14
- s: '16px';
15
- m: '24px';
16
- l: '32px';
17
- xl: '40px';
18
- xxl: '64px';
19
- xxxl: '80px';
10
+ zero: '0';
11
+ xxxs: '0.25rem';
12
+ xxs: '0.5rem';
13
+ xs: '0.75rem';
14
+ s: '1rem';
15
+ m: '1.5rem';
16
+ l: '2rem';
17
+ xl: '2.5rem';
18
+ xxl: '4rem';
19
+ xxxl: '5rem';
20
20
  };
21
21
 
22
22
  /** Type for `CanvasSpace` keys */
23
23
  export type CanvasSpaceKeys = keyof CanvasSpace;
24
24
 
25
- /** The px values for CanvasSpace (strings) */
25
+ /** The rem values for CanvasSpace (strings) */
26
26
  export type CanvasSpaceValues = ValueOf<CanvasSpace>;
27
27
 
28
- /** An object of space keys and px values (strings) */
28
+ /**
29
+ * An object of space keys and rem values (strings)
30
+ *
31
+ * Below is a table to show the equivalent values from `px` to `rem`.
32
+ * This is based on the default browser font size which is `16px`.
33
+ *
34
+ * | px Value | rem Value | space token |
35
+ * | --------- | --------- | ----------- |
36
+ * | 0 | 0 | zero |
37
+ * | 4px | 0.25rem | xxxs |
38
+ * | 8px | 0.5rem | xxs |
39
+ * | 12px | 0.75rem | xs |
40
+ * | 16px | 1rem | s |
41
+ * | 24px | 1.5rem | m |
42
+ * | 32px | 2rem | l |
43
+ * | 40px | 2.5rem | xl |
44
+ * | 64px | 4rem | xxl |
45
+ * | 80px | 5rem | xxxl |
46
+ *
47
+ * */
29
48
  export const space: CanvasSpace = {
30
- zero: '0px',
31
- xxxs: '4px',
32
- xxs: '8px',
33
- xs: '12px',
34
- s: '16px',
35
- m: '24px',
36
- l: '32px',
37
- xl: '40px',
38
- xxl: '64px',
39
- xxxl: '80px',
49
+ zero: '0',
50
+ xxxs: '0.25rem',
51
+ xxs: '0.5rem',
52
+ xs: '0.75rem',
53
+ s: '1rem',
54
+ m: '1.5rem',
55
+ l: '2rem',
56
+ xl: '2.5rem',
57
+ xxl: '4rem',
58
+ xxxl: '5rem',
40
59
  };
41
60
 
42
- /** Type for the `spaceNumbers` object with keys and numeric px values (numbers) */
61
+ /** Type for the `spaceNumbers` object with keys and numeric rem values (numbers) */
43
62
  export type CanvasSpaceNumbers = {
44
63
  zero: 0;
45
- xxxs: 4;
46
- xxs: 8;
47
- xs: 12;
48
- s: 16;
49
- m: 24;
50
- l: 32;
51
- xl: 40;
52
- xxl: 64;
53
- xxxl: 80;
64
+ xxxs: 0.25;
65
+ xxs: 0.5;
66
+ xs: 0.75;
67
+ s: 1;
68
+ m: 1.5;
69
+ l: 2;
70
+ xl: 2.5;
71
+ xxl: 4;
72
+ xxxl: 5;
54
73
  };
55
74
 
56
- /** The numeric px values for CanvasSpaceNumbers (numbers) */
75
+ /** The numeric rem values for CanvasSpaceNumbers (numbers) */
57
76
  export type CanvasSpaceNumberValues = ValueOf<CanvasSpaceNumbers>;
58
77
 
59
78
  /**
60
- * An object of space keys and their numeric px values (numbers)
61
- * - These are helpful when you need a raw numeric px value.
79
+ * An object of space keys and their numeric rem values (numbers)
80
+ * - These are helpful when you need a raw numeric rem value.
62
81
  * - Here's an example usage to perform calculations:
63
82
  * @example
64
- * const buttonPaddingLeft = spaceNumbers.s + iconSize;
83
+ * ```tsx
84
+ * const buttonPaddingLeft = `${spaceNumbers.s + iconSize}rem`;
85
+ * ```
86
+ *
87
+ * Below is a table to show the equivalent values from `px` to `rem`.
88
+ * This is based on the default browser font size which is `16px`.
89
+ *
90
+ * | px Value | rem Value | space token |
91
+ * | --------- | --------- | ----------- |
92
+ * | 0 | 0 | zero |
93
+ * | 4px | 0.25rem | xxxs |
94
+ * | 8px | 0.5rem | xxs |
95
+ * | 12px | 0.75rem | xs |
96
+ * | 16px | 1rem | s |
97
+ * | 24px | 1.5rem | m |
98
+ * | 32px | 2rem | l |
99
+ * | 40px | 2.5rem | xl |
100
+ * | 64px | 4rem | xxl |
101
+ * | 80px | 5rem | xxxl |
102
+ *
65
103
  */
66
104
  export const spaceNumbers: CanvasSpaceNumbers = {
67
105
  zero: 0,
68
- xxxs: 4,
69
- xxs: 8,
70
- xs: 12,
71
- s: 16,
72
- m: 24,
73
- l: 32,
74
- xl: 40,
75
- xxl: 64,
76
- xxxl: 80,
106
+ xxxs: 0.25,
107
+ xxs: 0.5,
108
+ xs: 0.75,
109
+ s: 1,
110
+ m: 1.5,
111
+ l: 2,
112
+ xl: 2.5,
113
+ xxl: 4,
114
+ xxxl: 5,
77
115
  };
@@ -50,7 +50,7 @@ export const TooltipContainer = styled('div')<TooltipContainerProps>(
50
50
  ...type.levels.subtext.medium,
51
51
  display: 'inline-flex',
52
52
  position: 'relative',
53
- padding: spaceNumbers.xxs + spaceNumbers.xxxs,
53
+ padding: space.xs,
54
54
  color: colors.frenchVanilla100,
55
55
  a: {
56
56
  color: colors.frenchVanilla100,
@@ -61,7 +61,7 @@ export const TooltipContainer = styled('div')<TooltipContainerProps>(
61
61
  content: '""',
62
62
  borderRadius: borderRadius.m,
63
63
  zIndex: -1,
64
- margin: spaceNumbers.xxxs,
64
+ margin: space.xxxs,
65
65
  backgroundColor: 'rgba(0,0,0,.85)',
66
66
  position: 'absolute',
67
67
  top: 0,
@@ -72,9 +72,9 @@ export const TooltipContainer = styled('div')<TooltipContainerProps>(
72
72
 
73
73
  // offset tooltips by 2 pixels when a keyboard focus ring is detected
74
74
  '[data-whatinput=keyboard] &': {
75
- padding: spaceNumbers.xxs + spaceNumbers.xxxs + 2,
75
+ padding: `${spaceNumbers.s - 0.125}rem`,
76
76
  ':before': {
77
- margin: spaceNumbers.xxxs + 2,
77
+ margin: `${spaceNumbers.xxxs + 0.125}rem`,
78
78
  },
79
79
  },
80
80
 
@@ -86,16 +86,16 @@ export const TooltipContainer = styled('div')<TooltipContainerProps>(
86
86
 
87
87
  // Fix offsets based on placement
88
88
  '[data-popper-placement="top-start"] &, [data-popper-placement="bottom-start"] &': {
89
- left: -spaceNumbers.xxxs,
89
+ left: `-${space.xxxs}`,
90
90
  },
91
91
  '[data-popper-placement="top-end"] &, [data-popper-placement="bottom-end"] &': {
92
- right: -spaceNumbers.xxxs,
92
+ right: `-${space.xxxs}`,
93
93
  },
94
94
  '[data-popper-placement="left-start"] &, [data-popper-placement="right-start"] &': {
95
- top: -spaceNumbers.xxxs,
95
+ top: `-${space.xxxs}`,
96
96
  },
97
97
  '[data-popper-placement="left-end"] &, [data-popper-placement="right-end"] &': {
98
- bottom: -spaceNumbers.xxxs,
98
+ bottom: `-${space.xxxs}`,
99
99
  },
100
100
  },
101
101
  ({transformOrigin = defaultTransformOrigin}) => {