@openfin/ui-library 0.1.3 → 0.1.4
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/README.md +9 -0
- package/dist/components/controls/Toggle/toggle.js +3 -3
- package/dist/components/input/TextInput/textInput.js +1 -1
- package/dist/components/layout/Box/box.js +6 -0
- package/dist/components/system/GlobalStyles/globalStyles.js +13 -10
- package/dist/components/system/ThemeProvider/index.d.ts +1 -0
- package/dist/components/system/ThemeProvider/index.js +1 -0
- package/dist/components/system/ThemeProvider/lib/constants.d.ts +0 -8
- package/dist/components/system/ThemeProvider/lib/constants.js +1 -16
- package/dist/components/system/ThemeProvider/lib/helpers.d.ts +6 -0
- package/dist/components/system/ThemeProvider/lib/helpers.js +9 -1
- package/dist/components/system/ThemeProvider/lib/mixins.d.ts +12 -0
- package/dist/components/system/ThemeProvider/lib/mixins.js +67 -0
- package/dist/components/system/ThemeProvider/lib/types.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,6 +204,15 @@ This triggers a Github Action to automatically build the latest version of the `
|
|
|
204
204
|
- useColorScheme
|
|
205
205
|
- useTheme
|
|
206
206
|
|
|
207
|
+
## [Mixins](./src/components/system/ThemeProvider/lib/mixins.ts)
|
|
208
|
+
|
|
209
|
+
CSS fragments that you can include in any styled component
|
|
210
|
+
|
|
211
|
+
- `${Mixins.noSelect}`
|
|
212
|
+
- `${Mixins.textOverflow}`
|
|
213
|
+
- `${Mixins.scrollbar.base}`
|
|
214
|
+
- `${Mixins.scrollbar.small}`
|
|
215
|
+
|
|
207
216
|
## Variants
|
|
208
217
|
|
|
209
218
|
### What are variants?
|
|
@@ -49,8 +49,8 @@ const InputContainer = styled_components_1.default(Box_1.Box) `
|
|
|
49
49
|
border-radius: calc(0.5 * var(--px-toggle));
|
|
50
50
|
|
|
51
51
|
background: ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.inputBg};
|
|
52
|
-
transition: background var(--
|
|
53
|
-
border-color var(
|
|
52
|
+
transition: background var(--openfin-ui-globalTransition),
|
|
53
|
+
border-color var(---openfin-ui-globalTransition);
|
|
54
54
|
|
|
55
55
|
&:focus-within {
|
|
56
56
|
border-color: ${({ theme }) => theme.palette.inputFocused};
|
|
@@ -67,7 +67,7 @@ const ToggleKnob = styled_components_1.default.button `
|
|
|
67
67
|
background: ${({ theme }) => theme.palette.inputColor};
|
|
68
68
|
border: none;
|
|
69
69
|
outline: none;
|
|
70
|
-
transition: left var(--
|
|
70
|
+
transition: left var(--openfin-ui-globalTransition);
|
|
71
71
|
pointer-events: none; /* Allow pass-thru for native input */
|
|
72
72
|
`;
|
|
73
73
|
const ToggleInput = styled_components_1.default(RawInput_1.RawInput) `
|
|
@@ -47,7 +47,7 @@ const StyledInputField = styled_components_1.default(RawInput_1.RawInput) `
|
|
|
47
47
|
color: ${({ theme }) => theme.palette.inputColor};
|
|
48
48
|
font-size: ${({ theme }) => theme.fontSize.base};
|
|
49
49
|
padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
|
|
50
|
-
transition: border-color var(--
|
|
50
|
+
transition: border-color var(--openfin-ui-globalTransition);
|
|
51
51
|
|
|
52
52
|
&:focus {
|
|
53
53
|
outline: 0;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Box = void 0;
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
const mixins_1 = require("../../system/ThemeProvider/lib/mixins");
|
|
8
9
|
const palette_1 = require("../../system/ThemeProvider/lib/palette");
|
|
9
10
|
/**
|
|
10
11
|
* ## BackgroundLevels
|
|
@@ -27,6 +28,11 @@ const BackgroundLevels = {
|
|
|
27
28
|
* - None of the child properties should be applied unless specified.
|
|
28
29
|
*/
|
|
29
30
|
exports.Box = styled_components_1.default.div `
|
|
31
|
+
/**
|
|
32
|
+
* Style Scrollbar for Boxes with overflow
|
|
33
|
+
*/
|
|
34
|
+
${mixins_1.Mixins.scrollbar.base}
|
|
35
|
+
|
|
30
36
|
display: ${({ display = 'flex' }) => display};
|
|
31
37
|
flex-direction: ${({ flexDirection = 'row' }) => flexDirection};
|
|
32
38
|
flex-wrap: ${({ flexWrap = 'nowrap' }) => flexWrap};
|
|
@@ -7,11 +7,14 @@ const helpers_1 = require("../ThemeProvider/lib/helpers");
|
|
|
7
7
|
exports.GlobalStyles = styled_components_1.createGlobalStyle `
|
|
8
8
|
/** -> Define Global CSS Vars */
|
|
9
9
|
:root {
|
|
10
|
-
--
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
--
|
|
10
|
+
--openfin-ui-globalBackground: ${({ theme }) => theme.palette.background1};
|
|
11
|
+
--openfin-ui-globalText: ${({ theme }) => theme.palette.textDefault};
|
|
12
|
+
--openfin-ui-globalPlaceholder: ${({ theme }) => theme.palette.inputPlaceholder};
|
|
13
|
+
--openfin-ui-globalTypography: ${constants_1.Typography.base};
|
|
14
|
+
--openfin-ui-globalTransition: ${({ theme }) => theme.transition.base};
|
|
15
|
+
|
|
16
|
+
/* Map over the palette keys and create variables out of them */
|
|
17
|
+
${helpers_1.getRootCssVars}
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/** -> @font-face Declaration */
|
|
@@ -32,19 +35,19 @@ exports.GlobalStyles = styled_components_1.createGlobalStyle `
|
|
|
32
35
|
/** -> Apply Global Styles */
|
|
33
36
|
:root,
|
|
34
37
|
body {
|
|
35
|
-
background: var(--
|
|
36
|
-
color: var(--
|
|
37
|
-
font: var(--
|
|
38
|
+
background: var(--openfin-ui-globalBackground);
|
|
39
|
+
color: var(--openfin-ui-globalText);
|
|
40
|
+
font: var(--openfin-ui-globalTypography);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
::placeholder {
|
|
41
|
-
color: var(--
|
|
44
|
+
color: var(--openfin-ui-globalPlaceholder);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/** -> Reduced Motion (Accessibility) */
|
|
45
48
|
@media (prefers-reduced-motion) {
|
|
46
49
|
:root {
|
|
47
|
-
--
|
|
50
|
+
--openfin-ui-globalTransition: ${({ theme }) => theme.transition.none};
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
`;
|
|
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./lib/constants"), exports);
|
|
14
14
|
__exportStar(require("./lib/helpers"), exports);
|
|
15
15
|
__exportStar(require("./lib/interface"), exports);
|
|
16
|
+
__exportStar(require("./lib/mixins"), exports);
|
|
16
17
|
__exportStar(require("./lib/palette"), exports);
|
|
17
18
|
__exportStar(require("./lib/types"), exports);
|
|
18
19
|
__exportStar(require("./themeProvider"), exports);
|
|
@@ -517,11 +517,3 @@ export declare const IconSize: {
|
|
|
517
517
|
readonly xxlarge: "32px";
|
|
518
518
|
readonly xxxlarge: "48px";
|
|
519
519
|
};
|
|
520
|
-
/**
|
|
521
|
-
* Mixins --
|
|
522
|
-
* Reusable utility fragments of CSS that make sense to express once (for consistency, maintainability).
|
|
523
|
-
*/
|
|
524
|
-
export declare const Mixins: {
|
|
525
|
-
readonly noSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
526
|
-
readonly textOverflow: import("styled-components").FlattenSimpleInterpolation;
|
|
527
|
-
};
|
|
@@ -19,9 +19,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
22
|
+
exports.IconSize = exports.IconSet = exports.Transition = exports.Typography = exports.LineHeight = exports.FontWeight = exports.FontSize = exports.FontStack = exports.Shadow = exports.Radius = exports.UnitPx = exports.Unit = exports.SizeName = exports.Size = exports.Color = void 0;
|
|
23
23
|
const RadixIcons = __importStar(require("@modulz/radix-icons"));
|
|
24
|
-
const styled_components_1 = require("styled-components");
|
|
25
24
|
const OpenFinIcons = __importStar(require("../../../elements/Icon/openfin"));
|
|
26
25
|
/**
|
|
27
26
|
* Color --
|
|
@@ -254,17 +253,3 @@ exports.IconSize = {
|
|
|
254
253
|
[exports.Size.xxlarge]: exports.UnitPx.xxxlarge,
|
|
255
254
|
[exports.Size.xxxlarge]: exports.UnitPx.xxxxlarge,
|
|
256
255
|
};
|
|
257
|
-
/**
|
|
258
|
-
* Mixins --
|
|
259
|
-
* Reusable utility fragments of CSS that make sense to express once (for consistency, maintainability).
|
|
260
|
-
*/
|
|
261
|
-
exports.Mixins = {
|
|
262
|
-
noSelect: styled_components_1.css `
|
|
263
|
-
user-select: none;
|
|
264
|
-
`,
|
|
265
|
-
textOverflow: styled_components_1.css `
|
|
266
|
-
white-space: nowrap;
|
|
267
|
-
overflow: hidden;
|
|
268
|
-
text-overflow: ellipsis;
|
|
269
|
-
`,
|
|
270
|
-
};
|
|
@@ -12,6 +12,12 @@ export declare type ComponentVariants = {
|
|
|
12
12
|
* @todo This needs to be typed better
|
|
13
13
|
*/
|
|
14
14
|
export declare const getVariantCSS: (variants: ComponentVariants, variantProp: string) => (props: StyledProps<any>) => any;
|
|
15
|
+
/**
|
|
16
|
+
* Build :root { --var } key value pairs from Palette
|
|
17
|
+
*/
|
|
18
|
+
export declare const getRootCssVars: ({ theme }: {
|
|
19
|
+
theme: DefaultTheme;
|
|
20
|
+
}) => string;
|
|
15
21
|
/**
|
|
16
22
|
* Lazy Load font-faces based on Theme Configuration
|
|
17
23
|
*/
|
|
@@ -3,9 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getStatusColor = exports.getFontFaces = exports.getVariantCSS = void 0;
|
|
6
|
+
exports.getStatusColor = exports.getFontFaces = exports.getRootCssVars = exports.getVariantCSS = void 0;
|
|
7
7
|
const font_face_base64_1 = __importDefault(require("./font-face-base64"));
|
|
8
8
|
const font_face_cdn_1 = __importDefault(require("./font-face-cdn"));
|
|
9
|
+
const palette_1 = require("./palette");
|
|
9
10
|
/**
|
|
10
11
|
* Get the CSS associated with a variant key
|
|
11
12
|
* @param variants -- Component variants data structure
|
|
@@ -16,6 +17,13 @@ const getVariantCSS = (variants, variantProp) => (props) => {
|
|
|
16
17
|
return variants[variantProp][props[variantProp]];
|
|
17
18
|
};
|
|
18
19
|
exports.getVariantCSS = getVariantCSS;
|
|
20
|
+
/**
|
|
21
|
+
* Build :root { --var } key value pairs from Palette
|
|
22
|
+
*/
|
|
23
|
+
const getRootCssVars = ({ theme }) => Object.keys(palette_1.Palette)
|
|
24
|
+
.map((key) => `--openfin-ui-${key}: ${theme.palette[key]};`)
|
|
25
|
+
.join('\n');
|
|
26
|
+
exports.getRootCssVars = getRootCssVars;
|
|
19
27
|
/**
|
|
20
28
|
* Lazy Load font-faces based on Theme Configuration
|
|
21
29
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mixins --
|
|
3
|
+
* Reusable utility fragments of CSS that make sense to express once (for consistency, maintainability).
|
|
4
|
+
*/
|
|
5
|
+
export declare const Mixins: {
|
|
6
|
+
readonly noSelect: import("styled-components").FlattenSimpleInterpolation;
|
|
7
|
+
readonly textOverflow: import("styled-components").FlattenSimpleInterpolation;
|
|
8
|
+
readonly scrollbar: {
|
|
9
|
+
readonly base: import("styled-components").FlattenSimpleInterpolation;
|
|
10
|
+
readonly small: import("styled-components").FlattenSimpleInterpolation;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Mixins = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
const styled_components_1 = require("styled-components");
|
|
6
|
+
/**
|
|
7
|
+
* Mixins
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Prevent User Selection
|
|
11
|
+
*/
|
|
12
|
+
const noSelect = styled_components_1.css `
|
|
13
|
+
user-select: none;
|
|
14
|
+
`;
|
|
15
|
+
/**
|
|
16
|
+
* Prevent Text from Wrapping and truncate with ellipsis
|
|
17
|
+
* when it overflows the parent container
|
|
18
|
+
*/
|
|
19
|
+
const textOverflow = styled_components_1.css `
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
`;
|
|
24
|
+
/**
|
|
25
|
+
* Scrollbar (4px)
|
|
26
|
+
* @link https://www.figma.com/file/0Y3pKZj0tJWuleF12h5Sua/Spatial---Components?node-id=2048%3A7477
|
|
27
|
+
*/
|
|
28
|
+
const scrollbar = styled_components_1.css `
|
|
29
|
+
&::-webkit-scrollbar {
|
|
30
|
+
width: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
31
|
+
height: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&::-webkit-scrollbar-track {
|
|
35
|
+
background: ${constants_1.Color.neutralGray};
|
|
36
|
+
border-radius: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
37
|
+
opacity: 0.8;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&::-webkit-scrollbar-thumb {
|
|
41
|
+
background: ${constants_1.Color.white};
|
|
42
|
+
width: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
43
|
+
height: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
44
|
+
border-radius: var(--scrollbarSize, ${constants_1.UnitPx.xsmall});
|
|
45
|
+
opacity: 0.8;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
/**
|
|
49
|
+
* Scrollbar Tiny (2px)
|
|
50
|
+
* Extends the regular scrollbar
|
|
51
|
+
*/
|
|
52
|
+
const scrollbarSmall = styled_components_1.css `
|
|
53
|
+
--scrollbarSize: 2px;
|
|
54
|
+
${scrollbar};
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* Mixins --
|
|
58
|
+
* Reusable utility fragments of CSS that make sense to express once (for consistency, maintainability).
|
|
59
|
+
*/
|
|
60
|
+
exports.Mixins = {
|
|
61
|
+
noSelect,
|
|
62
|
+
textOverflow,
|
|
63
|
+
scrollbar: {
|
|
64
|
+
[constants_1.Size.base]: scrollbar,
|
|
65
|
+
[constants_1.Size.small]: scrollbarSmall,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
@@ -15,11 +15,12 @@ export declare type TransitionType = keyof typeof Transition;
|
|
|
15
15
|
export declare type TypographyType = keyof typeof Typography;
|
|
16
16
|
export declare type UnitPxType = keyof typeof UnitPx;
|
|
17
17
|
export declare type UnitType = keyof typeof Unit;
|
|
18
|
-
export declare type PaletteType = Record<keyof typeof Palette, string>;
|
|
19
18
|
export declare type ThemeSet = {
|
|
20
19
|
light: DefaultTheme;
|
|
21
20
|
dark: DefaultTheme;
|
|
22
21
|
};
|
|
22
|
+
export declare type PaletteKeyType = keyof typeof Palette;
|
|
23
|
+
export declare type PaletteType = Record<keyof typeof Palette, string>;
|
|
23
24
|
export declare type ThemePaletteSet = {
|
|
24
25
|
light: {
|
|
25
26
|
palette: PaletteType;
|