@nicolassancho/storybook-core 3.1.0 → 3.2.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.
|
@@ -5,8 +5,17 @@ export interface TextProps {
|
|
|
5
5
|
* Text color. Every option reaches the 4.5:1 text contrast on white.
|
|
6
6
|
*/
|
|
7
7
|
color?: "base" | "dark" | "darker" | "primary" | "secondary";
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Text size: 14px, 16px and 20px for body copy, 32px for headings and a fluid 36 to 64px for
|
|
10
|
+
* hero text. Each size sets its own line-height, and `display` also tightens the tracking.
|
|
11
|
+
*/
|
|
12
|
+
size?: "small" | "medium" | "large" | "heading" | "display";
|
|
13
|
+
/**
|
|
14
|
+
* Font family: `body` is `font-sans`, `display` is `font-display` (the heading font the
|
|
15
|
+
* consumer sets with `--font-display`, the body font when none is set).
|
|
16
|
+
*/
|
|
17
|
+
font?: "body" | "display";
|
|
18
|
+
weight?: "normal" | "medium" | "semibold" | "bold";
|
|
10
19
|
underline?: boolean;
|
|
11
20
|
children: React.ReactNode;
|
|
12
21
|
className?: string;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { tv } from "tailwind-variants";
|
|
3
3
|
const textStyles = tv({
|
|
4
|
-
base: "font-sans",
|
|
5
4
|
variants: {
|
|
5
|
+
font: {
|
|
6
|
+
body: "font-sans",
|
|
7
|
+
display: "font-display",
|
|
8
|
+
},
|
|
6
9
|
color: {
|
|
7
10
|
base: "text-neutral-500",
|
|
8
11
|
dark: "text-neutral-700",
|
|
@@ -14,11 +17,14 @@ const textStyles = tv({
|
|
|
14
17
|
small: "text-sm",
|
|
15
18
|
medium: "text-base",
|
|
16
19
|
large: "text-lg",
|
|
20
|
+
heading: "text-2xl",
|
|
21
|
+
display: "text-4xl",
|
|
17
22
|
},
|
|
18
23
|
weight: {
|
|
19
24
|
normal: "font-normal",
|
|
20
|
-
|
|
25
|
+
medium: "font-medium",
|
|
21
26
|
semibold: "font-semibold",
|
|
27
|
+
bold: "font-bold",
|
|
22
28
|
},
|
|
23
29
|
underline: {
|
|
24
30
|
true: "underline",
|
|
@@ -26,12 +32,13 @@ const textStyles = tv({
|
|
|
26
32
|
},
|
|
27
33
|
},
|
|
28
34
|
defaultVariants: {
|
|
35
|
+
font: "body",
|
|
29
36
|
color: "dark",
|
|
30
37
|
size: "medium",
|
|
31
38
|
weight: "normal",
|
|
32
39
|
underline: false,
|
|
33
40
|
},
|
|
34
41
|
});
|
|
35
|
-
export const Text = ({ as: Component = "div", color = "dark", size = "medium", weight = "normal", underline = false, children, className = "", }) => {
|
|
36
|
-
return (_jsx(Component, { className: textStyles({ color, size, weight, underline, className }), children: children }));
|
|
42
|
+
export const Text = ({ as: Component = "div", font = "body", color = "dark", size = "medium", weight = "normal", underline = false, children, className = "", }) => {
|
|
43
|
+
return (_jsx(Component, { className: textStyles({ font, color, size, weight, underline, className }), children: children }));
|
|
37
44
|
};
|
package/dist/styles/theme.css
CHANGED
|
@@ -3,14 +3,37 @@
|
|
|
3
3
|
`@import "tailwindcss"`. The Colors story reads these values, so it needs no edit when they change.
|
|
4
4
|
*/
|
|
5
5
|
@theme {
|
|
6
|
-
/*
|
|
6
|
+
/*
|
|
7
|
+
Closed type scale: these are the only text sizes that exist. Sizes are in rem, so they follow
|
|
8
|
+
the browser's font-size setting, and each size carries its line-height (`text-sm` sets both).
|
|
9
|
+
4xl is the fluid display size (36px on phones, 64px from about 1200px wide). The names are
|
|
10
|
+
Tailwind's t-shirt sizes on purpose: tailwind-merge reads `text-display` as a color and
|
|
11
|
+
would drop one of `text-display` and `text-neutral-900` when they meet in a tv() call.
|
|
12
|
+
*/
|
|
7
13
|
--text-*: initial;
|
|
8
|
-
--text-xs:
|
|
9
|
-
--text-
|
|
10
|
-
--text-
|
|
11
|
-
--text-
|
|
12
|
-
--text-
|
|
13
|
-
--text-
|
|
14
|
+
--text-xs: 0.75rem;
|
|
15
|
+
--text-xs--line-height: 1rem;
|
|
16
|
+
--text-sm: 0.875rem;
|
|
17
|
+
--text-sm--line-height: 1.25rem;
|
|
18
|
+
--text-base: 1rem;
|
|
19
|
+
--text-base--line-height: 1.5rem;
|
|
20
|
+
--text-lg: 1.25rem;
|
|
21
|
+
--text-lg--line-height: 1.75rem;
|
|
22
|
+
--text-xl: 1.5rem;
|
|
23
|
+
--text-xl--line-height: 2rem;
|
|
24
|
+
--text-2xl: 2rem;
|
|
25
|
+
--text-2xl--line-height: 2.5rem;
|
|
26
|
+
--text-3xl: 2.5rem;
|
|
27
|
+
--text-3xl--line-height: 3rem;
|
|
28
|
+
--text-4xl: clamp(2.25rem, 5.4vw, 4rem);
|
|
29
|
+
--text-4xl--line-height: 1.04;
|
|
30
|
+
--text-4xl--letter-spacing: -0.03em;
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
Font families. The library loads no fonts: a consumer sets --font-sans (body) and optionally
|
|
34
|
+
--font-display (headings). Without one, headings use the body font.
|
|
35
|
+
*/
|
|
36
|
+
--font-display: var(--font-sans);
|
|
14
37
|
|
|
15
38
|
--color-primary-50: light-dark(#f9fbfc, #12191d);
|
|
16
39
|
--color-primary-100: light-dark(#f1f7fa, #121e23);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicolassancho/storybook-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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",
|