@workday/canvas-kit-react 6.0.0-alpha.0-next.27 → 6.0.0-alpha.0-next.28
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.
- package/button/lib/PrimaryButton.tsx +110 -32
- package/button/lib/parts/ButtonContainer.tsx +16 -5
- package/button/lib/parts/ButtonLabelIcon.tsx +34 -14
- package/button/lib/types.ts +10 -0
- package/dist/commonjs/button/lib/PrimaryButton.d.ts +80 -6
- package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +80 -26
- package/dist/commonjs/button/lib/parts/ButtonContainer.d.ts +5 -3
- package/dist/commonjs/button/lib/parts/ButtonContainer.d.ts.map +1 -1
- package/dist/commonjs/button/lib/parts/ButtonContainer.js +11 -9
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.js +28 -13
- package/dist/commonjs/button/lib/types.d.ts +8 -0
- package/dist/commonjs/button/lib/types.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.d.ts +80 -6
- package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +81 -27
- package/dist/es6/button/lib/parts/ButtonContainer.d.ts +5 -3
- package/dist/es6/button/lib/parts/ButtonContainer.d.ts.map +1 -1
- package/dist/es6/button/lib/parts/ButtonContainer.js +11 -9
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/es6/button/lib/parts/ButtonLabelIcon.js +28 -13
- package/dist/es6/button/lib/types.d.ts +8 -0
- package/dist/es6/button/lib/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/ts3.5/dist/commonjs/button/lib/PrimaryButton.d.ts +80 -6
- package/ts3.5/dist/commonjs/button/lib/parts/ButtonContainer.d.ts +5 -3
- package/ts3.5/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
- package/ts3.5/dist/commonjs/button/lib/types.d.ts +8 -0
- package/ts3.5/dist/es6/button/lib/PrimaryButton.d.ts +80 -6
- package/ts3.5/dist/es6/button/lib/parts/ButtonContainer.d.ts +5 -3
- package/ts3.5/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +7 -4
- package/ts3.5/dist/es6/button/lib/types.d.ts +8 -0
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
2
|
+
import { ButtonSizes, IconPositions } from '../types';
|
|
2
3
|
export interface ButtonLabelIconProps {
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
6
|
+
*
|
|
5
7
|
* @default 'medium'
|
|
6
8
|
*/
|
|
7
|
-
size?:
|
|
9
|
+
size?: ButtonSizes;
|
|
8
10
|
/**
|
|
9
11
|
* The icon of the Button.
|
|
10
12
|
* Note: not displayed at `small` size
|
|
11
13
|
*/
|
|
12
14
|
icon?: CanvasSystemIcon;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Button icon positions can either be `left` or `right`.
|
|
17
|
+
* If no value is provided, it defaults to `left`.
|
|
15
18
|
* @default 'left'
|
|
16
19
|
*/
|
|
17
|
-
iconPosition?:
|
|
20
|
+
iconPosition?: IconPositions;
|
|
18
21
|
/**
|
|
19
22
|
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
20
23
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonLabelIcon.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonLabelIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,MAAM,WAAW,oBAAoB;IACnC
|
|
1
|
+
{"version":3,"file":"ButtonLabelIcon.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonLabelIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACpD,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,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;CAC5B;AAuCD,eAAO,MAAM,eAAe,4GAkB3B,CAAC"}
|
|
@@ -37,8 +37,30 @@ var tokens_1 = require("@workday/canvas-kit-react/tokens");
|
|
|
37
37
|
var is_prop_valid_1 = __importDefault(require("@emotion/is-prop-valid"));
|
|
38
38
|
var icon_1 = require("@workday/canvas-kit-react/icon");
|
|
39
39
|
var common_1 = require("@workday/canvas-kit-react/common");
|
|
40
|
-
var
|
|
41
|
-
|
|
40
|
+
var iconSizes = {
|
|
41
|
+
extraSmall: 18,
|
|
42
|
+
small: 20,
|
|
43
|
+
medium: 20,
|
|
44
|
+
large: 24,
|
|
45
|
+
};
|
|
46
|
+
var getIconPositionStyles = function (_a) {
|
|
47
|
+
var iconPosition = _a.iconPosition, size = _a.size;
|
|
48
|
+
// Adjust margin values for visual balance, large buttons require 8px
|
|
49
|
+
var balancingMargin = size === 'large' ? tokens_1.space.xxs : tokens_1.space.xxxs;
|
|
50
|
+
// iconPosition can only be "right", "left", or undefined (defaults to "left")
|
|
51
|
+
if (iconPosition === 'right') {
|
|
52
|
+
return {
|
|
53
|
+
marginLeft: undefined,
|
|
54
|
+
marginRight: "-" + balancingMargin + " !important",
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return {
|
|
59
|
+
marginLeft: "-" + balancingMargin + " !important",
|
|
60
|
+
marginRight: undefined,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
42
64
|
var ButtonLabelIconStyled = common_1.styled('span', {
|
|
43
65
|
shouldForwardProp: function (prop) { return is_prop_valid_1.default(prop) && prop !== 'size'; },
|
|
44
66
|
})({
|
|
@@ -46,23 +68,16 @@ var ButtonLabelIconStyled = common_1.styled('span', {
|
|
|
46
68
|
}, function (_a) {
|
|
47
69
|
var size = _a.size;
|
|
48
70
|
return ({
|
|
49
|
-
width: size
|
|
50
|
-
height: size
|
|
51
|
-
});
|
|
52
|
-
}, function (_a) {
|
|
53
|
-
var iconPosition = _a.iconPosition;
|
|
54
|
-
return ({
|
|
55
|
-
marginLeft: iconPosition === 'right' ? undefined : "-" + tokens_1.space.xxxs + " !important",
|
|
56
|
-
marginRight: iconPosition === 'right' ? "-" + tokens_1.space.xxxs + " !important" : undefined,
|
|
71
|
+
width: size ? iconSizes[size] : iconSizes.medium,
|
|
72
|
+
height: size ? iconSizes[size] : iconSizes.medium,
|
|
57
73
|
});
|
|
58
|
-
});
|
|
74
|
+
}, getIconPositionStyles);
|
|
59
75
|
exports.ButtonLabelIcon = function (_a) {
|
|
60
76
|
var icon = _a.icon, size = _a.size, iconPosition = _a.iconPosition, _b = _a.shouldMirrorIcon, shouldMirrorIcon = _b === void 0 ? false : _b, elemProps = __rest(_a, ["icon", "size", "iconPosition", "shouldMirrorIcon"]);
|
|
61
|
-
/* istanbul ignore next line for coverage */
|
|
62
77
|
if (icon === undefined) {
|
|
63
78
|
return null;
|
|
64
79
|
}
|
|
65
|
-
var iconSize = size
|
|
80
|
+
var iconSize = size ? iconSizes[size] : undefined;
|
|
66
81
|
return (React.createElement(ButtonLabelIconStyled, __assign({ iconPosition: iconPosition, size: size }, elemProps),
|
|
67
82
|
React.createElement(icon_1.SystemIcon, { size: iconSize, icon: icon, shouldMirror: shouldMirrorIcon })));
|
|
68
83
|
};
|
|
@@ -19,4 +19,12 @@ export interface ButtonColors {
|
|
|
19
19
|
};
|
|
20
20
|
disabled: ButtonStateColors;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
24
|
+
* If no size is provided, it will default to `medium`.
|
|
25
|
+
*
|
|
26
|
+
* @default 'medium'
|
|
27
|
+
*/
|
|
28
|
+
export declare type ButtonSizes = 'extraSmall' | 'small' | 'medium' | 'large';
|
|
29
|
+
export declare type IconPositions = 'left' | 'right';
|
|
22
30
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../button/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,iBAAiB,GAAG;QACzB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../button/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,iBAAiB,GAAG;QACzB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;;;GAKG;AACH,oBAAY,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtE,oBAAY,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC"}
|
|
@@ -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 {
|
|
4
|
+
import { ButtonSizes, IconPositions } from './types';
|
|
5
5
|
export interface PrimaryButtonProps extends Themeable, GrowthBehavior {
|
|
6
6
|
/**
|
|
7
|
-
* The
|
|
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?:
|
|
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
|
-
*
|
|
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?:
|
|
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: (
|
|
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,
|
|
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"}
|
|
@@ -21,8 +21,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import * as React from 'react';
|
|
24
|
-
import { useTheme, createComponent, } from '@workday/canvas-kit-react/common';
|
|
24
|
+
import { useTheme, createComponent, focusRing, } from '@workday/canvas-kit-react/common';
|
|
25
|
+
import { colors } from '@workday/canvas-kit-react/tokens';
|
|
25
26
|
import { ButtonContainer, ButtonLabel, ButtonLabelData, ButtonLabelIcon } from './parts';
|
|
27
|
+
// Button sizes where data labels are enabled
|
|
28
|
+
var dataLabelSizes = ['medium', 'large'];
|
|
29
|
+
// All disabled buttons are set to 40% opacity.
|
|
30
|
+
// This will eventually live in the ButtonContainer styles, but for now we're scoping it to Primary, Secondary, and Tertiary buttons.
|
|
31
|
+
var disabledButtonOpacity = {
|
|
32
|
+
'&:disabled, &:disabled:active': {
|
|
33
|
+
opacity: 0.4,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
26
36
|
export var PrimaryButton = createComponent('button')({
|
|
27
37
|
displayName: 'PrimaryButton',
|
|
28
38
|
Component: function (_a, ref, Element) {
|
|
@@ -32,33 +42,77 @@ export var PrimaryButton = createComponent('button')({
|
|
|
32
42
|
_b = _a.theme,
|
|
33
43
|
// TODO: Fix useTheme and make it a real hook
|
|
34
44
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
35
|
-
theme = _b === void 0 ? 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"]);
|
|
36
|
-
return (React.createElement(ButtonContainer, __assign({ ref: ref, as: Element, colors: getPrimaryButtonColors(theme), size: size }, elemProps),
|
|
37
|
-
icon &&
|
|
45
|
+
theme = _b === void 0 ? 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(ButtonContainer, __assign({ ref: ref, as: Element, colors: getPrimaryButtonColors(variant, theme), size: size, extraStyles: disabledButtonOpacity }, elemProps),
|
|
47
|
+
icon && iconPosition === 'left' && (React.createElement(ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
|
|
38
48
|
React.createElement(ButtonLabel, null, children),
|
|
39
|
-
dataLabel && size
|
|
40
|
-
icon &&
|
|
49
|
+
dataLabel && dataLabelSizes.includes(size) && React.createElement(ButtonLabelData, null, dataLabel),
|
|
50
|
+
icon && iconPosition === 'right' && (React.createElement(ButtonLabelIcon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
|
|
41
51
|
},
|
|
42
52
|
});
|
|
43
|
-
export var getPrimaryButtonColors = function (
|
|
44
|
-
var themePrimary =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
export var getPrimaryButtonColors = function (variant, theme) {
|
|
54
|
+
var themePrimary = theme.canvas.palette.primary;
|
|
55
|
+
switch (variant) {
|
|
56
|
+
case undefined:
|
|
57
|
+
default:
|
|
58
|
+
return {
|
|
59
|
+
default: {
|
|
60
|
+
background: themePrimary.main,
|
|
61
|
+
icon: themePrimary.contrast,
|
|
62
|
+
label: themePrimary.contrast,
|
|
63
|
+
},
|
|
64
|
+
hover: {
|
|
65
|
+
background: themePrimary.dark,
|
|
66
|
+
},
|
|
67
|
+
active: {
|
|
68
|
+
background: themePrimary.darkest,
|
|
69
|
+
},
|
|
70
|
+
focus: {
|
|
71
|
+
background: themePrimary.main,
|
|
72
|
+
},
|
|
73
|
+
disabled: {
|
|
74
|
+
background: themePrimary.main,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
case 'inverse':
|
|
78
|
+
return {
|
|
79
|
+
default: {
|
|
80
|
+
background: colors.frenchVanilla100,
|
|
81
|
+
icon: colors.blackPepper400,
|
|
82
|
+
label: colors.blackPepper400,
|
|
83
|
+
labelData: colors.blackPepper400,
|
|
84
|
+
},
|
|
85
|
+
hover: {
|
|
86
|
+
background: colors.soap300,
|
|
87
|
+
icon: colors.blackPepper500,
|
|
88
|
+
label: colors.blackPepper500,
|
|
89
|
+
labelData: colors.blackPepper500,
|
|
90
|
+
},
|
|
91
|
+
active: {
|
|
92
|
+
background: colors.soap300,
|
|
93
|
+
icon: colors.blackPepper500,
|
|
94
|
+
label: colors.blackPepper500,
|
|
95
|
+
labelData: colors.blackPepper500,
|
|
96
|
+
},
|
|
97
|
+
focus: {
|
|
98
|
+
background: colors.frenchVanilla100,
|
|
99
|
+
border: colors.blackPepper400,
|
|
100
|
+
icon: colors.blackPepper400,
|
|
101
|
+
label: colors.blackPepper400,
|
|
102
|
+
labelData: colors.blackPepper400,
|
|
103
|
+
focusRing: focusRing({
|
|
104
|
+
separation: 1,
|
|
105
|
+
innerColor: colors.blackPepper500,
|
|
106
|
+
outerColor: colors.frenchVanilla100,
|
|
107
|
+
}, theme),
|
|
108
|
+
},
|
|
109
|
+
// Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
|
|
110
|
+
disabled: {
|
|
111
|
+
background: colors.frenchVanilla100,
|
|
112
|
+
icon: colors.blackPepper400,
|
|
113
|
+
label: colors.blackPepper400,
|
|
114
|
+
labelData: colors.blackPepper400,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
64
118
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { CSSObject } from '@emotion/core';
|
|
3
3
|
import { GrowthBehavior, EmotionCanvasTheme, StyledType } from '@workday/canvas-kit-react/common';
|
|
4
|
-
import { ButtonColors } from '../types';
|
|
4
|
+
import { ButtonColors, ButtonSizes } from '../types';
|
|
5
5
|
export interface ButtonContainerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, GrowthBehavior {
|
|
6
6
|
colors?: ButtonColors;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
9
|
+
* If no size is provided, it will default to `medium`.
|
|
10
|
+
*
|
|
9
11
|
* @default 'medium'
|
|
10
12
|
*/
|
|
11
|
-
size?:
|
|
13
|
+
size?: ButtonSizes;
|
|
12
14
|
/**
|
|
13
15
|
* The ref to the button that the styled component renders.
|
|
14
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonContainer.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,cAAc,EAId,kBAAkB,EAClB,UAAU,EACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ButtonContainer.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,cAAc,EAId,kBAAkB,EAClB,UAAU,EACX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,YAAY,EAAE,WAAW,EAAC,MAAM,UAAU,CAAC;AAGnD,MAAM,WAAW,oBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,cAAc;IAChB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB;AA8BD,eAAO,MAAM,eAAe,kMA8K3B,CAAC"}
|
|
@@ -45,15 +45,9 @@ export var ButtonContainer = styled('button', {
|
|
|
45
45
|
var size = _a.size;
|
|
46
46
|
switch (size) {
|
|
47
47
|
case 'large':
|
|
48
|
-
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
height: '48px',
|
|
52
|
-
padding: "0 " + space.l,
|
|
53
|
-
'& > * ': {
|
|
54
|
-
margin: "0 " + spaceNumbers.xs / 2 + "px",
|
|
55
|
-
},
|
|
56
|
-
};
|
|
48
|
+
return __assign(__assign({}, type.levels.body.small), { fontWeight: type.properties.fontWeights.bold, minWidth: '112px', height: '48px', padding: "0 " + space.l, '& > * ': {
|
|
49
|
+
margin: "0 " + spaceNumbers.xxs / 2 + "px",
|
|
50
|
+
} });
|
|
57
51
|
case 'medium':
|
|
58
52
|
default:
|
|
59
53
|
return {
|
|
@@ -73,6 +67,14 @@ export var ButtonContainer = styled('button', {
|
|
|
73
67
|
margin: "0 " + spaceNumbers.xxxs / 2 + "px",
|
|
74
68
|
},
|
|
75
69
|
};
|
|
70
|
+
case 'extraSmall':
|
|
71
|
+
return {
|
|
72
|
+
height: space.m,
|
|
73
|
+
padding: "0 " + space.xs,
|
|
74
|
+
'& > * ': {
|
|
75
|
+
margin: "0 " + spaceNumbers.xxxs / 2 + "px",
|
|
76
|
+
},
|
|
77
|
+
};
|
|
76
78
|
}
|
|
77
79
|
}, function (_a) {
|
|
78
80
|
var grow = _a.grow;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
2
|
+
import { ButtonSizes, IconPositions } from '../types';
|
|
2
3
|
export interface ButtonLabelIconProps {
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
6
|
+
*
|
|
5
7
|
* @default 'medium'
|
|
6
8
|
*/
|
|
7
|
-
size?:
|
|
9
|
+
size?: ButtonSizes;
|
|
8
10
|
/**
|
|
9
11
|
* The icon of the Button.
|
|
10
12
|
* Note: not displayed at `small` size
|
|
11
13
|
*/
|
|
12
14
|
icon?: CanvasSystemIcon;
|
|
13
15
|
/**
|
|
14
|
-
*
|
|
16
|
+
* Button icon positions can either be `left` or `right`.
|
|
17
|
+
* If no value is provided, it defaults to `left`.
|
|
15
18
|
* @default 'left'
|
|
16
19
|
*/
|
|
17
|
-
iconPosition?:
|
|
20
|
+
iconPosition?: IconPositions;
|
|
18
21
|
/**
|
|
19
22
|
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
20
23
|
* @default false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonLabelIcon.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonLabelIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,MAAM,WAAW,oBAAoB;IACnC
|
|
1
|
+
{"version":3,"file":"ButtonLabelIcon.d.ts","sourceRoot":"","sources":["../../../../../button/lib/parts/ButtonLabelIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAM9D,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACpD,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,IAAI,CAAC,EAAE,WAAW,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;CAC5B;AAuCD,eAAO,MAAM,eAAe,4GAkB3B,CAAC"}
|
|
@@ -25,8 +25,30 @@ import { space } from '@workday/canvas-kit-react/tokens';
|
|
|
25
25
|
import isPropValid from '@emotion/is-prop-valid';
|
|
26
26
|
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
27
27
|
import { styled } from '@workday/canvas-kit-react/common';
|
|
28
|
-
var
|
|
29
|
-
|
|
28
|
+
var iconSizes = {
|
|
29
|
+
extraSmall: 18,
|
|
30
|
+
small: 20,
|
|
31
|
+
medium: 20,
|
|
32
|
+
large: 24,
|
|
33
|
+
};
|
|
34
|
+
var getIconPositionStyles = function (_a) {
|
|
35
|
+
var iconPosition = _a.iconPosition, size = _a.size;
|
|
36
|
+
// Adjust margin values for visual balance, large buttons require 8px
|
|
37
|
+
var balancingMargin = size === 'large' ? space.xxs : space.xxxs;
|
|
38
|
+
// iconPosition can only be "right", "left", or undefined (defaults to "left")
|
|
39
|
+
if (iconPosition === 'right') {
|
|
40
|
+
return {
|
|
41
|
+
marginLeft: undefined,
|
|
42
|
+
marginRight: "-" + balancingMargin + " !important",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return {
|
|
47
|
+
marginLeft: "-" + balancingMargin + " !important",
|
|
48
|
+
marginRight: undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
30
52
|
var ButtonLabelIconStyled = styled('span', {
|
|
31
53
|
shouldForwardProp: function (prop) { return isPropValid(prop) && prop !== 'size'; },
|
|
32
54
|
})({
|
|
@@ -34,23 +56,16 @@ var ButtonLabelIconStyled = styled('span', {
|
|
|
34
56
|
}, function (_a) {
|
|
35
57
|
var size = _a.size;
|
|
36
58
|
return ({
|
|
37
|
-
width: size
|
|
38
|
-
height: size
|
|
39
|
-
});
|
|
40
|
-
}, function (_a) {
|
|
41
|
-
var iconPosition = _a.iconPosition;
|
|
42
|
-
return ({
|
|
43
|
-
marginLeft: iconPosition === 'right' ? undefined : "-" + space.xxxs + " !important",
|
|
44
|
-
marginRight: iconPosition === 'right' ? "-" + space.xxxs + " !important" : undefined,
|
|
59
|
+
width: size ? iconSizes[size] : iconSizes.medium,
|
|
60
|
+
height: size ? iconSizes[size] : iconSizes.medium,
|
|
45
61
|
});
|
|
46
|
-
});
|
|
62
|
+
}, getIconPositionStyles);
|
|
47
63
|
export var ButtonLabelIcon = function (_a) {
|
|
48
64
|
var icon = _a.icon, size = _a.size, iconPosition = _a.iconPosition, _b = _a.shouldMirrorIcon, shouldMirrorIcon = _b === void 0 ? false : _b, elemProps = __rest(_a, ["icon", "size", "iconPosition", "shouldMirrorIcon"]);
|
|
49
|
-
/* istanbul ignore next line for coverage */
|
|
50
65
|
if (icon === undefined) {
|
|
51
66
|
return null;
|
|
52
67
|
}
|
|
53
|
-
var iconSize = size
|
|
68
|
+
var iconSize = size ? iconSizes[size] : undefined;
|
|
54
69
|
return (React.createElement(ButtonLabelIconStyled, __assign({ iconPosition: iconPosition, size: size }, elemProps),
|
|
55
70
|
React.createElement(SystemIcon, { size: iconSize, icon: icon, shouldMirror: shouldMirrorIcon })));
|
|
56
71
|
};
|
|
@@ -19,4 +19,12 @@ export interface ButtonColors {
|
|
|
19
19
|
};
|
|
20
20
|
disabled: ButtonStateColors;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
24
|
+
* If no size is provided, it will default to `medium`.
|
|
25
|
+
*
|
|
26
|
+
* @default 'medium'
|
|
27
|
+
*/
|
|
28
|
+
export declare type ButtonSizes = 'extraSmall' | 'small' | 'medium' | 'large';
|
|
29
|
+
export declare type IconPositions = 'left' | 'right';
|
|
22
30
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../button/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,iBAAiB,GAAG;QACzB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../button/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,iBAAiB,GAAG;QACzB,SAAS,CAAC,EAAE,SAAS,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAED;;;;;GAKG;AACH,oBAAY,WAAW,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtE,oBAAY,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "6.0.0-alpha.0-next.
|
|
3
|
+
"version": "6.0.0-alpha.0-next.28+c4856dee",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"@emotion/styled": "^10.0.27",
|
|
57
57
|
"@popperjs/core": "^2.5.4",
|
|
58
58
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
59
|
-
"@workday/canvas-kit-labs-react": "^6.0.0-alpha.0-next.
|
|
60
|
-
"@workday/canvas-kit-popup-stack": "^6.0.0-alpha.0-next.
|
|
61
|
-
"@workday/canvas-kit-preview-react": "^6.0.0-alpha.0-next.
|
|
59
|
+
"@workday/canvas-kit-labs-react": "^6.0.0-alpha.0-next.28+c4856dee",
|
|
60
|
+
"@workday/canvas-kit-popup-stack": "^6.0.0-alpha.0-next.28+c4856dee",
|
|
61
|
+
"@workday/canvas-kit-preview-react": "^6.0.0-alpha.0-next.28+c4856dee",
|
|
62
62
|
"@workday/canvas-system-icons-web": "1.0.41",
|
|
63
63
|
"@workday/design-assets-types": "^0.2.4",
|
|
64
64
|
"chroma-js": "^2.1.0",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"@workday/canvas-accent-icons-web": "^1.0.0",
|
|
75
75
|
"@workday/canvas-applet-icons-web": "^0.17.50"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "c4856dee60238eceb0481cb522466dc4bee29506"
|
|
78
78
|
}
|