@nicolassancho/storybook-core 3.0.13 → 3.1.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/README.md +5 -1
- package/dist/components/Atoms/Button/Button.js +3 -3
- package/dist/components/Atoms/SearchInput/SearchInput.js +1 -1
- package/dist/components/Molecules/CartIcon/CartIcon.js +2 -2
- package/dist/components/Molecules/ProductCard/ProductCard.js +1 -1
- package/dist/components/Organisms/Header/Header.js +1 -1
- package/dist/styles/theme.css +96 -46
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ documented in Storybook. It is published to npm as `@nicolassancho/storybook-cor
|
|
|
24
24
|
plug in your framework.
|
|
25
25
|
- **Design tokens, not compiled CSS.** Colors, font sizes and breakpoints ship as a Tailwind v4
|
|
26
26
|
`@theme` file, and your app's Tailwind generates the classes.
|
|
27
|
+
- **Light and dark themes.** The dark theme follows the operating system, a `data-theme` attribute
|
|
28
|
+
on `<html>` overrides it, and every story is checked with axe and its `play` test in both themes.
|
|
27
29
|
- **Typed and documented.** TypeScript strict, every prop documented in JSDoc, and interaction
|
|
28
30
|
tests written as Storybook `play` functions.
|
|
29
31
|
|
|
@@ -41,6 +43,8 @@ Storybook.
|
|
|
41
43
|
|
|
42
44
|

|
|
43
45
|
|
|
46
|
+

|
|
47
|
+
|
|
44
48
|
## Using the library
|
|
45
49
|
|
|
46
50
|
Install the package, then add the design tokens and the source scan to your Tailwind v4 stylesheet:
|
|
@@ -74,7 +78,7 @@ The full guide (install, links and images, the Next.js App Router) is the **Cons
|
|
|
74
78
|
```bash
|
|
75
79
|
npm install # also builds the library (the `prepare` script)
|
|
76
80
|
npm run storybook # dev server on http://localhost:6006
|
|
77
|
-
npm test # runs every story in headless Chromium, with axe and the play tests
|
|
81
|
+
npm test # runs every story in headless Chromium, in both themes, with axe and the play tests
|
|
78
82
|
npm run build # compiles the library to dist/
|
|
79
83
|
```
|
|
80
84
|
|
|
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { tv } from "tailwind-variants";
|
|
14
14
|
const buttonStyles = tv({
|
|
15
|
-
base: "font-bold
|
|
15
|
+
base: "font-bold inline-flex items-center focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-surface",
|
|
16
16
|
variants: {
|
|
17
17
|
variant: {
|
|
18
|
-
primary: "rounded-sm bg-primary text-
|
|
19
|
-
secondary: "rounded-sm bg-secondary text-
|
|
18
|
+
primary: "rounded-sm bg-primary text-on-primary enabled:hover:bg-primary-darker",
|
|
19
|
+
secondary: "rounded-sm bg-secondary text-on-secondary enabled:hover:bg-secondary-darker focus-visible:ring-secondary",
|
|
20
20
|
text: "rounded-sm text-primary enabled:hover:underline",
|
|
21
21
|
},
|
|
22
22
|
size: {
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { tv } from "tailwind-variants";
|
|
14
14
|
const searchInputStyles = tv({
|
|
15
|
-
base: "w-full rounded-sm bg-
|
|
15
|
+
base: "w-full rounded-sm bg-surface px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-500 focus:outline-hidden focus:ring-2 transition-colors",
|
|
16
16
|
variants: {
|
|
17
17
|
variantSize: {
|
|
18
18
|
small: "text-xs py-1 px-2",
|
|
@@ -6,11 +6,11 @@ const cartIconStyles = tv({
|
|
|
6
6
|
base: "relative inline-flex items-center",
|
|
7
7
|
variants: {
|
|
8
8
|
interactive: {
|
|
9
|
-
true: "cursor-pointer rounded-sm focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2",
|
|
9
|
+
true: "cursor-pointer rounded-sm focus:outline-hidden focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-surface",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
12
|
slots: {
|
|
13
|
-
badge: "absolute -top-1 -right-1 bg-danger text-
|
|
13
|
+
badge: "absolute -top-1 -right-1 bg-danger text-on-danger text-xs rounded-full px-1",
|
|
14
14
|
},
|
|
15
15
|
});
|
|
16
16
|
export const CartIcon = ({ count = 0, onClick, color = "black", size = "medium", className, ariaLabel, }) => {
|
|
@@ -8,7 +8,7 @@ const productCardStyles = tv({
|
|
|
8
8
|
slots: {
|
|
9
9
|
imageWrapper: "relative aspect-3/4",
|
|
10
10
|
image: "w-full h-full object-cover",
|
|
11
|
-
tag: "absolute top-2 left-2 bg-neutral-950 text-
|
|
11
|
+
tag: "absolute top-2 left-2 bg-neutral-950 text-neutral-25 text-xs px-2 py-1 rounded-sm",
|
|
12
12
|
body: "p-2 flex flex-col",
|
|
13
13
|
productInfo: "flex flex-col",
|
|
14
14
|
title: "text-sm font-medium",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
3
|
const headerStyles = tv({
|
|
4
|
-
base: "w-full flex items-center justify-between px-4 h-16 bg-
|
|
4
|
+
base: "w-full flex items-center justify-between px-4 h-16 bg-surface shadow-sm",
|
|
5
5
|
});
|
|
6
6
|
const slotStyles = tv({
|
|
7
7
|
base: "flex items-center gap-2 flex-row h-full",
|
package/dist/styles/theme.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Design tokens. Shipped as dist/styles/theme.css: consumers import it after
|
|
3
|
-
`@import "tailwindcss"`.
|
|
3
|
+
`@import "tailwindcss"`. The Colors story reads these values, so it needs no edit when they change.
|
|
4
4
|
*/
|
|
5
5
|
@theme {
|
|
6
6
|
/* Closed type scale: these are the only text sizes that exist. */
|
|
@@ -12,64 +12,82 @@
|
|
|
12
12
|
--text-xl: 24px;
|
|
13
13
|
--text-2xl: 32px;
|
|
14
14
|
|
|
15
|
-
--color-primary-50: #f9fbfc;
|
|
16
|
-
--color-primary-100: #f1f7fa;
|
|
17
|
-
--color-primary-200: #d9e7ef;
|
|
18
|
-
--color-primary-300: #b8d3e4;
|
|
19
|
-
--color-primary-400: #90b5d2;
|
|
20
|
-
--color-primary-500: #6b98c1;
|
|
21
|
-
--color-primary-600:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
--color-primary-
|
|
26
|
-
--color-primary: #00548a;
|
|
27
|
-
--color-primary-
|
|
28
|
-
--color-primary-
|
|
15
|
+
--color-primary-50: light-dark(#f9fbfc, #12191d);
|
|
16
|
+
--color-primary-100: light-dark(#f1f7fa, #121e23);
|
|
17
|
+
--color-primary-200: light-dark(#d9e7ef, #192b35);
|
|
18
|
+
--color-primary-300: light-dark(#b8d3e4, #223a49);
|
|
19
|
+
--color-primary-400: light-dark(#90b5d2, #404e5a);
|
|
20
|
+
--color-primary-500: light-dark(#6b98c1, #4d657c);
|
|
21
|
+
--color-primary-600: light-dark(
|
|
22
|
+
#457ab0,
|
|
23
|
+
#5281b1
|
|
24
|
+
); /* 4.5:1 with white: lightest step usable for text */
|
|
25
|
+
--color-primary-700: light-dark(#0060ab, #589de4);
|
|
26
|
+
--color-primary-800: light-dark(#00548a, #73b0e6); /* same as DEFAULT */
|
|
27
|
+
--color-primary-900: light-dark(#00426c, #96c9f6);
|
|
28
|
+
--color-primary-950: light-dark(#003054, #c2e0fe);
|
|
29
|
+
--color-primary: light-dark(#00548a, #73b0e6);
|
|
30
|
+
--color-primary-lighter: light-dark(#0077cc, #4d94dc);
|
|
31
|
+
--color-primary-darker: light-dark(#003366, #96c9f6);
|
|
29
32
|
|
|
30
|
-
--color-secondary-50: #fff7ed;
|
|
31
|
-
--color-secondary-100: #ffedd5;
|
|
32
|
-
--color-secondary-200: #fed7aa;
|
|
33
|
-
--color-secondary-300: #fdba74;
|
|
34
|
-
--color-secondary-400: #fb923c;
|
|
35
|
-
--color-secondary-500: #f97316;
|
|
36
|
-
--color-secondary-600: #ea580c;
|
|
37
|
-
--color-secondary-700:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
--color-secondary: #
|
|
33
|
+
--color-secondary-50: light-dark(#fff7ed, #1e1a14);
|
|
34
|
+
--color-secondary-100: light-dark(#ffedd5, #272117);
|
|
35
|
+
--color-secondary-200: light-dark(#fed7aa, #382b1d);
|
|
36
|
+
--color-secondary-300: light-dark(#fdba74, #4e3922);
|
|
37
|
+
--color-secondary-400: light-dark(#fb923c, #6f4627);
|
|
38
|
+
--color-secondary-500: light-dark(#f97316, #924920);
|
|
39
|
+
--color-secondary-600: light-dark(#ea580c, #bf4401);
|
|
40
|
+
--color-secondary-700: light-dark(
|
|
41
|
+
#c2410c,
|
|
42
|
+
#d9653e
|
|
43
|
+
); /* same as DEFAULT; 5.2:1 with white, lightest step usable for text */
|
|
44
|
+
--color-secondary-800: light-dark(#9a3412, #ec886b); /* same as darker */
|
|
45
|
+
--color-secondary-900: light-dark(#7c2d12, #f7a58b);
|
|
46
|
+
--color-secondary-950: light-dark(#431407, #fee7e1);
|
|
47
|
+
--color-secondary: light-dark(#c2410c, #d9653e); /* 5.2:1 with white (WCAG AA) */
|
|
42
48
|
--color-secondary-lighter: #f28b2d; /* original brand orange: decorative use only, fails AA with white */
|
|
43
|
-
--color-secondary-darker: #9a3412; /* 7.3:1 with white */
|
|
49
|
+
--color-secondary-darker: light-dark(#9a3412, #ec886b); /* 7.3:1 with white */
|
|
44
50
|
|
|
45
51
|
/*
|
|
46
52
|
Semantic colors: the plain name is for text and icons on white or on `subtle` (all 4.5:1 or
|
|
47
53
|
better), `subtle` is for backgrounds. Always pair with text or an icon, never color alone.
|
|
48
54
|
*/
|
|
49
|
-
--color-danger: #b91c1c; /* 6.5:1 with white */
|
|
50
|
-
--color-danger-subtle: #fef2f2;
|
|
51
|
-
--color-success: #15803d; /* 5.0:1 with white */
|
|
52
|
-
--color-success-subtle: #f0fdf4;
|
|
53
|
-
--color-warning: #92400e; /* 7.1:1 with white */
|
|
54
|
-
--color-warning-subtle: #fef3c7;
|
|
55
|
+
--color-danger: light-dark(#b91c1c, #f47a70); /* 6.5:1 with white */
|
|
56
|
+
--color-danger-subtle: light-dark(#fef2f2, #2a1a1a);
|
|
57
|
+
--color-success: light-dark(#15803d, #4cb06b); /* 5.0:1 with white */
|
|
58
|
+
--color-success-subtle: light-dark(#f0fdf4, #16221a);
|
|
59
|
+
--color-warning: light-dark(#92400e, #e0a23a); /* 7.1:1 with white */
|
|
60
|
+
--color-warning-subtle: light-dark(#fef3c7, #2a2210);
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
Surface: the default background of the page and of controls (inputs, header). It is white in
|
|
64
|
+
light mode and the darkest tone in dark mode, so use it instead of `bg-white`.
|
|
65
|
+
`on-*`: the text and icon color for a filled brand or danger background (`bg-primary`,
|
|
66
|
+
`bg-secondary`, `bg-danger`). It is white in light mode and dark in dark mode, so use it
|
|
67
|
+
instead of `text-white`. Both are 4.5:1 or better on the fill, in both themes.
|
|
68
|
+
*/
|
|
69
|
+
--color-surface: light-dark(#ffffff, #141414);
|
|
70
|
+
--color-on-primary: light-dark(#ffffff, #141414);
|
|
71
|
+
--color-on-secondary: light-dark(#ffffff, #141414);
|
|
72
|
+
--color-on-danger: light-dark(#ffffff, #141414);
|
|
55
73
|
|
|
56
74
|
/*
|
|
57
75
|
Gray scale. Jobs: 900 body text, 600 secondary text, 500 placeholder, 400 input borders
|
|
58
76
|
(3:1), 200 dividers, 50 page background. 100 to 300 are never for text.
|
|
59
77
|
*/
|
|
60
78
|
--color-neutral-*: initial;
|
|
61
|
-
--color-neutral-25: rgb(250 250 250);
|
|
62
|
-
--color-neutral-50: rgb(246 246 246);
|
|
63
|
-
--color-neutral-100: rgb(231 231 231);
|
|
64
|
-
--color-neutral-200: rgb(209 209 209);
|
|
65
|
-
--color-neutral-300: rgb(176 176 176);
|
|
66
|
-
--color-neutral-400: rgb(136 136 136);
|
|
67
|
-
--color-neutral-500: rgb(109 109 109);
|
|
68
|
-
--color-neutral-600: rgb(93 93 93);
|
|
69
|
-
--color-neutral-700: rgb(79 79 79);
|
|
70
|
-
--color-neutral-800: rgb(69 69 69);
|
|
71
|
-
--color-neutral-900: rgb(61 61 61);
|
|
72
|
-
--color-neutral-950: rgb(48 48 48);
|
|
79
|
+
--color-neutral-25: light-dark(rgb(250 250 250), rgb(24 24 24));
|
|
80
|
+
--color-neutral-50: light-dark(rgb(246 246 246), rgb(27 27 27));
|
|
81
|
+
--color-neutral-100: light-dark(rgb(231 231 231), rgb(39 39 39));
|
|
82
|
+
--color-neutral-200: light-dark(rgb(209 209 209), rgb(54 54 54));
|
|
83
|
+
--color-neutral-300: light-dark(rgb(176 176 176), rgb(76 76 76));
|
|
84
|
+
--color-neutral-400: light-dark(rgb(136 136 136), rgb(108 108 108));
|
|
85
|
+
--color-neutral-500: light-dark(rgb(109 109 109), rgb(135 135 135));
|
|
86
|
+
--color-neutral-600: light-dark(rgb(93 93 93), rgb(155 155 155));
|
|
87
|
+
--color-neutral-700: light-dark(rgb(79 79 79), rgb(176 176 176));
|
|
88
|
+
--color-neutral-800: light-dark(rgb(69 69 69), rgb(194 194 194));
|
|
89
|
+
--color-neutral-900: light-dark(rgb(61 61 61), rgb(212 212 212));
|
|
90
|
+
--color-neutral-950: light-dark(rgb(48 48 48), rgb(232 232 232));
|
|
73
91
|
|
|
74
92
|
--breakpoint-xs: 0px;
|
|
75
93
|
--breakpoint-sm: 640px;
|
|
@@ -77,3 +95,35 @@
|
|
|
77
95
|
--breakpoint-lg: 1024px;
|
|
78
96
|
--breakpoint-xl: 1280px;
|
|
79
97
|
}
|
|
98
|
+
|
|
99
|
+
/*
|
|
100
|
+
Light and dark. Every color above is `light-dark(light, dark)`, so one declaration holds both
|
|
101
|
+
themes. Which one applies is the root's `color-scheme`: it follows the operating system by
|
|
102
|
+
default, and `data-theme="light"` or `data-theme="dark"` on <html> overrides it. `color-scheme`
|
|
103
|
+
also themes native controls and scrollbars. Set the attribute on <html> only: Tailwind compiles
|
|
104
|
+
`light-dark()` to custom-property toggles that are resolved at the root, so a nested element
|
|
105
|
+
with its own `data-theme` would not change.
|
|
106
|
+
|
|
107
|
+
The color names keep their jobs in both themes: the `neutral`, `primary` and `secondary` ramps
|
|
108
|
+
are inverted, so 900 is still body text, 200 still a divider and 50 the page background.
|
|
109
|
+
`-darker` is the hover step, so it is lighter in dark. `secondary-lighter` is decorative and the
|
|
110
|
+
same in both themes.
|
|
111
|
+
|
|
112
|
+
How the dark values were chosen: each step keeps the contrast ratio its light value has against
|
|
113
|
+
white, measured against the dark surface (#141414), with the same hue. Tints (50 to 400) have
|
|
114
|
+
less chroma so large areas stay calm, and the neutral text steps (700 to 950) are a little
|
|
115
|
+
brighter than a strict match because light text on a dark ground reads thinner. Text colors are
|
|
116
|
+
4.5:1 or better on `surface`, and semantic colors are too on their `subtle` background. The
|
|
117
|
+
Colors story lists every pairing for both themes and `npm test` asserts them.
|
|
118
|
+
*/
|
|
119
|
+
:root {
|
|
120
|
+
color-scheme: light dark;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:root[data-theme="light"] {
|
|
124
|
+
color-scheme: light;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:root[data-theme="dark"] {
|
|
128
|
+
color-scheme: dark;
|
|
129
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicolassancho/storybook-core",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Accessible React + Tailwind component library built with tailwind-variants and documented in Storybook.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|