pulso-custom-components 0.0.1
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 +73 -0
- package/dist/App.d.ts +3 -0
- package/dist/App.js +8 -0
- package/dist/components/Mylabel.d.ts +11 -0
- package/dist/components/Mylabel.js +4 -0
- package/dist/components/ui/myButton.d.ts +10 -0
- package/dist/components/ui/myButton.js +35 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/lib/utils.js +5 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +4 -0
- package/dist/stories/Button.d.ts +15 -0
- package/dist/stories/Button.js +7 -0
- package/dist/stories/Button.stories.d.ts +23 -0
- package/dist/stories/Button.stories.js +44 -0
- package/dist/stories/Header.d.ts +12 -0
- package/dist/stories/Header.js +4 -0
- package/dist/stories/Header.stories.d.ts +18 -0
- package/dist/stories/Header.stories.js +26 -0
- package/dist/stories/MyButton.stories.d.ts +18 -0
- package/dist/stories/MyButton.stories.js +21 -0
- package/dist/stories/Mylabel.stories.d.ts +12 -0
- package/dist/stories/Mylabel.stories.js +16 -0
- package/dist/stories/Page.d.ts +3 -0
- package/dist/stories/Page.js +8 -0
- package/dist/stories/Page.stories.d.ts +12 -0
- package/dist/stories/Page.stories.js +24 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +81 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is currently not compatible with SWC. See [this issue](https://github.com/vitejs/vite-plugin-react/issues/428) for tracking the progress.
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
package/dist/App.d.ts
ADDED
package/dist/App.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import './App.css';
|
|
4
|
+
function App() {
|
|
5
|
+
const [count, setCount] = useState(0);
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("a", { href: "https://vite.dev", target: "_blank" }), _jsx("a", { href: "https://react.dev", target: "_blank" })] }), _jsx("h1", { children: "Vite + React" }), _jsxs("div", { className: "card", children: [_jsxs("button", { onClick: () => setCount((count) => count + 1), children: ["count is ", count] }), _jsxs("p", { children: ["Edit ", _jsx("code", { children: "src/App.tsx" }), " and save to test HMR"] })] }), _jsx("p", { className: "read-the-docs", children: "Click on the Vite and React logos to learn more" })] }));
|
|
7
|
+
}
|
|
8
|
+
export default App;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const buttonVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
5
|
+
size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
declare function MyButton({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export { MyButton, buttonVariants };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
import { Slot } from "radix-ui";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
9
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
10
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
11
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
12
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
13
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
17
|
+
xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
18
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
19
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
20
|
+
icon: "size-9",
|
|
21
|
+
"icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
|
|
22
|
+
"icon-sm": "size-8",
|
|
23
|
+
"icon-lg": "size-10",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
variant: "default",
|
|
28
|
+
size: "default",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
function MyButton({ className, variant = "default", size = "default", asChild = false, ...props }) {
|
|
32
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
33
|
+
return (_jsx(Comp, { "data-slot": "button", "data-variant": variant, "data-size": size, className: cn(buttonVariants({ variant, size, className })), ...props }));
|
|
34
|
+
}
|
|
35
|
+
export { MyButton, buttonVariants };
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './button.css';
|
|
2
|
+
export interface ButtonProps {
|
|
3
|
+
/** Is this the principal call to action on the page? */
|
|
4
|
+
primary?: boolean;
|
|
5
|
+
/** What background color to use */
|
|
6
|
+
backgroundColor?: string;
|
|
7
|
+
/** How large should the button be? */
|
|
8
|
+
size?: 'small' | 'medium' | 'large';
|
|
9
|
+
/** Button contents */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Optional click handler */
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
}
|
|
14
|
+
/** Primary UI component for user interaction */
|
|
15
|
+
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import './button.css';
|
|
3
|
+
/** Primary UI component for user interaction */
|
|
4
|
+
export const Button = ({ primary = false, size = 'medium', backgroundColor, label, ...props }) => {
|
|
5
|
+
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
6
|
+
return (_jsx("button", { type: "button", className: ['storybook-button', `storybook-button--${size}`, mode].join(' '), style: { backgroundColor }, ...props, children: label }));
|
|
7
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {
|
|
10
|
+
backgroundColor: {
|
|
11
|
+
control: "color";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
args: {
|
|
15
|
+
onClick: import("storybook/test").Mock<(...args: any[]) => any>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
type Story = StoryObj<typeof meta>;
|
|
20
|
+
export declare const Primary: Story;
|
|
21
|
+
export declare const Secondary: Story;
|
|
22
|
+
export declare const Large: Story;
|
|
23
|
+
export declare const Small: Story;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { fn } from 'storybook/test';
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Example/Button',
|
|
6
|
+
component: Button,
|
|
7
|
+
parameters: {
|
|
8
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
9
|
+
layout: 'centered',
|
|
10
|
+
},
|
|
11
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
14
|
+
argTypes: {
|
|
15
|
+
backgroundColor: { control: 'color' },
|
|
16
|
+
},
|
|
17
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#story-args
|
|
18
|
+
args: { onClick: fn() },
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
22
|
+
export const Primary = {
|
|
23
|
+
args: {
|
|
24
|
+
primary: true,
|
|
25
|
+
label: 'Button',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const Secondary = {
|
|
29
|
+
args: {
|
|
30
|
+
label: 'Button',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
export const Large = {
|
|
34
|
+
args: {
|
|
35
|
+
size: 'large',
|
|
36
|
+
label: 'Button',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export const Small = {
|
|
40
|
+
args: {
|
|
41
|
+
size: 'small',
|
|
42
|
+
label: 'Button',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import './header.css';
|
|
2
|
+
type User = {
|
|
3
|
+
name: string;
|
|
4
|
+
};
|
|
5
|
+
export interface HeaderProps {
|
|
6
|
+
user?: User;
|
|
7
|
+
onLogin?: () => void;
|
|
8
|
+
onLogout?: () => void;
|
|
9
|
+
onCreateAccount?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from './Button';
|
|
3
|
+
import './header.css';
|
|
4
|
+
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (_jsx("header", { children: _jsxs("div", { className: "storybook-header", children: [_jsxs("div", { children: [_jsx("svg", { width: "32", height: "32", viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg", children: _jsxs("g", { fill: "none", fillRule: "evenodd", children: [_jsx("path", { d: "M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z", fill: "#FFF" }), _jsx("path", { d: "M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z", fill: "#555AB9" }), _jsx("path", { d: "M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z", fill: "#91BAF8" })] }) }), _jsx("h1", { children: "Acme" })] }), _jsx("div", { children: user ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "welcome", children: ["Welcome, ", _jsx("b", { children: user.name }), "!"] }), _jsx(Button, { size: "small", onClick: onLogout, label: "Log out" })] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { size: "small", onClick: onLogin, label: "Log in" }), _jsx(Button, { primary: true, size: "small", onClick: onCreateAccount, label: "Sign up" })] })) })] }) }));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ user, onLogin, onLogout, onCreateAccount }: import("./Header").HeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
args: {
|
|
10
|
+
onLogin: import("storybook/test").Mock<(...args: any[]) => any>;
|
|
11
|
+
onLogout: import("storybook/test").Mock<(...args: any[]) => any>;
|
|
12
|
+
onCreateAccount: import("storybook/test").Mock<(...args: any[]) => any>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
export declare const LoggedIn: Story;
|
|
18
|
+
export declare const LoggedOut: Story;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { fn } from 'storybook/test';
|
|
2
|
+
import { Header } from './Header';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Example/Header',
|
|
5
|
+
component: Header,
|
|
6
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
10
|
+
layout: 'fullscreen',
|
|
11
|
+
},
|
|
12
|
+
args: {
|
|
13
|
+
onLogin: fn(),
|
|
14
|
+
onLogout: fn(),
|
|
15
|
+
onCreateAccount: fn(),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
export const LoggedIn = {
|
|
20
|
+
args: {
|
|
21
|
+
user: {
|
|
22
|
+
name: 'Jane Doe',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export const LoggedOut = {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { MyButton } from '@/components/ui/myButton';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof MyButton;
|
|
6
|
+
tags: string[];
|
|
7
|
+
argTypes: {
|
|
8
|
+
className: {
|
|
9
|
+
control: "text";
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default meta;
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
export declare const Basic: Story;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MyButton } from '@/components/ui/myButton';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Form/Mubutton",
|
|
4
|
+
component: MyButton,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
argTypes: {
|
|
7
|
+
className: { control: "text" }
|
|
8
|
+
},
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Basic = {
|
|
15
|
+
args: {
|
|
16
|
+
children: "Holaaaa",
|
|
17
|
+
variant: "destructive",
|
|
18
|
+
size: "xs",
|
|
19
|
+
className: "bg-green-500"
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ label, className }: import("../components/Mylabel").Props) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Basic: Story;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Mylabel } from "../components/Mylabel";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Form/Labels",
|
|
4
|
+
component: Mylabel,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
export const Basic = {
|
|
12
|
+
args: {
|
|
13
|
+
label: "Holaa",
|
|
14
|
+
className: "red-blue-500"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Header } from './Header';
|
|
4
|
+
import './page.css';
|
|
5
|
+
export const Page = () => {
|
|
6
|
+
const [user, setUser] = React.useState();
|
|
7
|
+
return (_jsxs("article", { children: [_jsx(Header, { user: user, onLogin: () => setUser({ name: 'Jane Doe' }), onLogout: () => setUser(undefined), onCreateAccount: () => setUser({ name: 'Jane Doe' }) }), _jsxs("section", { className: "storybook-page", children: [_jsx("h2", { children: "Pages in Storybook" }), _jsxs("p", { children: ["We recommend building UIs with a", ' ', _jsx("a", { href: "https://componentdriven.org", target: "_blank", rel: "noopener noreferrer", children: _jsx("strong", { children: "component-driven" }) }), ' ', "process starting with atomic components and ending with pages."] }), _jsx("p", { children: "Render pages with mock data. This makes it easy to build and review page states without needing to navigate to them in your app. Here are some handy patterns for managing page data in Storybook:" }), _jsxs("ul", { children: [_jsx("li", { children: "Use a higher-level connected component. Storybook helps you compose such data from the \"args\" of child component stories" }), _jsx("li", { children: "Assemble data in the page component from your services. You can mock these services out using Storybook." })] }), _jsxs("p", { children: ["Get a guided tutorial on component-driven development at", ' ', _jsx("a", { href: "https://storybook.js.org/tutorials/", target: "_blank", rel: "noopener noreferrer", children: "Storybook tutorials" }), ". Read more in the", ' ', _jsx("a", { href: "https://storybook.js.org/docs", target: "_blank", rel: "noopener noreferrer", children: "docs" }), "."] }), _jsxs("div", { className: "tip-wrapper", children: [_jsx("span", { className: "tip", children: "Tip" }), " Adjust the width of the canvas with the", ' ', _jsx("svg", { width: "10", height: "10", viewBox: "0 0 12 12", xmlns: "http://www.w3.org/2000/svg", children: _jsx("g", { fill: "none", fillRule: "evenodd", children: _jsx("path", { d: "M1.5 5.2h4.8c.3 0 .5.2.5.4v5.1c-.1.2-.3.3-.4.3H1.4a.5.5 0 01-.5-.4V5.7c0-.3.2-.5.5-.5zm0-2.1h6.9c.3 0 .5.2.5.4v7a.5.5 0 01-1 0V4H1.5a.5.5 0 010-1zm0-2.1h9c.3 0 .5.2.5.4v9.1a.5.5 0 01-1 0V2H1.5a.5.5 0 010-1zm4.3 5.2H2V10h3.8V6.2z", id: "a", fill: "#999" }) }) }), "Viewports addon in the toolbar"] })] })] }));
|
|
8
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").FC<{}>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof meta>;
|
|
11
|
+
export declare const LoggedOut: Story;
|
|
12
|
+
export declare const LoggedIn: Story;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
2
|
+
import { Page } from './Page';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Example/Page',
|
|
5
|
+
component: Page,
|
|
6
|
+
parameters: {
|
|
7
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
8
|
+
layout: 'fullscreen',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const LoggedOut = {};
|
|
13
|
+
// More on component testing: https://storybook.js.org/docs/writing-tests/interaction-testing
|
|
14
|
+
export const LoggedIn = {
|
|
15
|
+
play: async ({ canvasElement }) => {
|
|
16
|
+
const canvas = within(canvasElement);
|
|
17
|
+
const loginButton = canvas.getByRole('button', { name: /Log in/i });
|
|
18
|
+
await expect(loginButton).toBeInTheDocument();
|
|
19
|
+
await userEvent.click(loginButton);
|
|
20
|
+
await expect(loginButton).not.toBeInTheDocument();
|
|
21
|
+
const logoutButton = canvas.getByRole('button', { name: /Log out/i });
|
|
22
|
+
await expect(logoutButton).toBeInTheDocument();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/app.tsx","../src/main.tsx","../src/components/mylabel.tsx","../src/components/ui/mybutton.tsx","../src/lib/utils.ts","../src/stories/button.stories.ts","../src/stories/button.tsx","../src/stories/header.stories.ts","../src/stories/header.tsx","../src/stories/mybutton.stories.ts","../src/stories/mylabel.stories.ts","../src/stories/page.stories.ts","../src/stories/page.tsx"],"version":"5.9.3"}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pulso-custom-components",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"react",
|
|
8
|
+
"dev",
|
|
9
|
+
"Pulso",
|
|
10
|
+
"Martin"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://martin-rios-tineo.vercel.app",
|
|
14
|
+
"repository": {
|
|
15
|
+
"url": "TODO",
|
|
16
|
+
"type": "git"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/"
|
|
20
|
+
],
|
|
21
|
+
"release": {
|
|
22
|
+
"branches": [
|
|
23
|
+
"+([0-9])?(.{+([0-9]),x}).x",
|
|
24
|
+
"master"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "^19.2.0",
|
|
29
|
+
"react-dom": "^19.2.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "npm run storybook",
|
|
33
|
+
"build": "npm run clean && tsc -b",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"preview": "vite preview",
|
|
36
|
+
"storybook": "storybook dev -p 6006",
|
|
37
|
+
"build-storybook": "storybook build",
|
|
38
|
+
"clean": "rimraf dist/"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@chromatic-com/storybook": "^5.0.0",
|
|
42
|
+
"@eslint/js": "^9.39.1",
|
|
43
|
+
"@storybook/addon-a11y": "^10.2.7",
|
|
44
|
+
"@storybook/addon-docs": "^10.2.7",
|
|
45
|
+
"@storybook/addon-onboarding": "^10.2.7",
|
|
46
|
+
"@storybook/addon-styling-webpack": "^3.0.0",
|
|
47
|
+
"@storybook/addon-vitest": "^10.2.7",
|
|
48
|
+
"@storybook/react-vite": "^10.2.7",
|
|
49
|
+
"@tailwindcss/postcss": "^4.1.18",
|
|
50
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
51
|
+
"@types/node": "^24.10.12",
|
|
52
|
+
"@types/react": "^19.2.5",
|
|
53
|
+
"@types/react-dom": "^19.2.3",
|
|
54
|
+
"@vitejs/plugin-react-swc": "^4.2.2",
|
|
55
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
56
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
57
|
+
"class-variance-authority": "^0.7.1",
|
|
58
|
+
"clsx": "^2.1.1",
|
|
59
|
+
"eslint": "^9.39.1",
|
|
60
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
61
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
62
|
+
"eslint-plugin-storybook": "^10.2.7",
|
|
63
|
+
"globals": "^16.5.0",
|
|
64
|
+
"lucide-react": "^0.563.0",
|
|
65
|
+
"playwright": "^1.58.2",
|
|
66
|
+
"postcss": "^8.5.6",
|
|
67
|
+
"radix-ui": "^1.4.3",
|
|
68
|
+
"react": "^19.2.0",
|
|
69
|
+
"react-dom": "^19.2.0",
|
|
70
|
+
"rimraf": "^6.1.2",
|
|
71
|
+
"shadcn": "^3.8.4",
|
|
72
|
+
"storybook": "^10.2.7",
|
|
73
|
+
"tailwind-merge": "^3.4.0",
|
|
74
|
+
"tailwindcss": "^4.1.18",
|
|
75
|
+
"tw-animate-css": "^1.4.0",
|
|
76
|
+
"typescript": "~5.9.3",
|
|
77
|
+
"typescript-eslint": "^8.46.4",
|
|
78
|
+
"vite": "^7.2.4",
|
|
79
|
+
"vitest": "^4.0.18"
|
|
80
|
+
}
|
|
81
|
+
}
|