reshaped 2.4.4 → 2.4.7
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/CHANGELOG.md +8 -0
- package/bundle.css +1 -1
- package/bundle.js +9 -9
- package/cli/theming/index.js +2 -2
- package/cli/theming/reshaped.config.js +3 -3
- package/components/Accordion/AccordionContent.js +3 -1
- package/components/Accordion/tests/Accordion.stories.js +3 -2
- package/components/Actionable/Actionable.js +4 -4
- package/components/Actionable/Actionable.module.css +1 -1
- package/components/Autocomplete/Autocomplete.js +8 -2
- package/components/Button/Button.js +1 -1
- package/components/Button/Button.module.css +1 -1
- package/components/Button/ButtonAligner.d.ts +4 -2
- package/components/Button/ButtonAligner.js +2 -8
- package/components/Checkbox/tests/Checkbox.stories.js +1 -1
- package/components/FormControl/FormControl.context.d.ts +53 -53
- package/components/MenuItem/MenuItem.js +1 -1
- package/components/MenuItem/MenuItem.module.css +1 -1
- package/components/MenuItem/MenuItemAligner.d.ts +2 -2
- package/components/MenuItem/MenuItemAligner.js +2 -4
- package/components/MenuItem/tests/MenuItem.stories.js +1 -1
- package/components/TextArea/TextArea.d.ts +5 -1
- package/components/TextArea/TextArea.js +3 -1
- package/components/TextArea/TextArea.module.css +1 -1
- package/components/TextArea/tests/TextArea.stories.d.ts +1 -0
- package/components/TextArea/tests/TextArea.stories.js +16 -0
- package/components/TextField/TextField.d.ts +5 -1
- package/components/TextField/TextField.js +3 -1
- package/components/TextField/TextField.module.css +1 -1
- package/components/TextField/tests/TextField.stories.d.ts +1 -0
- package/components/TextField/tests/TextField.stories.js +16 -0
- package/components/Toast/tests/Toast.stories.js +0 -1
- package/components/View/tests/View.stories.js +1 -1
- package/components/_private/Aligner/Aligner.d.ts +12 -0
- package/components/_private/Aligner/Aligner.js +18 -0
- package/components/_private/Aligner/Aligner.module.css +1 -0
- package/components/_private/Aligner/Aligner.types.d.ts +9 -0
- package/components/_private/Aligner/Aligner.types.js +1 -0
- package/components/_private/Aligner/index.d.ts +2 -0
- package/components/_private/Aligner/index.js +1 -0
- package/components/_private/Flyout/FlyoutTrigger.js +3 -12
- package/components/_private/Portal/Portal.d.ts +1 -1
- package/config/tailwind.js +2 -2
- package/package.json +26 -21
- package/themes/_generator/definitions/base.d.ts +3 -0
- package/themes/_generator/definitions/figma.d.ts +3 -0
- package/themes/_generator/definitions/reshaped.d.ts +3 -0
- package/{cli/theming → themes/_generator}/definitions/reshaped.js +5 -38
- package/themes/_generator/definitions/slate.d.ts +3 -0
- package/themes/_generator/tests/themes.stories.d.ts +2 -1
- package/themes/_generator/tests/themes.stories.js +75 -2
- package/themes/_generator/utilities/generateColors.d.ts +20 -0
- package/themes/_generator/utilities/generateColors.js +422 -0
- package/themes/figma/theme.css +1 -1
- package/themes/index.d.ts +11 -0
- package/themes/index.js +8 -0
- package/themes/reshaped/theme.css +1 -1
- package/themes/slate/theme.css +1 -1
- package/types/global.d.ts +1 -1
- package/cli/theming/definitions/base.d.ts +0 -3
- package/cli/theming/definitions/figma.d.ts +0 -3
- package/cli/theming/definitions/reshaped.d.ts +0 -3
- package/cli/theming/definitions/slate.d.ts +0 -3
- package/config/next.d.ts +0 -4
- package/config/next.js +0 -22
- /package/{cli/theming → themes/_generator}/definitions/base.js +0 -0
- /package/{cli/theming → themes/_generator}/definitions/figma.js +0 -0
- /package/{cli/theming → themes/_generator}/definitions/slate.js +0 -0
@@ -1 +1 @@
|
|
1
|
-
.root{background:var(--rs-color-background-elevation-base);border:1px solid var(--rs-color-border-neutral);display:flex;overflow:hidden;padding:calc(var(--rs-
|
1
|
+
.root{--rs-p-v:var(--rs-unit-x1);--rs-p-h:calc(var(--rs-unit-x1) + var(--rs-text-field-gap));background:var(--rs-color-background-elevation-base);border:1px solid var(--rs-color-border-neutral);display:flex;overflow:hidden;padding:calc(var(--rs-p-v) - 1px);position:relative;z-index:0}.root:focus-within{border-color:var(--rs-color-border-primary);box-shadow:0 0 0 1px var(--rs-color-border-primary)}.input{background:none;border:none;box-sizing:border-box;color:var(--rs-color-foreground-neutral);flex-grow:1;font-family:var(--rs-font-family-body);font-weight:var(--rs-font-weight-regular);margin:calc(var(--rs-unit-x1) * -1) 0;outline:none;padding:0 var(--rs-text-field-gap);position:relative;width:100%;z-index:1}.input:-webkit-autofill{-webkit-text-fill-color:var(--rs-color-foreground-neutral);-webkit-background-clip:text}.affix,.icon,.slot{align-items:center;display:flex;flex-shrink:0;position:relative;z-index:5}.icon{pointer-events:none}.affix{color:var(--rs-color-foreground-neutral-faded)}.attachment{align-items:center;display:flex}.attachment--position-start .affix,.attachment--position-start .icon{margin-inline-end:var(--rs-unit-x1);padding-inline-start:var(--rs-text-field-gap)}.attachment--position-start .affix{border-inline-end:1px solid var(--rs-color-border-neutral-faded);padding-inline-end:calc(var(--rs-text-field-gap) + var(--rs-unit-x1))}.attachment--position-end .affix,.attachment--position-end .icon{margin-inline-start:var(--rs-unit-x1);padding-inline-end:var(--rs-text-field-gap)}.attachment--position-end .affix{border-inline-start:1px solid var(--rs-color-border-neutral-faded);padding-inline-start:calc(var(--rs-text-field-gap) + var(--rs-unit-x1))}.root.--disabled{background:var(--rs-color-background-disabled-faded);border-color:var(--rs-color-border-disabled)}.root.--disabled,.root.--disabled .input{color:var(--rs-color-foreground-disabled);cursor:not-allowed}.--size-medium{--rs-text-field-gap:var(--rs-unit-x1);border-radius:var(--rs-unit-radius-small)}.--size-medium .input{padding-bottom:var(--rs-unit-x2);padding-top:var(--rs-unit-x2)}.--size-medium .affix,.--size-medium .input{font-size:var(--rs-font-size-body-3);line-height:var(--rs-line-height-body-3)}.--size-large{--rs-text-field-gap:var(--rs-unit-x2);border-radius:var(--rs-unit-radius-medium)}.--size-large .input{padding-bottom:var(--rs-unit-x3);padding-top:var(--rs-unit-x3)}.--size-large .affix,.--size-large .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}.--size-xlarge{--rs-text-field-gap:var(--rs-unit-x3);border-radius:var(--rs-unit-radius-medium)}.--size-xlarge .input{padding-bottom:var(--rs-unit-x4);padding-top:var(--rs-unit-x4)}.--size-xlarge .affix,.--size-xlarge .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}.root.--variant-faded{background:var(--rs-color-background-neutral-faded);border-color:transparent}.root.--variant-faded:focus-within{border-color:var(--rs-color-border-primary)}.root.--variant-headless{background:transparent;border-color:transparent}.root.--variant-headless.--status-error,.root.--variant-headless.--status-error:focus-within,.root.--variant-headless:focus-within{border-color:transparent;box-shadow:none}.root.--status-error{border-color:var(--rs-color-border-critical)}.root.--status-error:focus-within{border-color:var(--rs-color-border-primary)}@media (max-width:659px) and (hover:none){.input{font-size:var(--rs-font-size-body-2)!important}}@media (min-width:660px){.--size-medium--m{--rs-text-field-gap:var(--rs-unit-x1);border-radius:var(--rs-unit-radius-small)}.--size-medium--m .input{padding-bottom:var(--rs-unit-x2);padding-top:var(--rs-unit-x2)}.--size-medium--m .affix,.--size-medium--m .input{font-size:var(--rs-font-size-body-3);line-height:var(--rs-line-height-body-3)}.--size-large--m{--rs-text-field-gap:var(--rs-unit-x2);border-radius:var(--rs-unit-radius-medium)}.--size-large--m .input{padding-bottom:var(--rs-unit-x3);padding-top:var(--rs-unit-x3)}.--size-large--m .affix,.--size-large--m .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}.--size-xlarge--m{--rs-text-field-gap:var(--rs-unit-x3);border-radius:var(--rs-unit-radius-medium)}.--size-xlarge--m .input{padding-bottom:var(--rs-unit-x4);padding-top:var(--rs-unit-x4)}.--size-xlarge--m .affix,.--size-xlarge--m .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}}@media (min-width:900px){.--size-medium--l{--rs-text-field-gap:var(--rs-unit-x1);border-radius:var(--rs-unit-radius-small)}.--size-medium--l .input{padding-bottom:var(--rs-unit-x2);padding-top:var(--rs-unit-x2)}.--size-medium--l .affix,.--size-medium--l .input{font-size:var(--rs-font-size-body-3);line-height:var(--rs-line-height-body-3)}.--size-large--l{--rs-text-field-gap:var(--rs-unit-x2);border-radius:var(--rs-unit-radius-medium)}.--size-large--l .input{padding-bottom:var(--rs-unit-x3);padding-top:var(--rs-unit-x3)}.--size-large--l .affix,.--size-large--l .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}.--size-xlarge--l{--rs-text-field-gap:var(--rs-unit-x3);border-radius:var(--rs-unit-radius-medium)}.--size-xlarge--l .input{padding-bottom:var(--rs-unit-x4);padding-top:var(--rs-unit-x4)}.--size-xlarge--l .affix,.--size-xlarge--l .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}}@media (min-width:1280px){.--size-medium--xl{--rs-text-field-gap:var(--rs-unit-x1);border-radius:var(--rs-unit-radius-small)}.--size-medium--xl .input{padding-bottom:var(--rs-unit-x2);padding-top:var(--rs-unit-x2)}.--size-medium--xl .affix,.--size-medium--xl .input{font-size:var(--rs-font-size-body-3);line-height:var(--rs-line-height-body-3)}.--size-large--xl{--rs-text-field-gap:var(--rs-unit-x2);border-radius:var(--rs-unit-radius-medium)}.--size-large--xl .input{padding-bottom:var(--rs-unit-x3);padding-top:var(--rs-unit-x3)}.--size-large--xl .affix,.--size-large--xl .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}.--size-xlarge--xl{--rs-text-field-gap:var(--rs-unit-x3);border-radius:var(--rs-unit-radius-medium)}.--size-xlarge--xl .input{padding-bottom:var(--rs-unit-x4);padding-top:var(--rs-unit-x4)}.--size-xlarge--xl .affix,.--size-xlarge--xl .input{font-size:var(--rs-font-size-body-2);line-height:var(--rs-line-height-body-2)}}
|
@@ -12,3 +12,4 @@ export declare const size: () => React.JSX.Element;
|
|
12
12
|
export declare const affixes: () => React.JSX.Element;
|
13
13
|
export declare const slots: () => React.JSX.Element;
|
14
14
|
export declare const formControl: () => React.JSX.Element;
|
15
|
+
export declare const aligner: () => React.JSX.Element;
|
@@ -3,6 +3,9 @@ import { Example, Placeholder } from "../../../utilities/storybook/index.js";
|
|
3
3
|
import IconZap from "../../../icons/Zap.js";
|
4
4
|
import TextField from "../index.js";
|
5
5
|
import FormControl from "../../FormControl/index.js";
|
6
|
+
import View from "../../View/index.js";
|
7
|
+
import Text from "../../Text/index.js";
|
8
|
+
import Button from "../../Button/index.js";
|
6
9
|
export default { title: "Components/TextField" };
|
7
10
|
export const value = () => (<Example>
|
8
11
|
<Example.Item title="no value, placeholder">
|
@@ -98,3 +101,16 @@ export const formControl = () => (<Example>
|
|
98
101
|
</FormControl>
|
99
102
|
</Example.Item>
|
100
103
|
</Example>);
|
104
|
+
export const aligner = () => (<Example>
|
105
|
+
<Example.Item title="aligner">
|
106
|
+
<View gap={2}>
|
107
|
+
<Text variant="featured-2">What problem are you trying to solve?</Text>
|
108
|
+
<TextField.Aligner>
|
109
|
+
<TextField variant="headless" placeholder="Try something like 'I have a job'" name="description"/>
|
110
|
+
</TextField.Aligner>
|
111
|
+
<View.Item>
|
112
|
+
<Button>Next</Button>
|
113
|
+
</View.Item>
|
114
|
+
</View>
|
115
|
+
</Example.Item>
|
116
|
+
</Example>);
|
@@ -501,7 +501,7 @@ export const border = () => (<Example>
|
|
501
501
|
</Example.Item>
|
502
502
|
|
503
503
|
<Example.Item title="border: positive-faded">
|
504
|
-
<View borderColor="positive" padding={4}>
|
504
|
+
<View borderColor="positive-faded" padding={4}>
|
505
505
|
Content
|
506
506
|
</View>
|
507
507
|
</Example.Item>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/**
|
2
|
+
* Aligner is a utility used across multiple components to apply
|
3
|
+
* negative margin based on the component padding to align its text content
|
4
|
+
* visually with the rest of the page
|
5
|
+
*
|
6
|
+
* It relies on using a data-rs-aligner-target attribute in other components and works based
|
7
|
+
* on the --rs-p, --rs-p-v and --rs-p-h css variables
|
8
|
+
*/
|
9
|
+
import React from "react";
|
10
|
+
import type * as T from "./Aligner.types";
|
11
|
+
declare const Aligner: (props: T.Props) => React.JSX.Element;
|
12
|
+
export default Aligner;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Aligner is a utility used across multiple components to apply
|
3
|
+
* negative margin based on the component padding to align its text content
|
4
|
+
* visually with the rest of the page
|
5
|
+
*
|
6
|
+
* It relies on using a data-rs-aligner-target attribute in other components and works based
|
7
|
+
* on the --rs-p, --rs-p-v and --rs-p-h css variables
|
8
|
+
*/
|
9
|
+
import React from "react";
|
10
|
+
import { classNames } from "../../../utilities/helpers.js";
|
11
|
+
import s from "./Aligner.module.css";
|
12
|
+
const Aligner = (props) => {
|
13
|
+
const { side: passedSide = "all", children, className, attributes } = props;
|
14
|
+
const sides = typeof passedSide === "string" ? [passedSide] : passedSide;
|
15
|
+
const rootClassNames = classNames(s.root, sides.map((side) => s[`--side-${side}`]), className);
|
16
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: rootClassNames }), children));
|
17
|
+
};
|
18
|
+
export default Aligner;
|
@@ -0,0 +1 @@
|
|
1
|
+
.root [data-rs-aligner-target]{--rs-aligner-p-h:var(--rs-p-h,var(--rs-p));--rs-aligner-p-v:var(--rs-p-v,var(--rs-p))}.root.--side-all [data-rs-aligner-target]{margin:calc(var(--rs-aligner-p-v) * -1) calc(var(--rs-aligner-p-h) * -1)}.root.--side-inline [data-rs-aligner-target],.root.--side-start [data-rs-aligner-target]{margin-inline-start:calc(var(--rs-aligner-p-h) * -1)}.root.--side-end [data-rs-aligner-target],.root.--side-inline [data-rs-aligner-target]{margin-inline-end:calc(var(--rs-aligner-p-h) * -1)}.root.--side-block [data-rs-aligner-target],.root.--side-top [data-rs-aligner-target]{margin-block-start:calc(var(--rs-aligner-p-v) * -1)}.root.--side-block [data-rs-aligner-target],.root.--side-bottom [data-rs-aligner-target]{margin-block-end:calc(var(--rs-aligner-p-v) * -1)}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import type * as G from "../../../types/global";
|
2
|
+
type Side = "start" | "end" | "top" | "bottom" | "inline" | "block" | "all";
|
3
|
+
export type Props = {
|
4
|
+
children: React.ReactElement;
|
5
|
+
side?: Side | Side[];
|
6
|
+
className?: G.ClassName;
|
7
|
+
attributes?: G.Attributes<"div", Props>;
|
8
|
+
};
|
9
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from "./Aligner.js";
|
@@ -1,30 +1,21 @@
|
|
1
1
|
"use client";
|
2
2
|
import React from "react";
|
3
|
-
import useHotkeys from "../../../hooks/useHotkeys.js";
|
4
|
-
import * as keys from "../../../constants/keys.js";
|
5
3
|
import { useFlyoutContext } from "./Flyout.context.js";
|
6
4
|
const FlyoutTrigger = (props) => {
|
7
5
|
const { children } = props;
|
8
|
-
const { id, triggerElRef, triggerType, flyout, handleFocus, handleBlur, handleMouseEnter, handleMouseLeave, handleClick,
|
9
|
-
useHotkeys({
|
10
|
-
[`${keys.UP},${keys.DOWN}`]: () => {
|
11
|
-
if (flyout.status !== "idle")
|
12
|
-
return;
|
13
|
-
handleOpen();
|
14
|
-
},
|
15
|
-
}, [handleOpen, flyout.status], { ref: triggerElRef });
|
6
|
+
const { id, triggerElRef, triggerType, flyout, handleFocus, handleBlur, handleMouseEnter, handleMouseLeave, handleClick, trapFocusMode, } = useFlyoutContext();
|
16
7
|
let childrenAttributes = {
|
17
8
|
onBlur: handleBlur,
|
18
9
|
ref: triggerElRef,
|
19
10
|
};
|
20
|
-
if (triggerType === "click") {
|
11
|
+
if (triggerType === "click" || trapFocusMode === "action-menu") {
|
21
12
|
childrenAttributes.onClick = handleClick;
|
22
13
|
}
|
23
14
|
if (triggerType === "hover") {
|
24
15
|
childrenAttributes.onMouseEnter = handleMouseEnter;
|
25
16
|
childrenAttributes.onMouseLeave = handleMouseLeave;
|
26
17
|
}
|
27
|
-
if (triggerType === "hover" || triggerType === "focus") {
|
18
|
+
if ((triggerType === "hover" && trapFocusMode !== "action-menu") || triggerType === "focus") {
|
28
19
|
childrenAttributes.onFocus = handleFocus;
|
29
20
|
childrenAttributes["aria-describedby"] = id;
|
30
21
|
}
|
@@ -6,7 +6,7 @@ export declare const usePortalScope: () => T.Context;
|
|
6
6
|
* That gives Portal time to receive scope on first render
|
7
7
|
*/
|
8
8
|
declare const Portal: {
|
9
|
-
(props: T.Props):
|
9
|
+
(props: T.Props): any;
|
10
10
|
Scope: typeof PortalScope;
|
11
11
|
};
|
12
12
|
declare function PortalScope<T extends HTMLElement>(props: T.ScopeProps<T>): React.JSX.Element;
|
package/config/tailwind.js
CHANGED
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.getTheme = void 0;
|
7
|
-
const reshaped_1 = __importDefault(require("../
|
8
|
-
const base_1 = __importDefault(require("../
|
7
|
+
const reshaped_1 = __importDefault(require("../themes/_generator/definitions/reshaped"));
|
8
|
+
const base_1 = __importDefault(require("../themes/_generator/definitions/base"));
|
9
9
|
const string_1 = require("../utilities/string");
|
10
10
|
const color_1 = require("../utilities/color");
|
11
11
|
const mergeDefinitions_1 = __importDefault(require("../themes/_generator/utilities/mergeDefinitions"));
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "reshaped",
|
3
3
|
"description": "Professionally crafted design system in React & Figma for building products of any scale and complexity",
|
4
|
-
"version": "2.4.
|
4
|
+
"version": "2.4.7",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
6
6
|
"email": "hello@reshaped.so",
|
7
7
|
"homepage": "https://reshaped.so",
|
@@ -80,19 +80,19 @@
|
|
80
80
|
],
|
81
81
|
"devDependencies": {
|
82
82
|
"@size-limit/preset-big-lib": "9.0.0",
|
83
|
-
"@storybook/addon-a11y": "7.4.
|
84
|
-
"@storybook/react": "7.4.
|
85
|
-
"@storybook/react-vite": "7.4.
|
86
|
-
"@testing-library/jest-dom": "6.1.
|
83
|
+
"@storybook/addon-a11y": "7.4.6",
|
84
|
+
"@storybook/react": "7.4.6",
|
85
|
+
"@storybook/react-vite": "7.4.6",
|
86
|
+
"@testing-library/jest-dom": "6.1.4",
|
87
87
|
"@testing-library/react": "14.0.0",
|
88
|
-
"@testing-library/user-event": "14.
|
88
|
+
"@testing-library/user-event": "14.5.1",
|
89
89
|
"@types/events": "3.0.0",
|
90
|
-
"@types/jest": "29.5.
|
91
|
-
"@types/node": "20.6
|
92
|
-
"@types/react": "18.2.
|
93
|
-
"@types/react-dom": "18.2.
|
94
|
-
"@typescript-eslint/eslint-plugin": "6.
|
95
|
-
"@typescript-eslint/parser": "6.
|
90
|
+
"@types/jest": "29.5.5",
|
91
|
+
"@types/node": "20.8.6",
|
92
|
+
"@types/react": "18.2.28",
|
93
|
+
"@types/react-dom": "18.2.13",
|
94
|
+
"@typescript-eslint/eslint-plugin": "6.7.5",
|
95
|
+
"@typescript-eslint/parser": "6.7.5",
|
96
96
|
"@vitejs/plugin-react": "4.0.4",
|
97
97
|
"chromatic": "7.1.0",
|
98
98
|
"eslint": "8.49.0",
|
@@ -104,11 +104,11 @@
|
|
104
104
|
"eslint-plugin-react": "7.33.2",
|
105
105
|
"eslint-plugin-react-hooks": "4.6.0",
|
106
106
|
"identity-obj-proxy": "3.0.0",
|
107
|
-
"jest": "29.
|
108
|
-
"jest-environment-jsdom": "29.
|
107
|
+
"jest": "29.7.0",
|
108
|
+
"jest-environment-jsdom": "29.7.0",
|
109
109
|
"jest-matchmedia-mock": "1.1.0",
|
110
|
-
"lefthook": "1.
|
111
|
-
"postcss": "8.4.
|
110
|
+
"lefthook": "1.5.2",
|
111
|
+
"postcss": "8.4.31",
|
112
112
|
"postcss-cli": "10.1.0",
|
113
113
|
"postcss-each": "1.1.0",
|
114
114
|
"postcss-import": "15.1.0",
|
@@ -118,7 +118,7 @@
|
|
118
118
|
"react-dom": "18.2.0",
|
119
119
|
"resolve-tspaths": "0.8.15",
|
120
120
|
"size-limit": "9.0.0",
|
121
|
-
"storybook": "7.4.
|
121
|
+
"storybook": "7.4.6",
|
122
122
|
"stylelint": "15.10.3",
|
123
123
|
"stylelint-config-prettier": "9.0.5",
|
124
124
|
"stylelint-config-standard": "34.0.0",
|
@@ -144,18 +144,23 @@
|
|
144
144
|
},
|
145
145
|
"size-limit": [
|
146
146
|
{
|
147
|
-
"name": "JS",
|
147
|
+
"name": "Library / JS",
|
148
148
|
"path": "dist/bundle.js",
|
149
149
|
"webpack": false
|
150
150
|
},
|
151
151
|
{
|
152
|
-
"name": "CSS",
|
152
|
+
"name": "Library / CSS",
|
153
153
|
"path": "dist/bundle.css",
|
154
154
|
"webpack": false
|
155
155
|
},
|
156
156
|
{
|
157
|
-
"name": "
|
158
|
-
"path": "dist/
|
157
|
+
"name": "Theming / JS",
|
158
|
+
"path": "dist/tests/themingWithoutDefinition.js",
|
159
|
+
"webpack": true
|
160
|
+
},
|
161
|
+
{
|
162
|
+
"name": "Theming with a default theme definition / JS",
|
163
|
+
"path": "dist/tests/themingWithDefinition.js",
|
159
164
|
"webpack": true
|
160
165
|
}
|
161
166
|
],
|
@@ -1,5 +1,9 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const generateColors_1 = __importDefault(require("../utilities/generateColors"));
|
3
7
|
const theme = {
|
4
8
|
fontFamily: {
|
5
9
|
title: {
|
@@ -101,44 +105,7 @@ const theme = {
|
|
101
105
|
radiusMedium: { px: 8 },
|
102
106
|
radiusLarge: { px: 12 },
|
103
107
|
},
|
104
|
-
color:
|
105
|
-
foregroundNeutral: { hex: "#14171F", hexDark: "#EFF0F1" },
|
106
|
-
foregroundNeutralFaded: { hex: "#4D5874", hexDark: "#C2C8D6" },
|
107
|
-
foregroundDisabled: { hex: "#C7CDDB", hexDark: "#404A63" },
|
108
|
-
foregroundPrimary: { hex: "#4D4BE7", hexDark: "#9D9CF7" },
|
109
|
-
foregroundPositive: { hex: "#05751F", hexDark: "#03AB5F" },
|
110
|
-
foregroundCritical: { hex: "#CB101D", hexDark: "#EB6666" },
|
111
|
-
backgroundNeutral: { hex: "#DFE2EA", hexDark: "#384056" },
|
112
|
-
backgroundNeutralFaded: { hex: "#F3F4F6", hexDark: "#242838" },
|
113
|
-
backgroundNeutralHighlighted: { hex: "#D4D8E3", hexDark: "#404A63" },
|
114
|
-
backgroundDisabled: { hex: "#ECEEF3", hexDark: "#1C202B" },
|
115
|
-
backgroundDisabledFaded: { hex: "#F4F5F7", hexDark: "#161922" },
|
116
|
-
backgroundPrimary: { hex: "#5A58F2", hexDark: "#5250F2" },
|
117
|
-
backgroundPrimaryHighlighted: { hex: "#6d6bf5", hexDark: "#5f5df4" },
|
118
|
-
backgroundPrimaryFaded: { hex: "#EDECFD", hexDark: "#24254C" },
|
119
|
-
backgroundPositive: { hex: "#118850", hexDark: "#06743F" },
|
120
|
-
backgroundPositiveFaded: { hex: "#EBFEF6", hexDark: "#0F2921" },
|
121
|
-
backgroundPositiveHighlighted: { hex: "#009950", hexDark: "#008545" },
|
122
|
-
backgroundCritical: { hex: "#E22C2C", hexDark: "#AB1717" },
|
123
|
-
backgroundCriticalFaded: { hex: "#FEF1F2", hexDark: "#2F1E1F" },
|
124
|
-
backgroundCriticalHighlighted: { hex: "#eb4747", hexDark: "#c11515" },
|
125
|
-
borderNeutral: { hex: "#BBC1D3", hexDark: "#49536F" },
|
126
|
-
borderNeutralFaded: { hex: "#DFE2EA", hexDark: "#313649" },
|
127
|
-
borderDisabled: { hex: "#DFE2EA", hexDark: "#242938" },
|
128
|
-
borderPrimary: { hex: "#4D4BE7", hexDark: "#7D7BF4" },
|
129
|
-
borderPrimaryFaded: { hex: "#D7D5FB", hexDark: "#2E3160" },
|
130
|
-
borderPositive: { hex: "#05751F", hexDark: "#03A059" },
|
131
|
-
borderPositiveFaded: { hex: "#CDEDD5", hexDark: "#163C30" },
|
132
|
-
borderCritical: { hex: "#CB101D", hexDark: "#E95454" },
|
133
|
-
borderCriticalFaded: { hex: "#FBD5D8", hexDark: "#412A2B" },
|
134
|
-
backgroundPage: { hex: "#FFFFFF", hexDark: "#0D1117" },
|
135
|
-
backgroundPageFaded: { hex: "#FAFAFA", hexDark: "#0F131A" },
|
136
|
-
backgroundElevationBase: { hex: "#FFFFFF", hexDark: "#14181f" },
|
137
|
-
backgroundElevationRaised: { hex: "#FFFFFF", hexDark: "#181D25" },
|
138
|
-
backgroundElevationOverlay: { hex: "#FFFFFF", hexDark: "#1C212B" },
|
139
|
-
black: { hex: "#000000" },
|
140
|
-
white: { hex: "#FFFFFF" },
|
141
|
-
},
|
108
|
+
color: (0, generateColors_1.default)(),
|
142
109
|
duration: {
|
143
110
|
fast: { ms: 200 },
|
144
111
|
medium: { ms: 300 },
|
@@ -1,8 +1,13 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Example } from "../../../utilities/storybook/index.js";
|
3
|
+
import View from "../../../components/View/index.js";
|
3
4
|
import Button from "../../../components/Button/index.js";
|
5
|
+
import Badge from "../../../components/Badge/index.js";
|
6
|
+
import Alert from "../../../components/Alert/index.js";
|
7
|
+
import Card from "../../../components/Card/index.js";
|
8
|
+
import DropdownMenu from "../../../components/DropdownMenu/index.js";
|
4
9
|
import Theme from "../../../components/Theme/index.js";
|
5
|
-
import { getThemeCSS } from "../../index.js";
|
10
|
+
import { getThemeCSS, generateThemeColors, baseThemeDefinition } from "../../index.js";
|
6
11
|
export default { title: "Themes" };
|
7
12
|
const css = getThemeCSS("green", {
|
8
13
|
color: {
|
@@ -16,7 +21,64 @@ const css2 = getThemeCSS("peach", {
|
|
16
21
|
backgroundPrimaryHighlighted: { hex: "#ffbe76" },
|
17
22
|
},
|
18
23
|
});
|
19
|
-
|
24
|
+
const cssGenerated = getThemeCSS("generated", Object.assign(Object.assign({}, baseThemeDefinition), { color: generateThemeColors({ primary: "#2563eb" }) }));
|
25
|
+
const componentExamples = (<View gap={4}>
|
26
|
+
<View gap={2} direction="row">
|
27
|
+
<Button color="primary">Primary button</Button>
|
28
|
+
<Button color="critical">Primary button</Button>
|
29
|
+
<Button color="positive">Primary button</Button>
|
30
|
+
<Button color="neutral">Primary button</Button>
|
31
|
+
</View>
|
32
|
+
<View gap={2} direction="row">
|
33
|
+
<Button color="primary" variant="outline">
|
34
|
+
Primary button
|
35
|
+
</Button>
|
36
|
+
<Button color="critical" variant="outline">
|
37
|
+
Primary button
|
38
|
+
</Button>
|
39
|
+
<Button color="positive" variant="outline">
|
40
|
+
Primary button
|
41
|
+
</Button>
|
42
|
+
<Button color="neutral" variant="outline">
|
43
|
+
Primary button
|
44
|
+
</Button>
|
45
|
+
</View>
|
46
|
+
<View direction="row" gap={4}>
|
47
|
+
<View.Item columns={6}>
|
48
|
+
<Alert color="primary">Primary</Alert>
|
49
|
+
</View.Item>
|
50
|
+
<View.Item columns={6}>
|
51
|
+
<Alert color="critical">Critical</Alert>
|
52
|
+
</View.Item>
|
53
|
+
<View.Item columns={6}>
|
54
|
+
<Alert color="positive">Positive</Alert>
|
55
|
+
</View.Item>
|
56
|
+
<View.Item columns={6}>
|
57
|
+
<Alert color="neutral">Neutral</Alert>
|
58
|
+
</View.Item>
|
59
|
+
<View.Item columns={6}>
|
60
|
+
<Card>
|
61
|
+
<View gap={2} align="start">
|
62
|
+
<Badge variant="outline" color="primary">
|
63
|
+
Badge
|
64
|
+
</Badge>
|
65
|
+
<DropdownMenu>
|
66
|
+
<DropdownMenu.Trigger>
|
67
|
+
{(attributes) => (<Button variant="faded" attributes={attributes}>
|
68
|
+
Menu
|
69
|
+
</Button>)}
|
70
|
+
</DropdownMenu.Trigger>
|
71
|
+
<DropdownMenu.Content>
|
72
|
+
<DropdownMenu.Item>Item 1</DropdownMenu.Item>
|
73
|
+
<DropdownMenu.Item>Item 1</DropdownMenu.Item>
|
74
|
+
</DropdownMenu.Content>
|
75
|
+
</DropdownMenu>
|
76
|
+
</View>
|
77
|
+
</Card>
|
78
|
+
</View.Item>
|
79
|
+
</View>
|
80
|
+
</View>);
|
81
|
+
export const base = () => (<Example>
|
20
82
|
<Example.Item title="custom runtime theme">
|
21
83
|
<style>{css}</style>
|
22
84
|
<Theme name="green">
|
@@ -30,3 +92,14 @@ export const behavior = () => (<Example>
|
|
30
92
|
</Theme>
|
31
93
|
</Example.Item>
|
32
94
|
</Example>);
|
95
|
+
export const generation = () => (<Example>
|
96
|
+
<Example.Item title="base">
|
97
|
+
<style>{cssGenerated}</style>
|
98
|
+
<View gap={4}>
|
99
|
+
<View.Item>Generated theme</View.Item>
|
100
|
+
<Theme name="generated">{componentExamples}</Theme>
|
101
|
+
{/* <View.Item>Reshaped theme</View.Item> */}
|
102
|
+
{/* <Theme name="reshaped">{componentExamples}</Theme> */}
|
103
|
+
</View>
|
104
|
+
</Example.Item>
|
105
|
+
</Example>);
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* Some of the color conversion utilities are taken from https://github.com/hsluv/hsluv-javascript
|
3
|
+
* They have been rewritten for easier color transformations in the theme generation case
|
4
|
+
*/
|
5
|
+
type RgbColor = {
|
6
|
+
r: number;
|
7
|
+
g: number;
|
8
|
+
b: number;
|
9
|
+
};
|
10
|
+
export declare function hexToRgb(hex: string): RgbColor;
|
11
|
+
export declare function getRgbLuminance({ r, g, b }: RgbColor): number;
|
12
|
+
declare const generate: (args?: {
|
13
|
+
primary?: string;
|
14
|
+
critical?: string;
|
15
|
+
positive?: string;
|
16
|
+
neutral?: string;
|
17
|
+
}) => Record<import("../tokens/color/color.types").Name, import("../tokens/color/color.types").Token> & {
|
18
|
+
[tokenName: string]: import("../tokens/color/color.types").Token;
|
19
|
+
};
|
20
|
+
export default generate;
|