@openfin/ui-library 0.0.39 → 0.0.40
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/dist/components/controls/Button/button.js +3 -4
- package/dist/components/controls/Button/button.variants.js +0 -2
- package/dist/components/controls/Toggle/toggle.d.ts +2 -2
- package/dist/components/controls/Toggle/toggle.js +17 -34
- package/dist/components/system/ThemeProvider/lib/constants.d.ts +1 -1
- package/dist/components/system/ThemeProvider/lib/constants.js +1 -1
- package/dist/components/system/ThemeProvider/lib/palette.d.ts +3 -8
- package/dist/components/system/ThemeProvider/lib/palette.js +3 -8
- package/dist/components/system/ThemeProvider/themes/openfin.js +7 -9
- package/package.json +1 -1
- package/dist/components/controls/Toggle/toggle.variants.d.ts +0 -24
- package/dist/components/controls/Toggle/toggle.variants.js +0 -50
|
@@ -39,12 +39,11 @@ const ButtonElement = styled_components_1.default.button `
|
|
|
39
39
|
/**
|
|
40
40
|
* 1. Initialize local variables with reasonable defaults
|
|
41
41
|
*/
|
|
42
|
-
--color-background: ${({ theme }) => theme.palette.
|
|
43
|
-
--color-foreground: ${({ theme }) => theme.palette.
|
|
42
|
+
--color-background: ${({ theme }) => theme.palette.inputBg};
|
|
43
|
+
--color-foreground: ${({ theme }) => theme.palette.inputColor};
|
|
44
44
|
|
|
45
45
|
&:disabled {
|
|
46
|
-
--color-background: ${({ theme }) => theme.palette.
|
|
47
|
-
--color-foreground: ${({ theme }) => theme.palette.controlDisabledAccent};
|
|
46
|
+
--color-background: ${({ theme }) => theme.palette.inputDisabled};
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
/**
|
|
@@ -76,11 +76,9 @@ exports.variants = {
|
|
|
76
76
|
[exports.Variant.kind]: {
|
|
77
77
|
[exports.ButtonKind.primary]: styled_components_1.css `
|
|
78
78
|
--color-background: ${({ theme }) => theme.palette.brandPrimary};
|
|
79
|
-
--color-foreground: ${({ theme }) => theme.palette.controlAccent};
|
|
80
79
|
`,
|
|
81
80
|
[exports.ButtonKind.secondary]: styled_components_1.css `
|
|
82
81
|
--color-background: ${({ theme }) => theme.palette.brandSecondary};
|
|
83
|
-
--color-foreground: ${({ theme }) => theme.palette.controlAccent};
|
|
84
82
|
`,
|
|
85
83
|
[exports.ButtonKind.textOnly]: styled_components_1.css `
|
|
86
84
|
--color-background: transparent;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FC, InputHTMLAttributes } from 'react';
|
|
2
|
-
|
|
2
|
+
export declare type LabelSideType = 'left' | 'right';
|
|
3
3
|
export declare type ToggleProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
4
4
|
label?: string;
|
|
5
5
|
labelSide?: LabelSideType;
|
|
6
|
-
kind?: KindType;
|
|
7
6
|
type?: 'checkbox' | 'radio';
|
|
7
|
+
onChange?: Function;
|
|
8
8
|
};
|
|
9
9
|
export declare const Toggle: FC<ToggleProps>;
|
|
@@ -16,60 +16,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Toggle = void 0;
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
19
20
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
20
|
-
const helpers_1 = require("../../system/ThemeProvider/lib/helpers");
|
|
21
21
|
const Input_1 = require("../../input/Input");
|
|
22
|
-
const
|
|
22
|
+
const Box_1 = require("../../layout/Box");
|
|
23
23
|
const Toggle = (_a) => {
|
|
24
|
-
var { id, label, labelSide = 'right', type = 'checkbox',
|
|
24
|
+
var { id, label, labelSide = 'right', type = 'checkbox', onChange = () => { } } = _a, inputProps = __rest(_a, ["id", "label", "labelSide", "type", "onChange"]);
|
|
25
|
+
const [isChecked, setIsChecked] = react_1.useState(inputProps.checked);
|
|
25
26
|
return (jsx_runtime_1.jsxs(ToggleContainer, Object.assign({ labelSide: labelSide }, { children: [label ? jsx_runtime_1.jsx(ToggleLabel, Object.assign({ htmlFor: id }, { children: label }), void 0) : undefined,
|
|
26
|
-
jsx_runtime_1.jsxs(InputContainer, Object.assign({
|
|
27
|
-
|
|
27
|
+
jsx_runtime_1.jsxs(InputContainer, Object.assign({ isChecked: isChecked }, { children: [jsx_runtime_1.jsx(ToggleInput, Object.assign({ id: id, type: type }, inputProps, { onChange: (event) => {
|
|
28
|
+
setIsChecked(event.target.checked);
|
|
29
|
+
onChange(event);
|
|
30
|
+
} }), void 0),
|
|
31
|
+
jsx_runtime_1.jsx(ToggleKnob, { tabIndex: -1 }, void 0)] }), void 0)] }), void 0));
|
|
28
32
|
};
|
|
29
33
|
exports.Toggle = Toggle;
|
|
30
34
|
const ToggleContainer = styled_components_1.default.div `
|
|
31
|
-
/**
|
|
32
|
-
* 1. Inject variants
|
|
33
|
-
*/
|
|
34
|
-
${helpers_1.getVariantCSS(toggle_variants_1.variants, toggle_variants_1.Variant.labelSide)}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 2. Component Build
|
|
38
|
-
*/
|
|
39
35
|
display: flex;
|
|
40
36
|
gap: ${({ theme }) => theme.px.xlarge};
|
|
37
|
+
flex-direction: ${({ labelSide }) => labelSide === 'right' ? 'row' : 'row-reverse'};
|
|
41
38
|
line-height: ${({ theme }) => theme.px.xlarge /* Matches height of Input to vertically center text */};
|
|
42
39
|
`;
|
|
43
|
-
const InputContainer = styled_components_1.default.
|
|
44
|
-
/**
|
|
45
|
-
* 1. Initialize local variables with reasonable defaults
|
|
46
|
-
*/
|
|
47
|
-
--color-background: ${({ theme }) => theme.palette.controlAccent};
|
|
48
|
-
--color-foreground: ${({ theme }) => theme.palette.controlFill};
|
|
49
|
-
--color-active: ${({ theme }) => theme.palette.controlActiveFill};
|
|
50
|
-
--color-knob: var(--color-foreground);
|
|
40
|
+
const InputContainer = styled_components_1.default(Box_1.Box) `
|
|
51
41
|
--px-toggle: ${({ theme }) => theme.px.xlarge};
|
|
52
42
|
--px-knob: ${({ theme }) => theme.px.base};
|
|
53
43
|
|
|
54
|
-
/**
|
|
55
|
-
* 2. Inject variants
|
|
56
|
-
*/
|
|
57
|
-
${helpers_1.getVariantCSS(toggle_variants_1.variants, toggle_variants_1.Variant.kind)}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 3. Component Build
|
|
61
|
-
*/
|
|
62
44
|
position: relative;
|
|
63
45
|
height: var(--px-toggle);
|
|
64
46
|
width: calc(2 * var(--px-toggle));
|
|
47
|
+
border: 1px solid
|
|
48
|
+
${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.inputBg};
|
|
65
49
|
border-radius: calc(0.5 * var(--px-toggle));
|
|
66
50
|
|
|
67
|
-
background:
|
|
51
|
+
background: ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.inputBg};
|
|
68
52
|
transition: background var(--global-transition);
|
|
69
53
|
|
|
70
54
|
&:focus-within {
|
|
71
|
-
|
|
72
|
-
0 0 0 2px var(--color-active);
|
|
55
|
+
border-color: ${({ theme }) => theme.palette.inputFocused};
|
|
73
56
|
}
|
|
74
57
|
`;
|
|
75
58
|
const ToggleKnob = styled_components_1.default.button `
|
|
@@ -80,7 +63,7 @@ const ToggleKnob = styled_components_1.default.button `
|
|
|
80
63
|
left: ${({ theme }) => theme.px.xsmall};
|
|
81
64
|
transform: translateY(-50%);
|
|
82
65
|
border-radius: 50%;
|
|
83
|
-
background:
|
|
66
|
+
background: ${({ theme }) => theme.palette.inputColor};
|
|
84
67
|
border: none;
|
|
85
68
|
outline: none;
|
|
86
69
|
transition: left var(--global-transition);
|
|
@@ -102,7 +85,7 @@ const ToggleInput = styled_components_1.default(Input_1.Input) `
|
|
|
102
85
|
left: calc(100% - ${({ theme }) => theme.px.large});
|
|
103
86
|
}
|
|
104
87
|
&:disabled + ${ToggleKnob} {
|
|
105
|
-
|
|
88
|
+
background: ${({ theme }) => theme.palette.inputDisabled};
|
|
106
89
|
}
|
|
107
90
|
&:not(:disabled) {
|
|
108
91
|
cursor: pointer;
|
|
@@ -192,7 +192,7 @@ export declare const Typography: {
|
|
|
192
192
|
* Design System transition easings because UI motion feels better if everything moves the same way.
|
|
193
193
|
*/
|
|
194
194
|
export declare const Transition: {
|
|
195
|
-
readonly base: "
|
|
195
|
+
readonly base: "200ms cubic-bezier(0.16, 1, 0.3, 1)";
|
|
196
196
|
readonly none: "0ms";
|
|
197
197
|
};
|
|
198
198
|
/**
|
|
@@ -228,7 +228,7 @@ exports.Typography = {
|
|
|
228
228
|
* Design System transition easings because UI motion feels better if everything moves the same way.
|
|
229
229
|
*/
|
|
230
230
|
exports.Transition = {
|
|
231
|
-
base: '
|
|
231
|
+
base: '200ms cubic-bezier(0.16, 1, 0.3, 1)',
|
|
232
232
|
none: '0ms',
|
|
233
233
|
};
|
|
234
234
|
/**
|
|
@@ -10,20 +10,15 @@ export declare const Palette: {
|
|
|
10
10
|
readonly background6: "background6";
|
|
11
11
|
readonly brandPrimary: "brandPrimary";
|
|
12
12
|
readonly brandSecondary: "brandSecondary";
|
|
13
|
-
readonly controlFill: "controlFill";
|
|
14
|
-
readonly controlAccent: "controlAccent";
|
|
15
|
-
readonly controlActiveFill: "controlActiveFill";
|
|
16
|
-
readonly controlDisabledFill: "controlDisabledFill";
|
|
17
|
-
readonly controlDisabledAccent: "controlDisabledAccent";
|
|
18
13
|
readonly inputBg: "inputBg";
|
|
19
14
|
readonly inputColor: "inputColor";
|
|
20
15
|
readonly inputPlaceholder: "inputPlaceholder";
|
|
21
|
-
readonly
|
|
16
|
+
readonly inputDisabled: "inputDisabled";
|
|
17
|
+
readonly inputFocused: "inputFocused";
|
|
22
18
|
readonly statusSuccess: "statusSuccess";
|
|
23
19
|
readonly statusWarning: "statusWarning";
|
|
24
20
|
readonly statusCritical: "statusCritical";
|
|
25
|
-
readonly
|
|
26
|
-
readonly statusFocused: "statusFocused";
|
|
21
|
+
readonly statusActive: "statusActive";
|
|
27
22
|
readonly textDefault: "textDefault";
|
|
28
23
|
readonly textHelp: "textHelp";
|
|
29
24
|
readonly textInactive: "textInactive";
|
|
@@ -13,20 +13,15 @@ exports.Palette = {
|
|
|
13
13
|
background6: 'background6',
|
|
14
14
|
brandPrimary: 'brandPrimary',
|
|
15
15
|
brandSecondary: 'brandSecondary',
|
|
16
|
-
controlFill: 'controlFill',
|
|
17
|
-
controlAccent: 'controlAccent',
|
|
18
|
-
controlActiveFill: 'controlActiveFill',
|
|
19
|
-
controlDisabledFill: 'controlDisabledFill',
|
|
20
|
-
controlDisabledAccent: 'controlDisabledAccent',
|
|
21
16
|
inputBg: 'inputBg',
|
|
22
17
|
inputColor: 'inputColor',
|
|
23
18
|
inputPlaceholder: 'inputPlaceholder',
|
|
24
|
-
|
|
19
|
+
inputDisabled: 'inputDisabled',
|
|
20
|
+
inputFocused: 'inputFocused',
|
|
25
21
|
statusSuccess: 'statusSuccess',
|
|
26
22
|
statusWarning: 'statusWarning',
|
|
27
23
|
statusCritical: 'statusCritical',
|
|
28
|
-
|
|
29
|
-
statusFocused: 'statusFocused',
|
|
24
|
+
statusActive: 'statusActive',
|
|
30
25
|
textDefault: 'textDefault',
|
|
31
26
|
textHelp: 'textHelp',
|
|
32
27
|
textInactive: 'textInactive',
|
|
@@ -20,13 +20,11 @@ const base = {
|
|
|
20
20
|
const sharedPalette = {
|
|
21
21
|
// Brand
|
|
22
22
|
[palette_1.Palette.brandPrimary]: constants_1.Color.openFin,
|
|
23
|
-
[palette_1.Palette.brandSecondary]: constants_1.Color.blue,
|
|
24
23
|
// Status
|
|
25
24
|
[palette_1.Palette.statusSuccess]: constants_1.Color.green,
|
|
26
25
|
[palette_1.Palette.statusWarning]: constants_1.Color.orange,
|
|
27
26
|
[palette_1.Palette.statusCritical]: constants_1.Color.red,
|
|
28
|
-
[palette_1.Palette.
|
|
29
|
-
[palette_1.Palette.statusFocused]: constants_1.Color.neutralGray,
|
|
27
|
+
[palette_1.Palette.statusActive]: constants_1.Color.blue,
|
|
30
28
|
};
|
|
31
29
|
/**
|
|
32
30
|
* Light Theme
|
|
@@ -34,10 +32,10 @@ const sharedPalette = {
|
|
|
34
32
|
exports.OpenFinLightTheme = Object.assign(Object.assign({}, base), { palette: Object.assign(Object.assign({}, sharedPalette), {
|
|
35
33
|
// Background levels
|
|
36
34
|
[palette_1.Palette.background1]: constants_1.Color.lightGray1, [palette_1.Palette.background2]: constants_1.Color.lightGray2, [palette_1.Palette.background3]: constants_1.Color.lightGray3, [palette_1.Palette.background4]: constants_1.Color.lightGray4, [palette_1.Palette.background5]: constants_1.Color.lightGray4, [palette_1.Palette.background6]: constants_1.Color.lightGray4,
|
|
37
|
-
//
|
|
38
|
-
[palette_1.Palette.
|
|
35
|
+
// Brand
|
|
36
|
+
[palette_1.Palette.brandSecondary]: constants_1.Color.darkGray6,
|
|
39
37
|
// Inputs
|
|
40
|
-
[palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray4, [palette_1.Palette.
|
|
38
|
+
[palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray4, [palette_1.Palette.inputDisabled]: constants_1.Color.neutralGray, [palette_1.Palette.inputFocused]: constants_1.Color.lightGray4,
|
|
41
39
|
// Text
|
|
42
40
|
[palette_1.Palette.textDefault]: constants_1.Color.darkGray6, [palette_1.Palette.textHelp]: constants_1.Color.darkGray3, [palette_1.Palette.textInactive]: constants_1.Color.neutralGray }) });
|
|
43
41
|
/**
|
|
@@ -46,9 +44,9 @@ exports.OpenFinLightTheme = Object.assign(Object.assign({}, base), { palette: Ob
|
|
|
46
44
|
exports.OpenFinDarkTheme = Object.assign(Object.assign({}, base), { palette: Object.assign(Object.assign({}, sharedPalette), {
|
|
47
45
|
// Background levels
|
|
48
46
|
[palette_1.Palette.background1]: constants_1.Color.darkGray6, [palette_1.Palette.background2]: constants_1.Color.darkGray5, [palette_1.Palette.background3]: constants_1.Color.darkGray4, [palette_1.Palette.background4]: constants_1.Color.darkGray3, [palette_1.Palette.background5]: constants_1.Color.darkGray2, [palette_1.Palette.background6]: constants_1.Color.darkGray1,
|
|
49
|
-
//
|
|
50
|
-
[palette_1.Palette.
|
|
47
|
+
// Brand
|
|
48
|
+
[palette_1.Palette.brandSecondary]: constants_1.Color.darkGray2,
|
|
51
49
|
// Inputs
|
|
52
|
-
[palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray4, [palette_1.Palette.
|
|
50
|
+
[palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray4, [palette_1.Palette.inputDisabled]: constants_1.Color.neutralGray, [palette_1.Palette.inputFocused]: constants_1.Color.lightGray4,
|
|
53
51
|
// Text
|
|
54
52
|
[palette_1.Palette.textDefault]: constants_1.Color.white, [palette_1.Palette.textHelp]: constants_1.Color.lightGray4, [palette_1.Palette.textInactive]: constants_1.Color.neutralGray }) });
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const Variant: {
|
|
2
|
-
readonly kind: "kind";
|
|
3
|
-
readonly labelSide: "labelSide";
|
|
4
|
-
};
|
|
5
|
-
export declare const Kind: {
|
|
6
|
-
readonly primary: "primary";
|
|
7
|
-
readonly secondary: "secondary";
|
|
8
|
-
};
|
|
9
|
-
export declare type KindType = keyof typeof Kind;
|
|
10
|
-
export declare const LabelSide: {
|
|
11
|
-
readonly left: "left";
|
|
12
|
-
readonly right: "right";
|
|
13
|
-
};
|
|
14
|
-
export declare type LabelSideType = keyof typeof LabelSide;
|
|
15
|
-
export declare const variants: {
|
|
16
|
-
readonly kind: {
|
|
17
|
-
readonly primary: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
18
|
-
readonly secondary: import("styled-components").FlattenInterpolation<import("styled-components").ThemeProps<import("styled-components").DefaultTheme>>;
|
|
19
|
-
};
|
|
20
|
-
readonly labelSide: {
|
|
21
|
-
readonly left: import("styled-components").FlattenSimpleInterpolation;
|
|
22
|
-
readonly right: import("styled-components").FlattenSimpleInterpolation;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.variants = exports.LabelSide = exports.Kind = exports.Variant = void 0;
|
|
4
|
-
const styled_components_1 = require("styled-components");
|
|
5
|
-
exports.Variant = {
|
|
6
|
-
kind: 'kind',
|
|
7
|
-
labelSide: 'labelSide',
|
|
8
|
-
};
|
|
9
|
-
exports.Kind = {
|
|
10
|
-
primary: 'primary',
|
|
11
|
-
secondary: 'secondary',
|
|
12
|
-
};
|
|
13
|
-
exports.LabelSide = {
|
|
14
|
-
left: 'left',
|
|
15
|
-
right: 'right',
|
|
16
|
-
};
|
|
17
|
-
exports.variants = {
|
|
18
|
-
[exports.Variant.kind]: {
|
|
19
|
-
[exports.Kind.primary]: styled_components_1.css `
|
|
20
|
-
--color-background: ${({ theme }) => theme.palette.controlFill};
|
|
21
|
-
--color-foreground: ${({ theme }) => theme.palette.controlAccent};
|
|
22
|
-
--color-active: ${({ theme }) => theme.palette.controlActiveFill};
|
|
23
|
-
--color-knob: ${({ theme }) => theme.palette.controlAccent};
|
|
24
|
-
|
|
25
|
-
&:disabled {
|
|
26
|
-
--color-background: ${({ theme }) => theme.palette.controlDisabledFill};
|
|
27
|
-
--color-foreground: ${({ theme }) => theme.palette.controlDisabledAccent};
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
|
-
[exports.Kind.secondary]: styled_components_1.css `
|
|
31
|
-
--color-background: ${({ theme }) => theme.palette.brandSecondary};
|
|
32
|
-
--color-foreground: ${({ theme }) => theme.palette.controlAccent};
|
|
33
|
-
--color-active: ${({ theme }) => theme.palette.controlActiveFill};
|
|
34
|
-
--color-knob: ${({ theme }) => theme.palette.controlAccent};
|
|
35
|
-
|
|
36
|
-
&:disabled {
|
|
37
|
-
--color-background: ${({ theme }) => theme.palette.controlDisabledFill};
|
|
38
|
-
--color-foreground: ${({ theme }) => theme.palette.controlDisabledAccent};
|
|
39
|
-
}
|
|
40
|
-
`,
|
|
41
|
-
},
|
|
42
|
-
[exports.Variant.labelSide]: {
|
|
43
|
-
[exports.LabelSide.left]: styled_components_1.css `
|
|
44
|
-
flex-direction: row;
|
|
45
|
-
`,
|
|
46
|
-
[exports.LabelSide.right]: styled_components_1.css `
|
|
47
|
-
flex-direction: row-reverse;
|
|
48
|
-
`,
|
|
49
|
-
},
|
|
50
|
-
};
|