@nicolassancho/storybook-core 4.1.4 → 4.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.
- package/README.md +1 -1
- package/dist/components/Atoms/Button/Button.js +1 -23
- package/dist/components/Atoms/Button/buttonStyles.d.ts +55 -0
- package/dist/components/Atoms/Button/buttonStyles.js +38 -0
- package/dist/components/Atoms/ButtonLink/ButtonLink.d.ts +34 -0
- package/dist/components/Atoms/ButtonLink/ButtonLink.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ documented in Storybook. It is published to npm as `@nicolassancho/storybook-cor
|
|
|
33
33
|
|
|
34
34
|
| Layer | Components |
|
|
35
35
|
| --------- | ----------------------------------------------------------------------------------- |
|
|
36
|
-
| Atoms | Button, Chip, ChipLink, Icon, Image, Label, RadioButton, SearchInput, Spinner, Text |
|
|
36
|
+
| Atoms | Button, ButtonLink, Chip, ChipLink, Icon, Image, Label, RadioButton, SearchInput, Spinner, Text |
|
|
37
37
|
| Molecules | Breadcrumbs, CartIcon, ProductCard, ProductDetails, RadioGroup |
|
|
38
38
|
| Organisms | Footer, Header, ProductGrid |
|
|
39
39
|
| Layouts | Container, Grid |
|
|
@@ -10,29 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
const buttonStyles = tv({
|
|
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
|
-
variants: {
|
|
17
|
-
variant: {
|
|
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
|
-
text: "rounded-sm text-primary enabled:hover:underline",
|
|
21
|
-
},
|
|
22
|
-
size: {
|
|
23
|
-
small: "text-xs px-2 py-1",
|
|
24
|
-
medium: "text-sm px-4 py-2",
|
|
25
|
-
large: "text-lg px-6 py-3",
|
|
26
|
-
},
|
|
27
|
-
disabled: {
|
|
28
|
-
true: "opacity-50 cursor-not-allowed",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
defaultVariants: {
|
|
32
|
-
variant: "primary",
|
|
33
|
-
size: "medium",
|
|
34
|
-
},
|
|
35
|
-
});
|
|
13
|
+
import { buttonStyles } from "./buttonStyles.js";
|
|
36
14
|
/**
|
|
37
15
|
* Primary UI component for user interaction
|
|
38
16
|
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const buttonStyles: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
variant: {
|
|
3
|
+
primary: "rounded-sm bg-primary text-on-primary";
|
|
4
|
+
secondary: "rounded-sm bg-secondary text-on-secondary focus-visible:ring-secondary";
|
|
5
|
+
text: "rounded-sm text-primary";
|
|
6
|
+
};
|
|
7
|
+
size: {
|
|
8
|
+
small: "text-xs px-2 py-1";
|
|
9
|
+
medium: "text-sm px-4 py-2";
|
|
10
|
+
large: "text-lg px-6 py-3";
|
|
11
|
+
};
|
|
12
|
+
disabled: {
|
|
13
|
+
true: "opacity-50 cursor-not-allowed";
|
|
14
|
+
};
|
|
15
|
+
link: {
|
|
16
|
+
true: "no-underline";
|
|
17
|
+
false: "";
|
|
18
|
+
};
|
|
19
|
+
}, undefined, "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", {
|
|
20
|
+
variant: {
|
|
21
|
+
primary: "rounded-sm bg-primary text-on-primary";
|
|
22
|
+
secondary: "rounded-sm bg-secondary text-on-secondary focus-visible:ring-secondary";
|
|
23
|
+
text: "rounded-sm text-primary";
|
|
24
|
+
};
|
|
25
|
+
size: {
|
|
26
|
+
small: "text-xs px-2 py-1";
|
|
27
|
+
medium: "text-sm px-4 py-2";
|
|
28
|
+
large: "text-lg px-6 py-3";
|
|
29
|
+
};
|
|
30
|
+
disabled: {
|
|
31
|
+
true: "opacity-50 cursor-not-allowed";
|
|
32
|
+
};
|
|
33
|
+
link: {
|
|
34
|
+
true: "no-underline";
|
|
35
|
+
false: "";
|
|
36
|
+
};
|
|
37
|
+
}, undefined, import("tailwind-variants").TVReturnTypeLike<{
|
|
38
|
+
variant: {
|
|
39
|
+
primary: "rounded-sm bg-primary text-on-primary";
|
|
40
|
+
secondary: "rounded-sm bg-secondary text-on-secondary focus-visible:ring-secondary";
|
|
41
|
+
text: "rounded-sm text-primary";
|
|
42
|
+
};
|
|
43
|
+
size: {
|
|
44
|
+
small: "text-xs px-2 py-1";
|
|
45
|
+
medium: "text-sm px-4 py-2";
|
|
46
|
+
large: "text-lg px-6 py-3";
|
|
47
|
+
};
|
|
48
|
+
disabled: {
|
|
49
|
+
true: "opacity-50 cursor-not-allowed";
|
|
50
|
+
};
|
|
51
|
+
link: {
|
|
52
|
+
true: "no-underline";
|
|
53
|
+
false: "";
|
|
54
|
+
};
|
|
55
|
+
}, undefined>>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
// Shared by Button and ButtonLink, not exported from `src/index.js`. The hover classes are in
|
|
3
|
+
// `compoundVariants` because `enabled:` never matches an `<a>`.
|
|
4
|
+
export const buttonStyles = tv({
|
|
5
|
+
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",
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
primary: "rounded-sm bg-primary text-on-primary",
|
|
9
|
+
secondary: "rounded-sm bg-secondary text-on-secondary focus-visible:ring-secondary",
|
|
10
|
+
text: "rounded-sm text-primary",
|
|
11
|
+
},
|
|
12
|
+
size: {
|
|
13
|
+
small: "text-xs px-2 py-1",
|
|
14
|
+
medium: "text-sm px-4 py-2",
|
|
15
|
+
large: "text-lg px-6 py-3",
|
|
16
|
+
},
|
|
17
|
+
disabled: {
|
|
18
|
+
true: "opacity-50 cursor-not-allowed",
|
|
19
|
+
},
|
|
20
|
+
link: {
|
|
21
|
+
true: "no-underline",
|
|
22
|
+
false: "",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
compoundVariants: [
|
|
26
|
+
{ variant: "primary", link: false, class: "enabled:hover:bg-primary-darker" },
|
|
27
|
+
{ variant: "primary", link: true, class: "hover:bg-primary-darker" },
|
|
28
|
+
{ variant: "secondary", link: false, class: "enabled:hover:bg-secondary-darker" },
|
|
29
|
+
{ variant: "secondary", link: true, class: "hover:bg-secondary-darker" },
|
|
30
|
+
{ variant: "text", link: false, class: "enabled:hover:underline" },
|
|
31
|
+
{ variant: "text", link: true, class: "hover:underline" },
|
|
32
|
+
],
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
variant: "primary",
|
|
35
|
+
size: "medium",
|
|
36
|
+
link: false,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ButtonLinkProps {
|
|
3
|
+
/** Where the link goes, for example `/products`. It needs no JavaScript. */
|
|
4
|
+
href: string;
|
|
5
|
+
/** Link contents */
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* The type of the button
|
|
9
|
+
*/
|
|
10
|
+
variant?: "primary" | "secondary" | "text";
|
|
11
|
+
/**
|
|
12
|
+
* How large should the button be?
|
|
13
|
+
*/
|
|
14
|
+
size?: "small" | "medium" | "large";
|
|
15
|
+
/**
|
|
16
|
+
* Component used to render the link. Receives `href`, `className` and `children`, so a
|
|
17
|
+
* framework link (e.g. `next/link`) can be passed directly. Defaults to a plain `<a>`. Define it
|
|
18
|
+
* outside the render function: an inline definition remounts the link.
|
|
19
|
+
*/
|
|
20
|
+
LinkComponent?: React.ElementType<{
|
|
21
|
+
href: string;
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
className?: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Additional classes for custom styling
|
|
27
|
+
*/
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A link that looks like a `Button`, for a call to action that goes to another page, such as
|
|
32
|
+
* "Shop the collection". For an action that runs code or submits a form, use `Button`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ButtonLink: React.FC<ButtonLinkProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { buttonStyles } from "../Button/buttonStyles.js";
|
|
3
|
+
/**
|
|
4
|
+
* A link that looks like a `Button`, for a call to action that goes to another page, such as
|
|
5
|
+
* "Shop the collection". For an action that runs code or submits a form, use `Button`.
|
|
6
|
+
*/
|
|
7
|
+
export const ButtonLink = ({ href, children, variant, size = "medium", LinkComponent = "a", className, }) => (_jsx(LinkComponent, { href: href, className: buttonStyles({ variant, size, link: true, className }), children: children }));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./components/Atoms/Button/Button.js";
|
|
2
|
+
export * from "./components/Atoms/ButtonLink/ButtonLink.js";
|
|
2
3
|
export * from "./components/Atoms/Chip/Chip.js";
|
|
3
4
|
export * from "./components/Atoms/ChipLink/ChipLink.js";
|
|
4
5
|
export * from "./components/Atoms/Spinner/Spinner.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Atoms
|
|
2
2
|
export * from "./components/Atoms/Button/Button.js";
|
|
3
|
+
export * from "./components/Atoms/ButtonLink/ButtonLink.js";
|
|
3
4
|
export * from "./components/Atoms/Chip/Chip.js";
|
|
4
5
|
export * from "./components/Atoms/ChipLink/ChipLink.js";
|
|
5
6
|
export * from "./components/Atoms/Spinner/Spinner.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nicolassancho/storybook-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.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",
|