@workday/canvas-kit-react 10.0.0-alpha.538-next.0 → 10.0.0-alpha.540-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.
- package/button/index.ts +8 -11
- package/button/lib/BaseButton.tsx +274 -256
- package/button/lib/Button.tsx +67 -0
- package/button/lib/DeleteButton.tsx +42 -58
- package/button/lib/PrimaryButton.tsx +82 -149
- package/button/lib/SecondaryButton.tsx +87 -173
- package/button/lib/TertiaryButton.tsx +158 -223
- package/button/lib/ToolbarDropdownButton.tsx +11 -2
- package/button/lib/ToolbarIconButton.tsx +10 -2
- package/button/lib/parts/ButtonLabelIcon.tsx +1 -7
- package/button/lib/types.ts +6 -8
- package/checkbox/lib/Checkbox.tsx +24 -33
- package/common/lib/CanvasProvider.tsx +50 -24
- package/dist/commonjs/button/index.d.ts +8 -5
- package/dist/commonjs/button/index.d.ts.map +1 -1
- package/dist/commonjs/button/index.js +9 -13
- package/dist/commonjs/button/lib/BaseButton.d.ts +69 -5
- package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/BaseButton.js +199 -192
- package/dist/commonjs/button/lib/Button.d.ts +17 -0
- package/dist/commonjs/button/lib/Button.d.ts.map +1 -0
- package/dist/commonjs/button/lib/Button.js +42 -0
- package/dist/commonjs/button/lib/DeleteButton.d.ts +7 -9
- package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/DeleteButton.js +29 -19
- package/dist/commonjs/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +67 -79
- package/dist/commonjs/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/SecondaryButton.js +71 -96
- package/dist/commonjs/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/TertiaryButton.js +136 -134
- package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/commonjs/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarIconButton.js +10 -2
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/commonjs/button/lib/types.d.ts +6 -7
- package/dist/commonjs/button/lib/types.d.ts.map +1 -1
- package/dist/commonjs/card/lib/Card.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.js +13 -17
- package/dist/commonjs/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +31 -13
- package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
- package/dist/commonjs/layout/lib/Box.d.ts +3 -2
- package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Box.js +2 -1
- package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
- package/dist/commonjs/layout/lib/Grid.d.ts +1 -1
- package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
- package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/Radio.js +17 -22
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/commonjs/table/lib/Table.d.ts +1 -2
- package/dist/commonjs/table/lib/Table.d.ts.map +1 -1
- package/dist/commonjs/table/lib/Table.js +1 -2
- package/dist/commonjs/table/lib/TableRow.d.ts +3 -6
- package/dist/commonjs/table/lib/TableRow.d.ts.map +1 -1
- package/dist/commonjs/table/lib/TableRow.js +3 -5
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/commonjs/text-area/lib/TextArea.d.ts.map +1 -1
- package/dist/commonjs/text-area/lib/TextArea.js +1 -1
- package/dist/commonjs/text-input/lib/TextInput.js +1 -1
- package/dist/commonjs/tokens/lib/space.d.ts +44 -31
- package/dist/commonjs/tokens/lib/space.d.ts.map +1 -1
- package/dist/commonjs/tokens/lib/space.js +22 -29
- package/dist/commonjs/tooltip/lib/TooltipContainer.js +2 -2
- package/dist/es6/button/index.d.ts +8 -5
- package/dist/es6/button/index.d.ts.map +1 -1
- package/dist/es6/button/index.js +8 -5
- package/dist/es6/button/lib/BaseButton.d.ts +69 -5
- package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/es6/button/lib/BaseButton.js +199 -192
- package/dist/es6/button/lib/Button.d.ts +17 -0
- package/dist/es6/button/lib/Button.d.ts.map +1 -0
- package/dist/es6/button/lib/Button.js +20 -0
- package/dist/es6/button/lib/DeleteButton.d.ts +7 -9
- package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/es6/button/lib/DeleteButton.js +31 -21
- package/dist/es6/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +67 -79
- package/dist/es6/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/SecondaryButton.js +71 -95
- package/dist/es6/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/TertiaryButton.js +137 -135
- package/dist/es6/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/es6/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarIconButton.js +10 -2
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/es6/button/lib/types.d.ts +6 -7
- package/dist/es6/button/lib/types.d.ts.map +1 -1
- package/dist/es6/card/lib/Card.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.js +14 -18
- package/dist/es6/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +31 -13
- package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
- package/dist/es6/layout/lib/Box.d.ts +3 -2
- package/dist/es6/layout/lib/Box.d.ts.map +1 -1
- package/dist/es6/layout/lib/Box.js +2 -1
- package/dist/es6/layout/lib/Flex.d.ts +1 -1
- package/dist/es6/layout/lib/Grid.d.ts +1 -1
- package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
- package/dist/es6/popup/lib/Popup.d.ts +1 -1
- package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
- package/dist/es6/radio/lib/Radio.js +18 -23
- package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/es6/table/lib/Table.d.ts +1 -2
- package/dist/es6/table/lib/Table.d.ts.map +1 -1
- package/dist/es6/table/lib/Table.js +1 -2
- package/dist/es6/table/lib/TableRow.d.ts +3 -6
- package/dist/es6/table/lib/TableRow.d.ts.map +1 -1
- package/dist/es6/table/lib/TableRow.js +4 -6
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/text-area/lib/TextArea.d.ts.map +1 -1
- package/dist/es6/text-area/lib/TextArea.js +2 -2
- package/dist/es6/text-input/lib/TextInput.js +2 -2
- package/dist/es6/tokens/lib/space.d.ts +44 -31
- package/dist/es6/tokens/lib/space.d.ts.map +1 -1
- package/dist/es6/tokens/lib/space.js +22 -29
- package/dist/es6/tooltip/lib/TooltipContainer.js +3 -3
- package/layout/lib/Box.tsx +6 -4
- package/package.json +5 -3
- package/popup/lib/PopupCloseIcon.tsx +1 -1
- package/radio/lib/Radio.tsx +18 -34
- package/segmented-control/lib/SegmentedControlButton.tsx +3 -1
- package/table/lib/Table.tsx +1 -2
- package/table/lib/TableRow.tsx +5 -8
- package/text-area/lib/TextArea.tsx +2 -8
- package/text-input/lib/TextInput.tsx +2 -2
- package/tokens/README.md +25 -28
- package/tokens/lib/space.ts +53 -40
- package/tooltip/lib/TooltipContainer.tsx +3 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BaseButton } from './BaseButton';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
export const Button = createComponent('button')({
|
|
5
|
+
displayName: 'Button',
|
|
6
|
+
Component: ({ children, icon, colors, iconPosition, shouldMirrorIcon, size = 'medium', ...elemProps }, ref, Element) => {
|
|
7
|
+
const baseIconPosition = iconPosition
|
|
8
|
+
? iconPosition
|
|
9
|
+
: icon
|
|
10
|
+
? children
|
|
11
|
+
? 'start'
|
|
12
|
+
: 'only'
|
|
13
|
+
: undefined;
|
|
14
|
+
return (React.createElement(BaseButton, Object.assign({ as: Element, ref: ref, size: size, icon: icon, iconPosition: baseIconPosition }, elemProps),
|
|
15
|
+
icon && baseIconPosition === 'start' && (React.createElement(BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
|
|
16
|
+
children && React.createElement(BaseButton.Label, null, children),
|
|
17
|
+
icon && baseIconPosition === 'only' && (React.createElement(BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
|
|
18
|
+
icon && baseIconPosition === 'end' && (React.createElement(BaseButton.Icon, { size: size, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
size?: 'small' | 'medium' | 'large';
|
|
9
|
-
children?: React.ReactNode;
|
|
1
|
+
import { ButtonProps } from './Button';
|
|
2
|
+
/**
|
|
3
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
4
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
5
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
6
|
+
*/
|
|
7
|
+
export interface DeleteButtonProps extends ButtonProps {
|
|
10
8
|
}
|
|
11
9
|
/**
|
|
12
10
|
* Use sparingly for destructive actions that will result in data loss, can’t be undone, or will
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/DeleteButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DeleteButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/DeleteButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAS,WAAW,EAAC,MAAM,UAAU,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,WAAW;CAAG;AA+BzD;;;;GAIG;AACH,eAAO,MAAM,YAAY,0FASvB,CAAC"}
|
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { buttonVars } from './BaseButton';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStyles, cssVar } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, brand, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
const deleteStyles = createStyles({
|
|
8
|
+
[buttonVars.default.background]: cssVar(brand.error.base),
|
|
9
|
+
[buttonVars.default.border]: 'transparent',
|
|
10
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
11
|
+
[buttonVars.default.label]: cssVar(brand.error.accent),
|
|
12
|
+
'&:hover, &.hover': {
|
|
13
|
+
[buttonVars.hover.background]: cssVar(brand.error.dark),
|
|
14
|
+
[buttonVars.hover.border]: 'transparent',
|
|
15
|
+
[buttonVars.hover.label]: cssVar(brand.error.accent),
|
|
8
16
|
},
|
|
9
|
-
|
|
10
|
-
background:
|
|
17
|
+
'&:focus-visible, &.focus': {
|
|
18
|
+
[buttonVars.focus.background]: cssVar(brand.error.base),
|
|
19
|
+
[buttonVars.focus.border]: 'transparent',
|
|
20
|
+
[buttonVars.focus.label]: cssVar(brand.error.accent),
|
|
21
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
22
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
11
23
|
},
|
|
12
|
-
active: {
|
|
13
|
-
background:
|
|
24
|
+
'&:active, &.active': {
|
|
25
|
+
[buttonVars.active.background]: cssVar(brand.error.darkest),
|
|
26
|
+
[buttonVars.active.border]: 'transparent',
|
|
27
|
+
[buttonVars.active.label]: cssVar(brand.error.accent),
|
|
14
28
|
},
|
|
15
|
-
focus: {
|
|
16
|
-
background:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
background: themeError.light,
|
|
20
|
-
opacity: '1', // allows for overriding the default opacity of 0.4
|
|
29
|
+
'&:disabled, &:active:disabled, &:focus:disabled, &:hover:disabled': {
|
|
30
|
+
[buttonVars.disabled.background]: cssVar(brand.error.light),
|
|
31
|
+
[buttonVars.disabled.label]: cssVar(brand.error.accent),
|
|
32
|
+
opacity: 1,
|
|
21
33
|
},
|
|
22
34
|
});
|
|
23
35
|
/**
|
|
@@ -27,9 +39,7 @@ const getDeleteButtonColors = ({ canvas: { palette: { error: themeError }, }, })
|
|
|
27
39
|
*/
|
|
28
40
|
export const DeleteButton = createComponent('button')({
|
|
29
41
|
displayName: 'DeleteButton',
|
|
30
|
-
Component: ({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
theme = useTheme(), size = 'medium', children, ...elemProps }, ref, Element) => (React.createElement(BaseButton, Object.assign({ padding: getPaddingStyles(children, size, undefined, undefined), minWidth: getMinWidthStyles(children, size), ref: ref, as: Element, colors: getDeleteButtonColors(theme), size: size }, elemProps),
|
|
34
|
-
React.createElement(BaseButton.Label, null, children))),
|
|
42
|
+
Component: ({ children, cs, size, ...elemProps }, ref, Element) => {
|
|
43
|
+
return (React.createElement(Button, Object.assign({ as: Element, ref: ref, size: size, cs: [deleteStyles, cs] }, elemProps), children));
|
|
44
|
+
},
|
|
35
45
|
});
|
|
@@ -1,42 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { ButtonProps } from './Button';
|
|
2
|
+
/**
|
|
3
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
4
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
5
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
6
|
+
*/
|
|
7
|
+
export interface PrimaryButtonProps extends ButtonProps {
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
+
* Variant has an option for `inverse` which will inverse the styling
|
|
9
10
|
*/
|
|
10
11
|
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
|
-
*/
|
|
15
|
-
size?: ButtonSizes;
|
|
16
|
-
/**
|
|
17
|
-
* The icon of the Button.
|
|
18
|
-
* Note: not displayed at `small` size
|
|
19
|
-
*/
|
|
20
|
-
icon?: CanvasSystemIcon;
|
|
21
|
-
/**
|
|
22
|
-
* Button icon positions can either be `start` or `end`.
|
|
23
|
-
* If no value is provided, it defaults to `start`.
|
|
24
|
-
*/
|
|
25
|
-
iconPosition?: IconPositions;
|
|
26
|
-
/**
|
|
27
|
-
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
28
|
-
*/
|
|
29
|
-
shouldMirrorIcon?: boolean;
|
|
30
|
-
children?: React.ReactNode;
|
|
31
12
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* prop.
|
|
40
|
-
*/
|
|
13
|
+
export declare const primaryButtonModifiers: {
|
|
14
|
+
variant: {
|
|
15
|
+
inverse: string;
|
|
16
|
+
};
|
|
17
|
+
} & ((modifiers: Partial<{
|
|
18
|
+
variant: "inverse";
|
|
19
|
+
}>) => string);
|
|
41
20
|
export declare const PrimaryButton: import("@workday/canvas-kit-react/common").ElementComponent<"button", PrimaryButtonProps>;
|
|
42
21
|
//# sourceMappingURL=PrimaryButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/PrimaryButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrimaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/PrimaryButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAS,WAAW,EAAC,MAAM,UAAU,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,kBAAmB,SAAQ,WAAW;IACrD;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAkCD,eAAO,MAAM,sBAAsB;;;;;;cA4BjC,CAAC;AAEH,eAAO,MAAM,aAAa,2FAqBxB,CAAC"}
|
|
@@ -1,84 +1,72 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
* Primary Buttons are high emphasis. Use once per screen to draw attention to the highest priority
|
|
68
|
-
* action. Multiple primary buttons make it confusing for the user to understand what action they
|
|
69
|
-
* should take. Not all screens require a Primary Button.
|
|
70
|
-
*
|
|
71
|
-
* Primary Buttons have four sizes: `extraSmall`, `small`, `medium`, and `large`. Icons are
|
|
72
|
-
* supported for every size and can be positioned at the `start` or `end` with the `iconPosition`
|
|
73
|
-
* prop.
|
|
74
|
-
*/
|
|
2
|
+
import { buttonVars } from './BaseButton';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStyles, cssVar, createModifiers } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, brand, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
const primaryStyles = createStyles({
|
|
8
|
+
// Default Styles
|
|
9
|
+
[buttonVars.default.background]: cssVar(brand.primary.base, cssVar(base.blueberry400)),
|
|
10
|
+
[buttonVars.default.border]: 'transparent',
|
|
11
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
12
|
+
[buttonVars.default.label]: cssVar(brand.primary.accent),
|
|
13
|
+
[buttonVars.default.icon]: cssVar(brand.primary.accent),
|
|
14
|
+
// Hover Styles
|
|
15
|
+
[buttonVars.hover.background]: cssVar(brand.primary.dark),
|
|
16
|
+
[buttonVars.hover.border]: 'transparent',
|
|
17
|
+
[buttonVars.hover.label]: cssVar(brand.primary.accent),
|
|
18
|
+
[buttonVars.hover.icon]: cssVar(brand.primary.accent),
|
|
19
|
+
// Focus Styles
|
|
20
|
+
[buttonVars.focus.background]: cssVar(brand.primary.base),
|
|
21
|
+
[buttonVars.focus.border]: 'transparent',
|
|
22
|
+
[buttonVars.focus.label]: cssVar(brand.primary.accent),
|
|
23
|
+
[buttonVars.focus.icon]: cssVar(brand.primary.accent),
|
|
24
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
25
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
26
|
+
// Active Styles
|
|
27
|
+
[buttonVars.active.background]: cssVar(brand.primary.darkest),
|
|
28
|
+
[buttonVars.active.border]: 'transparent',
|
|
29
|
+
[buttonVars.active.label]: cssVar(brand.primary.accent),
|
|
30
|
+
[buttonVars.active.icon]: cssVar(brand.primary.accent),
|
|
31
|
+
// Disabled Styles
|
|
32
|
+
[buttonVars.disabled.background]: cssVar(brand.primary.base),
|
|
33
|
+
[buttonVars.disabled.border]: 'transparent',
|
|
34
|
+
[buttonVars.disabled.label]: cssVar(brand.primary.accent),
|
|
35
|
+
[buttonVars.disabled.opacity]: '0.4',
|
|
36
|
+
[buttonVars.disabled.icon]: cssVar(brand.primary.accent),
|
|
37
|
+
});
|
|
38
|
+
export const primaryButtonModifiers = createModifiers({
|
|
39
|
+
variant: {
|
|
40
|
+
inverse: createStyles({
|
|
41
|
+
// Default Styles
|
|
42
|
+
[buttonVars.default.background]: cssVar(base.frenchVanilla100),
|
|
43
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
44
|
+
[buttonVars.default.label]: cssVar(base.blackPepper400),
|
|
45
|
+
[buttonVars.default.icon]: cssVar(base.blackPepper400),
|
|
46
|
+
// Hover Styles
|
|
47
|
+
[buttonVars.hover.background]: cssVar(base.soap300),
|
|
48
|
+
[buttonVars.hover.label]: cssVar(base.blackPepper500),
|
|
49
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper500),
|
|
50
|
+
// Focus Styles
|
|
51
|
+
[buttonVars.focus.background]: cssVar(base.frenchVanilla100),
|
|
52
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper400),
|
|
53
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper400),
|
|
54
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.blackPepper400),
|
|
55
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(base.frenchVanilla100),
|
|
56
|
+
// Active Styles
|
|
57
|
+
[buttonVars.active.background]: cssVar(base.soap400),
|
|
58
|
+
[buttonVars.active.label]: cssVar(base.blackPepper500),
|
|
59
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper500),
|
|
60
|
+
// Disabled Styles
|
|
61
|
+
[buttonVars.disabled.background]: cssVar(base.frenchVanilla100),
|
|
62
|
+
[buttonVars.disabled.label]: cssVar(base.blackPepper400),
|
|
63
|
+
[buttonVars.disabled.icon]: cssVar(base.blackPepper400),
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
75
67
|
export const PrimaryButton = createComponent('button')({
|
|
76
68
|
displayName: 'PrimaryButton',
|
|
77
|
-
Component: ({
|
|
78
|
-
|
|
79
|
-
return (React.createElement(BaseButton, Object.assign({ ref: ref, size: size, colors: getPrimaryButtonColors(variant, theme), padding: getPaddingStyles(children, size, icon, iconPosition), minWidth: getMinWidthStyles(children, size), as: Element }, elemProps),
|
|
80
|
-
icon && iconPosition === 'start' && (React.createElement(BaseButton.Icon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
|
|
81
|
-
children && React.createElement(BaseButton.Label, null, children),
|
|
82
|
-
icon && iconPosition === 'end' && (React.createElement(BaseButton.Icon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
|
|
69
|
+
Component: ({ children, icon, cs, iconPosition, variant, size, ...elemProps }, ref, Element) => {
|
|
70
|
+
return (React.createElement(Button, Object.assign({ as: Element, ref: ref, size: size, icon: icon, iconPosition: iconPosition, cs: [primaryStyles, primaryButtonModifiers({ variant: variant }), cs] }, elemProps), children));
|
|
83
71
|
},
|
|
84
72
|
});
|
|
@@ -1,48 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* The variant of the SecondaryButton.
|
|
9
|
-
* @default undefined
|
|
10
|
-
*/
|
|
11
|
-
variant?: 'inverse' | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
14
|
-
* If no size is provided, it will default to `medium`.
|
|
15
|
-
*
|
|
16
|
-
* @default 'medium'
|
|
17
|
-
*/
|
|
18
|
-
size?: ButtonSizes;
|
|
19
|
-
/**
|
|
20
|
-
* The icon of the Button.
|
|
21
|
-
* Note: not displayed at `small` size
|
|
22
|
-
*/
|
|
23
|
-
icon?: CanvasSystemIcon;
|
|
24
|
-
/**
|
|
25
|
-
* Button icon positions can either be `start` or `end`.
|
|
26
|
-
* If no value is provided, it defaults to `start`.
|
|
27
|
-
* @default 'start'
|
|
28
|
-
*/
|
|
29
|
-
iconPosition?: IconPositions;
|
|
1
|
+
import { ButtonProps } from './Button';
|
|
2
|
+
/**
|
|
3
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
4
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
5
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
6
|
+
*/
|
|
7
|
+
export interface SecondaryButtonProps extends ButtonProps {
|
|
30
8
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @default false
|
|
9
|
+
* Variant has an option for `inverse` which will inverse the styling
|
|
33
10
|
*/
|
|
34
|
-
|
|
35
|
-
children?: React.ReactNode;
|
|
11
|
+
variant?: 'inverse';
|
|
36
12
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* prop.
|
|
45
|
-
*/
|
|
13
|
+
export declare const secondaryButtonModifiers: {
|
|
14
|
+
variant: {
|
|
15
|
+
inverse: string;
|
|
16
|
+
};
|
|
17
|
+
} & ((modifiers: Partial<{
|
|
18
|
+
variant: "inverse";
|
|
19
|
+
}>) => string);
|
|
46
20
|
export declare const SecondaryButton: import("@workday/canvas-kit-react/common").ElementComponent<"button", SecondaryButtonProps>;
|
|
47
|
-
export declare const getSecondaryButtonColors: (variant: 'inverse' | undefined, theme: EmotionCanvasTheme) => ButtonColors;
|
|
48
21
|
//# sourceMappingURL=SecondaryButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/SecondaryButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SecondaryButton.d.ts","sourceRoot":"","sources":["../../../../button/lib/SecondaryButton.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAS,WAAW,EAAC,MAAM,UAAU,CAAC;AAE7C;;;;GAIG;AACH,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IACvD;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAkCD,eAAO,MAAM,wBAAwB;;;;;;cAgCnC,CAAC;AAEH,eAAO,MAAM,eAAe,6FAoB1B,CAAC"}
|
|
@@ -1,100 +1,76 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { buttonVars } from './BaseButton';
|
|
3
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { createStyles, cssVar, createModifiers } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, brand, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
import { Button } from './Button';
|
|
7
|
+
const secondaryStyles = createStyles({
|
|
8
|
+
// Default Styles
|
|
9
|
+
[buttonVars.default.background]: 'transparent',
|
|
10
|
+
[buttonVars.default.border]: cssVar(base.blackPepper400),
|
|
11
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
12
|
+
[buttonVars.default.label]: cssVar(base.blackPepper400),
|
|
13
|
+
[buttonVars.default.icon]: cssVar(base.blackPepper400),
|
|
14
|
+
// Hover Styles
|
|
15
|
+
[buttonVars.hover.background]: cssVar(base.blackPepper400),
|
|
16
|
+
[buttonVars.hover.border]: cssVar(base.blackPepper400),
|
|
17
|
+
[buttonVars.hover.label]: cssVar(brand.primary.accent),
|
|
18
|
+
[buttonVars.hover.icon]: cssVar(brand.primary.accent),
|
|
19
|
+
// Focus Styles
|
|
20
|
+
[buttonVars.focus.background]: 'transparent',
|
|
21
|
+
[buttonVars.focus.border]: cssVar(base.blackPepper400),
|
|
22
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper400),
|
|
23
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper400),
|
|
24
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
25
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
26
|
+
// Active Styles
|
|
27
|
+
[buttonVars.active.background]: cssVar(base.blackPepper500),
|
|
28
|
+
[buttonVars.active.border]: cssVar(base.blackPepper500),
|
|
29
|
+
[buttonVars.active.label]: cssVar(brand.primary.accent),
|
|
30
|
+
[buttonVars.active.icon]: cssVar(brand.primary.accent),
|
|
31
|
+
// Disabled Styles
|
|
32
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
33
|
+
[buttonVars.disabled.border]: cssVar(base.blackPepper400),
|
|
34
|
+
[buttonVars.disabled.label]: cssVar(base.blackPepper400),
|
|
35
|
+
[buttonVars.disabled.opacity]: '0.4',
|
|
36
|
+
[buttonVars.disabled.icon]: cssVar(base.blackPepper400),
|
|
37
|
+
});
|
|
38
|
+
export const secondaryButtonModifiers = createModifiers({
|
|
39
|
+
variant: {
|
|
40
|
+
inverse: createStyles({
|
|
41
|
+
// Default Styles
|
|
42
|
+
[buttonVars.default.background]: 'transparent',
|
|
43
|
+
[buttonVars.default.border]: cssVar(base.frenchVanilla100),
|
|
44
|
+
[buttonVars.default.label]: cssVar(base.frenchVanilla100),
|
|
45
|
+
[buttonVars.default.icon]: cssVar(base.frenchVanilla100),
|
|
46
|
+
// Hover Styles
|
|
47
|
+
[buttonVars.hover.background]: cssVar(base.soap300),
|
|
48
|
+
[buttonVars.hover.border]: cssVar(base.soap300),
|
|
49
|
+
[buttonVars.hover.label]: cssVar(base.blackPepper500),
|
|
50
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper500),
|
|
51
|
+
// Focus Styles
|
|
52
|
+
[buttonVars.focus.background]: cssVar(base.frenchVanilla100),
|
|
53
|
+
[buttonVars.focus.border]: cssVar(base.frenchVanilla100),
|
|
54
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper500),
|
|
55
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper500),
|
|
56
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.blackPepper500),
|
|
57
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(base.frenchVanilla100),
|
|
58
|
+
// Active Styles
|
|
59
|
+
[buttonVars.active.background]: cssVar(base.soap400),
|
|
60
|
+
[buttonVars.active.border]: cssVar(base.soap400),
|
|
61
|
+
[buttonVars.active.label]: cssVar(base.blackPepper500),
|
|
62
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper500),
|
|
63
|
+
// Disabled Styles
|
|
64
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
65
|
+
[buttonVars.disabled.border]: cssVar(base.frenchVanilla100),
|
|
66
|
+
[buttonVars.disabled.label]: cssVar(base.frenchVanilla100),
|
|
67
|
+
[buttonVars.disabled.icon]: cssVar(base.frenchVanilla100),
|
|
68
|
+
}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
14
71
|
export const SecondaryButton = createComponent('button')({
|
|
15
72
|
displayName: 'SecondaryButton',
|
|
16
|
-
Component: ({
|
|
17
|
-
|
|
18
|
-
return (React.createElement(BaseButton, Object.assign({ ref: ref, size: size, colors: getSecondaryButtonColors(variant, theme), padding: getPaddingStyles(children, size, icon, iconPosition), minWidth: getMinWidthStyles(children, size), as: Element }, elemProps),
|
|
19
|
-
icon && iconPosition === 'start' && (React.createElement(BaseButton.Icon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon })),
|
|
20
|
-
children && React.createElement(BaseButton.Label, null, children),
|
|
21
|
-
icon && iconPosition === 'end' && (React.createElement(BaseButton.Icon, { size: size, iconPosition: iconPosition, icon: icon, shouldMirrorIcon: shouldMirrorIcon }))));
|
|
73
|
+
Component: ({ children, icon, cs, iconPosition, variant, ...elemProps }, ref, Element) => {
|
|
74
|
+
return (React.createElement(Button, Object.assign({ as: Element, ref: ref, icon: icon, iconPosition: iconPosition, cs: [secondaryStyles, secondaryButtonModifiers({ variant: variant }), cs] }, elemProps), children));
|
|
22
75
|
},
|
|
23
76
|
});
|
|
24
|
-
export const getSecondaryButtonColors = (variant, theme) => {
|
|
25
|
-
const { canvas: { palette: { primary: themePrimary }, }, } = theme;
|
|
26
|
-
switch (variant) {
|
|
27
|
-
case undefined:
|
|
28
|
-
default:
|
|
29
|
-
return {
|
|
30
|
-
default: {
|
|
31
|
-
background: 'transparent',
|
|
32
|
-
border: colors.blackPepper400,
|
|
33
|
-
icon: colors.blackPepper400,
|
|
34
|
-
label: colors.blackPepper400,
|
|
35
|
-
},
|
|
36
|
-
hover: {
|
|
37
|
-
background: colors.blackPepper400,
|
|
38
|
-
border: colors.blackPepper400,
|
|
39
|
-
icon: themePrimary.contrast,
|
|
40
|
-
label: themePrimary.contrast,
|
|
41
|
-
},
|
|
42
|
-
active: {
|
|
43
|
-
background: colors.blackPepper500,
|
|
44
|
-
border: colors.blackPepper500,
|
|
45
|
-
icon: themePrimary.contrast,
|
|
46
|
-
label: themePrimary.contrast,
|
|
47
|
-
},
|
|
48
|
-
focus: {
|
|
49
|
-
border: colors.blackPepper400,
|
|
50
|
-
icon: colors.blackPepper400,
|
|
51
|
-
label: colors.blackPepper400,
|
|
52
|
-
},
|
|
53
|
-
// Identical to 'default' styles. ButtonContainer will set opacity to 40%
|
|
54
|
-
disabled: {
|
|
55
|
-
background: 'transparent',
|
|
56
|
-
border: colors.blackPepper400,
|
|
57
|
-
icon: colors.blackPepper400,
|
|
58
|
-
label: colors.blackPepper400,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
case 'inverse':
|
|
62
|
-
return {
|
|
63
|
-
default: {
|
|
64
|
-
background: 'transparent',
|
|
65
|
-
border: colors.frenchVanilla100,
|
|
66
|
-
icon: colors.frenchVanilla100,
|
|
67
|
-
label: colors.frenchVanilla100,
|
|
68
|
-
},
|
|
69
|
-
hover: {
|
|
70
|
-
background: colors.soap300,
|
|
71
|
-
border: colors.soap300,
|
|
72
|
-
icon: colors.blackPepper500,
|
|
73
|
-
label: colors.blackPepper500,
|
|
74
|
-
},
|
|
75
|
-
active: {
|
|
76
|
-
background: colors.soap400,
|
|
77
|
-
border: colors.soap400,
|
|
78
|
-
icon: colors.blackPepper500,
|
|
79
|
-
label: colors.blackPepper500,
|
|
80
|
-
},
|
|
81
|
-
focus: {
|
|
82
|
-
background: colors.frenchVanilla100,
|
|
83
|
-
icon: colors.blackPepper500,
|
|
84
|
-
label: colors.blackPepper500,
|
|
85
|
-
focusRing: focusRing({
|
|
86
|
-
separation: 2,
|
|
87
|
-
innerColor: 'currentColor',
|
|
88
|
-
outerColor: colors.frenchVanilla100,
|
|
89
|
-
}, theme),
|
|
90
|
-
},
|
|
91
|
-
// Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
|
|
92
|
-
disabled: {
|
|
93
|
-
background: 'transparent',
|
|
94
|
-
border: colors.frenchVanilla100,
|
|
95
|
-
icon: colors.frenchVanilla100,
|
|
96
|
-
label: colors.frenchVanilla100,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
};
|