@workday/canvas-kit-react 10.0.0-alpha.446-next.0 → 10.0.0-alpha.447-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 (56) 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/radio/lib/Radio.d.ts.map +1 -1
  9. package/dist/commonjs/radio/lib/Radio.js +13 -13
  10. package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
  11. package/dist/commonjs/select/lib/Select.js +1 -1
  12. package/dist/commonjs/table/lib/TableRow.js +1 -1
  13. package/dist/commonjs/text-area/lib/TextArea.d.ts.map +1 -1
  14. package/dist/commonjs/text-area/lib/TextArea.js +3 -3
  15. package/dist/commonjs/text-input/lib/TextInput.js +1 -1
  16. package/dist/commonjs/tokens/index.d.ts.map +1 -1
  17. package/dist/commonjs/tokens/lib/depth.d.ts +6 -6
  18. package/dist/commonjs/tokens/lib/depth.d.ts.map +1 -1
  19. package/dist/commonjs/tokens/lib/depth.js +6 -6
  20. package/dist/commonjs/tokens/lib/space.d.ts +65 -27
  21. package/dist/commonjs/tokens/lib/space.d.ts.map +1 -1
  22. package/dist/commonjs/tokens/lib/space.js +61 -23
  23. package/dist/commonjs/tooltip/lib/TooltipContainer.js +8 -8
  24. package/dist/es6/button/lib/BaseButton.d.ts +1 -1
  25. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  26. package/dist/es6/button/lib/BaseButton.js +4 -4
  27. package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
  28. package/dist/es6/checkbox/lib/Checkbox.js +12 -12
  29. package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
  30. package/dist/es6/radio/lib/Radio.js +14 -14
  31. package/dist/es6/select/lib/Select.d.ts.map +1 -1
  32. package/dist/es6/select/lib/Select.js +2 -2
  33. package/dist/es6/table/lib/TableRow.js +1 -1
  34. package/dist/es6/text-area/lib/TextArea.d.ts.map +1 -1
  35. package/dist/es6/text-area/lib/TextArea.js +4 -4
  36. package/dist/es6/text-input/lib/TextInput.js +1 -1
  37. package/dist/es6/tokens/index.d.ts.map +1 -1
  38. package/dist/es6/tokens/index.js +1 -1
  39. package/dist/es6/tokens/lib/depth.d.ts +6 -6
  40. package/dist/es6/tokens/lib/depth.d.ts.map +1 -1
  41. package/dist/es6/tokens/lib/depth.js +6 -6
  42. package/dist/es6/tokens/lib/space.d.ts +65 -27
  43. package/dist/es6/tokens/lib/space.d.ts.map +1 -1
  44. package/dist/es6/tokens/lib/space.js +61 -23
  45. package/dist/es6/tooltip/lib/TooltipContainer.js +8 -8
  46. package/package.json +3 -3
  47. package/radio/lib/Radio.tsx +20 -14
  48. package/select/lib/Select.tsx +2 -9
  49. package/table/lib/TableRow.tsx +1 -1
  50. package/text-area/lib/TextArea.tsx +10 -4
  51. package/text-input/lib/TextInput.tsx +1 -1
  52. package/tokens/README.md +19 -19
  53. package/tokens/index.ts +1 -2
  54. package/tokens/lib/depth.ts +16 -12
  55. package/tokens/lib/space.ts +84 -46
  56. package/tooltip/lib/TooltipContainer.tsx +8 -8
@@ -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}) => {