@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
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import {colors, commonColors, space} from '@workday/canvas-kit-react/tokens';
2
+ import {styled} from '@workday/canvas-kit-react/common';
3
+ import {colors, commonColors, space, CSSProperties} from '@workday/canvas-kit-react/tokens';
4
4
 
5
5
  export interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
6
6
  /**
@@ -10,45 +10,58 @@ export interface ActionBarProps extends React.HTMLAttributes<HTMLDivElement> {
10
10
  fixed?: boolean;
11
11
  }
12
12
 
13
- const ActionBarContainer = styled('div')(
13
+ function getFixedStyles(fixed = false): CSSProperties {
14
+ return fixed
15
+ ? {
16
+ position: 'fixed',
17
+ left: 0,
18
+ bottom: 0,
19
+ right: 0,
20
+ }
21
+ : {};
22
+ }
23
+
24
+ const ActionBarContainer = styled('div')<ActionBarProps>(
14
25
  {
15
26
  borderTop: `solid 1px ${colors.soap400}`,
16
27
  background: commonColors.background,
17
28
  padding: space.s,
18
29
  boxShadow: '0 -2px 4px rgba(0, 0, 0, 0.08)',
19
- '@media (max-width: 575px)': {
20
- padding: space.xxs,
21
- },
22
30
  },
23
- ({fixed}: ActionBarProps) =>
24
- fixed && {
25
- position: 'fixed',
26
- left: 0,
27
- bottom: 0,
28
- right: 0,
29
- }
31
+ ({fixed, theme}) => {
32
+ return {
33
+ ...getFixedStyles(fixed),
34
+ [theme.canvas.breakpoints.down('s')]: {
35
+ padding: space.xxs,
36
+ },
37
+ };
38
+ }
30
39
  );
31
40
 
32
- const ChildrenContainer = styled('div')({
33
- display: 'inline-block',
34
- padding: `0 ${space.m}`,
35
- '*:not(:first-of-type)': {
36
- marginLeft: space.s,
41
+ const ChildrenContainer = styled('div')(
42
+ {
43
+ display: 'inline-block',
44
+ padding: `0 ${space.m}`,
45
+ '*:not(:first-of-type)': {
46
+ marginLeft: space.s,
47
+ },
37
48
  },
38
- '@media (max-width: 575px)': {
39
- display: 'flex',
40
- padding: space.xxs,
41
- justifyContent: 'center',
42
- flexDirection: 'row-reverse',
43
- '> *': {
44
- flex: 1,
45
- '&:not(:first-of-type)': {
46
- marginRight: space.s,
47
- marginLeft: 0,
49
+ ({theme}) => ({
50
+ [theme.canvas.breakpoints.down('s')]: {
51
+ display: 'flex',
52
+ padding: space.xxs,
53
+ justifyContent: 'center',
54
+ flexDirection: 'row-reverse',
55
+ '> *': {
56
+ flex: 1,
57
+ '&:not(:first-of-type)': {
58
+ marginRight: space.s,
59
+ marginLeft: 0,
60
+ },
48
61
  },
49
62
  },
50
- },
51
- });
63
+ })
64
+ );
52
65
 
53
66
  export default class ActionBar extends React.Component<ActionBarProps> {
54
67
  public render() {
@@ -6,17 +6,27 @@ import {
6
6
  Themeable,
7
7
  EmotionCanvasTheme,
8
8
  createComponent,
9
+ focusRing,
9
10
  } from '@workday/canvas-kit-react/common';
11
+ import {colors} from '@workday/canvas-kit-react/tokens';
10
12
  import {CanvasSystemIcon} from '@workday/design-assets-types';
11
- import {ButtonColors} from './types';
13
+
12
14
  import {ButtonContainer, ButtonLabel, ButtonLabelData, ButtonLabelIcon} from './parts';
15
+ import {ButtonSizes, IconPositions} from './types';
13
16
 
14
17
  export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
15
18
  /**
16
- * The size of the Button.
19
+ * The variant of the PrimaryButton.
20
+ * @default undefined
21
+ */
22
+ variant?: 'inverse';
23
+ /**
24
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
25
+ * If no size is provided, it will default to `medium`.
26
+ *
17
27
  * @default 'medium'
18
28
  */
19
- size?: 'small' | 'medium' | 'large';
29
+ size?: ButtonSizes;
20
30
  /**
21
31
  * The data label of the Button.
22
32
  * Note: not displayed at `small` size
@@ -28,10 +38,11 @@ export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
28
38
  */
29
39
  icon?: CanvasSystemIcon;
30
40
  /**
31
- * The position of the TertiaryButton icon.
41
+ * Button icon positions can either be `left` or `right`.
42
+ * If no value is provided, it defaults to `left`.
32
43
  * @default 'left'
33
44
  */
34
- iconPosition?: 'left' | 'right';
45
+ iconPosition?: IconPositions;
35
46
  /**
36
47
  * If set to `true`, transform the icon's x-axis to mirror the graphic
37
48
  * @default false
@@ -40,6 +51,16 @@ export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
40
51
  children?: React.ReactNode;
41
52
  }
42
53
 
54
+ // Button sizes where data labels are enabled
55
+ const dataLabelSizes = ['medium', 'large'];
56
+ // All disabled buttons are set to 40% opacity.
57
+ // This will eventually live in the ButtonContainer styles, but for now we're scoping it to Primary, Secondary, and Tertiary buttons.
58
+ const disabledButtonOpacity = {
59
+ '&:disabled, &:disabled:active': {
60
+ opacity: 0.4,
61
+ },
62
+ };
63
+
43
64
  export const PrimaryButton = createComponent('button')({
44
65
  displayName: 'PrimaryButton',
45
66
  Component: (
@@ -49,6 +70,7 @@ export const PrimaryButton = createComponent('button')({
49
70
  theme = useTheme(),
50
71
  size = 'medium',
51
72
  iconPosition = 'left',
73
+ variant,
52
74
  dataLabel,
53
75
  icon,
54
76
  shouldMirrorIcon = false,
@@ -61,11 +83,12 @@ export const PrimaryButton = createComponent('button')({
61
83
  <ButtonContainer
62
84
  ref={ref}
63
85
  as={Element}
64
- colors={getPrimaryButtonColors(theme)}
86
+ colors={getPrimaryButtonColors(variant, theme)}
65
87
  size={size}
88
+ extraStyles={disabledButtonOpacity}
66
89
  {...elemProps}
67
90
  >
68
- {icon && size !== 'small' && iconPosition === 'left' && (
91
+ {icon && iconPosition === 'left' && (
69
92
  <ButtonLabelIcon
70
93
  size={size}
71
94
  iconPosition={iconPosition}
@@ -74,8 +97,8 @@ export const PrimaryButton = createComponent('button')({
74
97
  />
75
98
  )}
76
99
  <ButtonLabel>{children}</ButtonLabel>
77
- {dataLabel && size !== 'small' && <ButtonLabelData>{dataLabel}</ButtonLabelData>}
78
- {icon && size !== 'small' && iconPosition === 'right' && (
100
+ {dataLabel && dataLabelSizes.includes(size) && <ButtonLabelData>{dataLabel}</ButtonLabelData>}
101
+ {icon && iconPosition === 'right' && (
79
102
  <ButtonLabelIcon
80
103
  size={size}
81
104
  iconPosition={iconPosition}
@@ -87,26 +110,81 @@ export const PrimaryButton = createComponent('button')({
87
110
  ),
88
111
  });
89
112
 
90
- export const getPrimaryButtonColors = ({
91
- canvas: {
92
- palette: {primary: themePrimary},
93
- },
94
- }: EmotionCanvasTheme): ButtonColors => ({
95
- default: {
96
- background: themePrimary.main,
97
- icon: themePrimary.contrast,
98
- label: themePrimary.contrast,
99
- },
100
- hover: {
101
- background: themePrimary.dark,
102
- },
103
- active: {
104
- background: themePrimary.darkest,
105
- },
106
- focus: {
107
- background: themePrimary.main,
108
- },
109
- disabled: {
110
- background: themePrimary.light,
111
- },
112
- });
113
+ export const getPrimaryButtonColors = (
114
+ variant: 'inverse' | undefined,
115
+ theme: EmotionCanvasTheme
116
+ ) => {
117
+ const {
118
+ canvas: {
119
+ palette: {primary: themePrimary},
120
+ },
121
+ } = theme;
122
+
123
+ switch (variant) {
124
+ case undefined:
125
+ default:
126
+ return {
127
+ default: {
128
+ background: themePrimary.main,
129
+ icon: themePrimary.contrast,
130
+ label: themePrimary.contrast,
131
+ },
132
+ hover: {
133
+ background: themePrimary.dark,
134
+ },
135
+ active: {
136
+ background: themePrimary.darkest,
137
+ },
138
+ focus: {
139
+ background: themePrimary.main,
140
+ },
141
+ disabled: {
142
+ background: themePrimary.main,
143
+ },
144
+ };
145
+
146
+ case 'inverse':
147
+ return {
148
+ default: {
149
+ background: colors.frenchVanilla100,
150
+ icon: colors.blackPepper400,
151
+ label: colors.blackPepper400,
152
+ labelData: colors.blackPepper400,
153
+ },
154
+ hover: {
155
+ background: colors.soap300,
156
+ icon: colors.blackPepper500,
157
+ label: colors.blackPepper500,
158
+ labelData: colors.blackPepper500,
159
+ },
160
+ active: {
161
+ background: colors.soap300,
162
+ icon: colors.blackPepper500,
163
+ label: colors.blackPepper500,
164
+ labelData: colors.blackPepper500,
165
+ },
166
+ focus: {
167
+ background: colors.frenchVanilla100,
168
+ border: colors.blackPepper400,
169
+ icon: colors.blackPepper400,
170
+ label: colors.blackPepper400,
171
+ labelData: colors.blackPepper400,
172
+ focusRing: focusRing(
173
+ {
174
+ separation: 1,
175
+ innerColor: colors.blackPepper500,
176
+ outerColor: colors.frenchVanilla100,
177
+ },
178
+ theme
179
+ ),
180
+ },
181
+ // Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
182
+ disabled: {
183
+ background: colors.frenchVanilla100,
184
+ icon: colors.blackPepper400,
185
+ label: colors.blackPepper400,
186
+ labelData: colors.blackPepper400,
187
+ },
188
+ };
189
+ }
190
+ };
@@ -10,7 +10,7 @@ import {
10
10
  focusRing,
11
11
  } from '@workday/canvas-kit-react/common';
12
12
  import {CanvasSystemIcon} from '@workday/design-assets-types';
13
- import {ButtonColors} from './types';
13
+ import {ButtonColors, ButtonSizes, IconPositions} from './types';
14
14
  import {ButtonContainer, ButtonLabel, ButtonLabelData, ButtonLabelIcon} from './parts';
15
15
 
16
16
  export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
@@ -20,10 +20,12 @@ export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
20
20
  */
21
21
  variant?: 'inverse' | undefined;
22
22
  /**
23
- * The size of the Button.
23
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
24
+ * If no size is provided, it will default to `medium`.
25
+ *
24
26
  * @default 'medium'
25
27
  */
26
- size?: 'small' | 'medium' | 'large';
28
+ size?: ButtonSizes;
27
29
  /**
28
30
  * The data label of the Button.
29
31
  * Note: not displayed at `small` size
@@ -35,10 +37,11 @@ export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
35
37
  */
36
38
  icon?: CanvasSystemIcon;
37
39
  /**
38
- * The position of the TertiaryButton icon.
40
+ * Button icon positions can either be `left` or `right`.
41
+ * If no value is provided, it defaults to `left`.
39
42
  * @default 'left'
40
43
  */
41
- iconPosition?: 'left' | 'right';
44
+ iconPosition?: IconPositions;
42
45
  /**
43
46
  * If set to `true`, transform the icon's x-axis to mirror the graphic
44
47
  * @default false
@@ -47,6 +50,16 @@ export interface SecondaryButtonProps extends Themeable, GrowthBehavior {
47
50
  children?: React.ReactNode;
48
51
  }
49
52
 
53
+ // Button sizes where data labels are enabled
54
+ const dataLabelSizes = ['medium', 'large'];
55
+ // All disabled buttons are set to 40% opacity.
56
+ // This will eventually live in the ButtonContainer styles, but for now we're scoping it to Primary, Secondary, and Tertiary buttons.
57
+ const disabledButtonOpacity = {
58
+ '&:disabled, &:disabled:active': {
59
+ opacity: 0.4,
60
+ },
61
+ };
62
+
50
63
  export const SecondaryButton = createComponent('button')({
51
64
  displayName: 'SecondaryButton',
52
65
  Component: (
@@ -71,9 +84,10 @@ export const SecondaryButton = createComponent('button')({
71
84
  as={Element}
72
85
  colors={getSecondaryButtonColors(variant, theme)}
73
86
  size={size}
87
+ extraStyles={disabledButtonOpacity}
74
88
  {...elemProps}
75
89
  >
76
- {icon && size !== 'small' && iconPosition === 'left' && (
90
+ {icon && iconPosition === 'left' && (
77
91
  <ButtonLabelIcon
78
92
  size={size}
79
93
  iconPosition={iconPosition}
@@ -82,8 +96,8 @@ export const SecondaryButton = createComponent('button')({
82
96
  />
83
97
  )}
84
98
  <ButtonLabel>{children}</ButtonLabel>
85
- {dataLabel && size !== 'small' && <ButtonLabelData>{dataLabel}</ButtonLabelData>}
86
- {icon && size !== 'small' && iconPosition === 'right' && (
99
+ {dataLabel && dataLabelSizes.includes(size) && <ButtonLabelData>{dataLabel}</ButtonLabelData>}
100
+ {icon && iconPosition === 'right' && (
87
101
  <ButtonLabelIcon
88
102
  size={size}
89
103
  iconPosition={iconPosition}
@@ -136,12 +150,13 @@ export const getSecondaryButtonColors = (
136
150
  label: colors.blackPepper400,
137
151
  labelData: colors.blackPepper400,
138
152
  },
153
+ // Identical to 'default' styles. ButtonContainer will set opacity to 40%
139
154
  disabled: {
140
155
  background: 'transparent',
141
- border: 'rgba(30, 30, 30, 0.4)', // Black Pepper 400 @ 40%
142
- icon: 'rgba(30, 30, 30, 0.4)', // Black Pepper 400 @ 40%
143
- label: 'rgba(30, 30, 30, 0.4)', // Black Pepper 400 @ 40%
144
- labelData: 'rgba(30, 30, 30, 0.4)', // Black Pepper 400 @ 40%
156
+ border: colors.blackPepper400,
157
+ icon: colors.blackPepper400,
158
+ label: colors.blackPepper400,
159
+ labelData: colors.blackPepper400,
145
160
  },
146
161
  };
147
162
  case 'inverse':
@@ -180,12 +195,12 @@ export const getSecondaryButtonColors = (
180
195
  theme
181
196
  ),
182
197
  },
198
+ // Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
183
199
  disabled: {
184
200
  background: 'transparent',
185
- border: 'rgba(255, 255, 255, 0.4)', // French Vanilla 400 @ 40%
186
- icon: 'rgba(255, 255, 255, 0.4)', // French Vanilla 400 @ 40%
187
- label: 'rgba(255, 255, 255, 0.4)', // French Vanilla 400 @ 40%
188
- labelData: 'rgba(255, 255, 255, 0.4)', // French Vanilla 400 @ 40%
201
+ border: colors.frenchVanilla100,
202
+ icon: colors.frenchVanilla100,
203
+ label: colors.frenchVanilla100,
189
204
  },
190
205
  };
191
206
  }
@@ -10,7 +10,7 @@ import {
10
10
  EmotionCanvasTheme,
11
11
  StyledType,
12
12
  } from '@workday/canvas-kit-react/common';
13
- import {ButtonColors} from '../types';
13
+ import {ButtonColors, ButtonSizes} from '../types';
14
14
  import {buttonLabelDataClassName} from './ButtonLabelData';
15
15
 
16
16
  export interface ButtonContainerProps
@@ -18,10 +18,12 @@ export interface ButtonContainerProps
18
18
  GrowthBehavior {
19
19
  colors?: ButtonColors;
20
20
  /**
21
- * The size of the Button.
21
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
22
+ * If no size is provided, it will default to `medium`.
23
+ *
22
24
  * @default 'medium'
23
25
  */
24
- size?: 'small' | 'medium' | 'large';
26
+ size?: ButtonSizes;
25
27
  /**
26
28
  * The ref to the button that the styled component renders.
27
29
  */
@@ -110,12 +112,13 @@ export const ButtonContainer = styled('button', {
110
112
  switch (size) {
111
113
  case 'large':
112
114
  return {
113
- fontSize: type.properties.fontSizes[16],
115
+ ...type.levels.body.small,
116
+ fontWeight: type.properties.fontWeights.bold,
114
117
  minWidth: '112px',
115
118
  height: '48px',
116
119
  padding: `0 ${space.l}`,
117
120
  '& > * ': {
118
- margin: `0 ${spaceNumbers.xs / 2}px`,
121
+ margin: `0 ${spaceNumbers.xxs / 2}px`,
119
122
  },
120
123
  };
121
124
  case 'medium':
@@ -137,6 +140,14 @@ export const ButtonContainer = styled('button', {
137
140
  margin: `0 ${spaceNumbers.xxxs / 2}px`,
138
141
  },
139
142
  };
143
+ case 'extraSmall':
144
+ return {
145
+ height: space.m,
146
+ padding: `0 ${space.xs}`,
147
+ '& > * ': {
148
+ margin: `0 ${spaceNumbers.xxxs / 2}px`,
149
+ },
150
+ };
140
151
  }
141
152
  },
142
153
  ({grow}) => grow && {width: '100%', maxWidth: '100%'},
@@ -5,22 +5,25 @@ import isPropValid from '@emotion/is-prop-valid';
5
5
  import {SystemIcon} from '@workday/canvas-kit-react/icon';
6
6
  import {styled} from '@workday/canvas-kit-react/common';
7
7
 
8
+ import {ButtonSizes, IconPositions} from '../types';
8
9
  export interface ButtonLabelIconProps {
9
10
  /**
10
- * The size of the Button.
11
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
12
+ *
11
13
  * @default 'medium'
12
14
  */
13
- size?: 'small' | 'medium' | 'large';
15
+ size?: ButtonSizes;
14
16
  /**
15
17
  * The icon of the Button.
16
18
  * Note: not displayed at `small` size
17
19
  */
18
20
  icon?: CanvasSystemIcon;
19
21
  /**
20
- * The position of the TertiaryButton icon.
22
+ * Button icon positions can either be `left` or `right`.
23
+ * If no value is provided, it defaults to `left`.
21
24
  * @default 'left'
22
25
  */
23
- iconPosition?: 'left' | 'right';
26
+ iconPosition?: IconPositions;
24
27
  /**
25
28
  * If set to `true`, transform the icon's x-axis to mirror the graphic
26
29
  * @default false
@@ -28,8 +31,29 @@ export interface ButtonLabelIconProps {
28
31
  shouldMirrorIcon?: boolean;
29
32
  }
30
33
 
31
- const ICON_SIZE = 24;
32
- const SMALL_ICON_SIZE = 20;
34
+ const iconSizes: Record<ButtonSizes, number> = {
35
+ extraSmall: 18,
36
+ small: 20,
37
+ medium: 20,
38
+ large: 24,
39
+ };
40
+
41
+ const getIconPositionStyles = ({iconPosition, size}: ButtonLabelIconProps) => {
42
+ // Adjust margin values for visual balance, large buttons require 8px
43
+ const balancingMargin = size === 'large' ? space.xxs : space.xxxs;
44
+ // iconPosition can only be "right", "left", or undefined (defaults to "left")
45
+ if (iconPosition === 'right') {
46
+ return {
47
+ marginLeft: undefined,
48
+ marginRight: `-${balancingMargin} !important`,
49
+ };
50
+ } else {
51
+ return {
52
+ marginLeft: `-${balancingMargin} !important`,
53
+ marginRight: undefined,
54
+ };
55
+ }
56
+ };
33
57
 
34
58
  const ButtonLabelIconStyled = styled('span', {
35
59
  shouldForwardProp: prop => isPropValid(prop) && prop !== 'size',
@@ -38,13 +62,10 @@ const ButtonLabelIconStyled = styled('span', {
38
62
  display: 'inline-block',
39
63
  },
40
64
  ({size}) => ({
41
- width: size === 'small' ? SMALL_ICON_SIZE : ICON_SIZE,
42
- height: size === 'small' ? SMALL_ICON_SIZE : ICON_SIZE,
65
+ width: size ? iconSizes[size] : iconSizes.medium,
66
+ height: size ? iconSizes[size] : iconSizes.medium,
43
67
  }),
44
- ({iconPosition}) => ({
45
- marginLeft: iconPosition === 'right' ? undefined : `-${space.xxxs} !important`,
46
- marginRight: iconPosition === 'right' ? `-${space.xxxs} !important` : undefined,
47
- })
68
+ getIconPositionStyles
48
69
  );
49
70
 
50
71
  export const ButtonLabelIcon = ({
@@ -54,12 +75,11 @@ export const ButtonLabelIcon = ({
54
75
  shouldMirrorIcon = false,
55
76
  ...elemProps
56
77
  }: ButtonLabelIconProps) => {
57
- /* istanbul ignore next line for coverage */
58
78
  if (icon === undefined) {
59
79
  return null;
60
80
  }
61
81
 
62
- const iconSize = size === 'small' ? SMALL_ICON_SIZE : undefined;
82
+ const iconSize = size ? iconSizes[size] : undefined;
63
83
 
64
84
  return (
65
85
  <ButtonLabelIconStyled iconPosition={iconPosition} size={size} {...elemProps}>
@@ -20,3 +20,13 @@ export interface ButtonColors {
20
20
  };
21
21
  disabled: ButtonStateColors;
22
22
  }
23
+
24
+ /**
25
+ * There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
26
+ * If no size is provided, it will default to `medium`.
27
+ *
28
+ * @default 'medium'
29
+ */
30
+ export type ButtonSizes = 'extraSmall' | 'small' | 'medium' | 'large';
31
+
32
+ export type IconPositions = 'left' | 'right';