@beydesign/storybook 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 ADDED
@@ -0,0 +1,50 @@
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/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## Expanding the ESLint configuration
11
+
12
+ If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13
+
14
+ - Configure the top-level `parserOptions` property like this:
15
+
16
+ ```js
17
+ export default tseslint.config({
18
+ languageOptions: {
19
+ // other options...
20
+ parserOptions: {
21
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
22
+ tsconfigRootDir: import.meta.dirname,
23
+ },
24
+ },
25
+ })
26
+ ```
27
+
28
+ - Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29
+ - Optionally add `...tseslint.configs.stylisticTypeChecked`
30
+ - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31
+
32
+ ```js
33
+ // eslint.config.js
34
+ import react from 'eslint-plugin-react'
35
+
36
+ export default tseslint.config({
37
+ // Set the react version
38
+ settings: { react: { version: '18.3' } },
39
+ plugins: {
40
+ // Add the react plugin
41
+ react,
42
+ },
43
+ rules: {
44
+ // other rules...
45
+ // Enable its recommended rules
46
+ ...react.configs.recommended.rules,
47
+ ...react.configs['jsx-runtime'].rules,
48
+ },
49
+ })
50
+ ```
package/dist/App.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import './App.css';
2
+ declare function App(): import("react/jsx-runtime").JSX.Element;
3
+ export default App;
package/dist/App.js ADDED
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import reactLogo from './assets/react.svg';
4
+ import viteLogo from '/vite.svg';
5
+ import './App.css';
6
+ function App() {
7
+ const [count, setCount] = useState(0);
8
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { children: [_jsx("a", { href: "https://vite.dev", target: "_blank", children: _jsx("img", { src: viteLogo, className: "logo", alt: "Vite logo" }) }), _jsx("a", { href: "https://react.dev", target: "_blank", children: _jsx("img", { src: reactLogo, className: "logo react", alt: "React logo" }) })] }), _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" })] }));
9
+ }
10
+ export default App;
@@ -0,0 +1,2 @@
1
+ export { MainButton } from './stories/Button';
2
+ export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, type MainButtonProps } from './stories/types/button';
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Components
2
+ export { MainButton } from './stories/Button';
3
+ // Types
4
+ export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType } from './stories/types/button';
package/dist/main.d.ts ADDED
@@ -0,0 +1 @@
1
+ import './index.css';
package/dist/main.js ADDED
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { StrictMode } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import './index.css';
5
+ import App from './App';
6
+ createRoot(document.getElementById('root')).render(_jsx(StrictMode, { children: _jsx(App, {}) }));
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { MainButtonProps, ComponentsProps } from './types/button';
3
+ export declare const MainButton: React.FC<MainButtonProps>;
4
+ export declare const Components: React.FC<ComponentsProps>;
@@ -0,0 +1,258 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, CircularProgress } from '@mui/material';
3
+ import * as PhosphorIcons from '@phosphor-icons/react';
4
+ import { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType } from './types/button';
5
+ const getIconComponent = (iconName, props) => {
6
+ const Icon = PhosphorIcons[iconName];
7
+ return Icon ? _jsx(Icon, { ...props }) : null;
8
+ };
9
+ export const MainButton = ({ onClick, text, disabled = false, loading = false, type = ButtonType.Button, style, size = ButtonSize.xl, hierarchy = ButtonHierarchy.Primary, displayIcon, displayIconMode = ButtonDisplayMode.Default, state = ButtonState.Default, shape = ButtonShape.Square, destructive = false, showLeadingIcon = true, showTrailingIcon = true, leadingIcon = 'Circle', trailingIcon = 'Circle', }) => {
10
+ const getBackgroundColor = (isHover = false) => {
11
+ if (destructive) {
12
+ if (state === ButtonState.Disabled || disabled)
13
+ return 'var(--colors-light-background-bg-error-solid)';
14
+ if (state === ButtonState.Hover || isHover)
15
+ return 'var(--primitives-desktop-primary-red-700)';
16
+ return 'var(--colors-light-background-bg-error)';
17
+ }
18
+ switch (hierarchy) {
19
+ case ButtonHierarchy.Primary:
20
+ if (state === ButtonState.Disabled || disabled)
21
+ return 'var(--colors-light-background-bg-button-disabled)';
22
+ if (state === ButtonState.Hover || isHover)
23
+ return 'var(--colors-light-background-bg-brand-hover)';
24
+ return 'var(--colors-light-background-bg-brand)';
25
+ case ButtonHierarchy.Secondary:
26
+ if (state === ButtonState.Disabled || disabled)
27
+ return 'var(--colors-light-background-bg-component-disabled)';
28
+ if (state === ButtonState.Hover || isHover)
29
+ return 'var(--colors-light-background-bg-card-highlight-hover)';
30
+ return 'var(--colors-light-background-bg-white)';
31
+ case ButtonHierarchy.SecondaryColor:
32
+ if (state === ButtonState.Disabled || disabled)
33
+ return 'var(--colors-light-background-bg-element)';
34
+ if (state === ButtonState.Hover || isHover)
35
+ return 'var(--colors-light-background-bg-card-highlight-hover)';
36
+ return 'var(--colors-light-background-bg-white)';
37
+ case ButtonHierarchy.SecondaryTransparent:
38
+ if (state === ButtonState.Disabled || disabled)
39
+ return 'var(--colors-light-background-bg-overlay-1)';
40
+ if (state === ButtonState.Hover || isHover)
41
+ return 'var(--colors-light-background-bg-brand-hover)';
42
+ return 'var(--primitives-desktop-primary-transparent-violet-50)';
43
+ case ButtonHierarchy.Tetriary:
44
+ if (state === ButtonState.Disabled || disabled)
45
+ return 'var(--colors-light-background-bg-element)';
46
+ if (state === ButtonState.Hover || isHover)
47
+ return 'var(--primitives-desktop-primary-white-40)';
48
+ return 'var(--colors-light-background-bg-white)';
49
+ case ButtonHierarchy.TetriaryColor:
50
+ if (state === ButtonState.Disabled || disabled)
51
+ return 'var(--colors-light-background-bg-element)';
52
+ if (state === ButtonState.Hover || isHover)
53
+ return 'var(--colors-light-background-bg-card-highlight-hover)';
54
+ return 'transparent';
55
+ default:
56
+ return 'var(--colors-light-background-bg-brand)';
57
+ }
58
+ };
59
+ const getTextColor = () => {
60
+ if (destructive) {
61
+ if (state === ButtonState.Disabled || disabled)
62
+ return 'var(--colors-light-text-text-white)';
63
+ return 'var(--colors-light-background-bg-white)';
64
+ }
65
+ switch (hierarchy) {
66
+ case ButtonHierarchy.Primary:
67
+ if (state === ButtonState.Disabled || disabled)
68
+ return 'var(--colors-light-text-text-white)';
69
+ return 'var(--colors-light-text-text-white)';
70
+ case ButtonHierarchy.Secondary:
71
+ if (state === ButtonState.Disabled || disabled)
72
+ return 'var(--colors-light-text-text-disabled)';
73
+ return 'var(--colors-light-text-text-title)';
74
+ case ButtonHierarchy.SecondaryColor:
75
+ if (state === ButtonState.Disabled || disabled)
76
+ return 'var(--colors-light-text-text-disabled)';
77
+ return 'var(--colors-light-text-text-accent)';
78
+ case ButtonHierarchy.SecondaryTransparent:
79
+ if (state === ButtonState.Disabled || disabled)
80
+ return 'var(--colors-light-text-text-white)';
81
+ return 'var(--colors-light-text-text-white)';
82
+ case ButtonHierarchy.Tetriary:
83
+ if (state === ButtonState.Disabled || disabled)
84
+ return 'var(--colors-light-text-text-disabled)';
85
+ return 'var(--colors-light-text-text-title)';
86
+ case ButtonHierarchy.TetriaryColor:
87
+ if (state === ButtonState.Disabled || disabled)
88
+ return 'var(--colors-light-text-text-disabled)';
89
+ return 'var(--colors-light-text-text-accent)';
90
+ default:
91
+ return 'var(--colors-light-text-text-white)';
92
+ }
93
+ };
94
+ const getBorderColor = (isHover = false) => {
95
+ if (destructive) {
96
+ if (state === ButtonState.Disabled || disabled)
97
+ return 'var(--colors-light-border-border-disabled)';
98
+ if (state === ButtonState.Hover || isHover)
99
+ return 'var(--primitives-desktop-primary-red-700)';
100
+ return 'var(--primitives-desktop-primary-bg-error)';
101
+ }
102
+ switch (hierarchy) {
103
+ case ButtonHierarchy.Primary:
104
+ if (state === ButtonState.Disabled || disabled)
105
+ return 'var(--colors-light-border-border-component)';
106
+ if (state === ButtonState.Hover || isHover)
107
+ return 'var(--colors-light-background-bg-brand-hover)';
108
+ return 'var(--colors-light-background-bg-brand)';
109
+ case ButtonHierarchy.Secondary:
110
+ if (state === ButtonState.Disabled || disabled)
111
+ return 'var(--colors-light-border-border-component)';
112
+ if (state === ButtonState.Hover || isHover)
113
+ return 'var(--colors-light-background-bg-card-highlight-hover)';
114
+ return 'var(--colors-light-border-border-component)';
115
+ case ButtonHierarchy.SecondaryColor:
116
+ if (state === ButtonState.Disabled || disabled)
117
+ return 'var(--colors-light-border-border-component)';
118
+ if (state === ButtonState.Hover || isHover)
119
+ return 'var(--colors-light-background-bg-brand-hover)';
120
+ return 'var(--colors-light-border-border-brand)';
121
+ case ButtonHierarchy.SecondaryTransparent:
122
+ if (state === ButtonState.Disabled || disabled)
123
+ return 'var(--colors-light-border-border-disabled)';
124
+ if (state === ButtonState.Hover || isHover)
125
+ return 'var(--primitives-desktop-primary-white-100)';
126
+ return 'var(--colors-light-background-bg-white)';
127
+ case ButtonHierarchy.Tetriary:
128
+ if (state === ButtonState.Disabled || disabled)
129
+ return 'var(--colors-light-border-border-component)';
130
+ return 'var(--colors-light-border-bg-white)';
131
+ case ButtonHierarchy.TetriaryColor:
132
+ if (state === ButtonState.Disabled || disabled)
133
+ return 'var(--colors-light-border-border-component)';
134
+ return 'var(--colors-light-border-bg-white)';
135
+ default:
136
+ return 'var(--colors-light-background-bg-brand)';
137
+ }
138
+ };
139
+ const getButtonSize = () => {
140
+ const sizes = {
141
+ [ButtonSize.xl]: {
142
+ width: displayIconMode === ButtonDisplayMode.Only ? '3.25rem' : '12.75rem',
143
+ height: '3.25rem',
144
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-lg) var(--spacing-tokens-size-in-px-spacing-spacing-3xl)',
145
+ fontSize: 'var(--global-font-size-3)',
146
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
147
+ },
148
+ [ButtonSize.lg]: {
149
+ width: displayIconMode === ButtonDisplayMode.Only ? '3rem' : '11.75rem',
150
+ height: '3rem',
151
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-lg) var(--spacing-tokens-size-in-px-spacing-spacing-2xl)',
152
+ fontSize: 'var(--global-font-size-3)',
153
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
154
+ },
155
+ [ButtonSize.md]: {
156
+ width: displayIconMode === ButtonDisplayMode.Only ? '2.75rem' : '10.75rem',
157
+ height: '2.75rem',
158
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-xl)',
159
+ fontSize: 'var(--global-font-size-2)',
160
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
161
+ },
162
+ [ButtonSize.sm]: {
163
+ width: displayIconMode === ButtonDisplayMode.Only ? '2.5rem' : '9.75rem',
164
+ height: '2.5rem',
165
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-xl)',
166
+ fontSize: 'var(--global-font-size-1)',
167
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
168
+ },
169
+ [ButtonSize.xs]: {
170
+ width: displayIconMode === ButtonDisplayMode.Only ? '2.25rem' : '8.75rem',
171
+ height: '2.25rem',
172
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-lg)',
173
+ fontSize: 'var(--global-font-size-1)',
174
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
175
+ },
176
+ [ButtonSize.xxs]: {
177
+ width: displayIconMode === ButtonDisplayMode.Only ? '2rem' : '7.75rem',
178
+ height: '2rem',
179
+ padding: displayIconMode === ButtonDisplayMode.Only ? 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)' : 'var(--spacing-tokens-size-in-px-spacing-spacing-sm) var(--spacing-tokens-size-in-px-spacing-spacing-md)',
180
+ fontSize: 'var(--global-font-size-0)',
181
+ gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
182
+ }
183
+ };
184
+ return sizes[size] || sizes[ButtonSize.xl];
185
+ };
186
+ const getButtonShape = () => {
187
+ switch (shape) {
188
+ case ButtonShape.Square:
189
+ return 'var(--spacing-tokens-size-in-px-radius-radius-xs)';
190
+ case ButtonShape.Circle:
191
+ return 'var(--spacing-tokens-size-in-px-spacing-spacing-11xl)';
192
+ default:
193
+ return 'var(--spacing-tokens-size-in-px-radius-radius-xs)';
194
+ }
195
+ };
196
+ const getIconSize = () => {
197
+ const sizes = {
198
+ [ButtonSize.xl]: 24,
199
+ [ButtonSize.lg]: 22,
200
+ [ButtonSize.md]: 20,
201
+ [ButtonSize.sm]: 18,
202
+ [ButtonSize.xs]: 16,
203
+ [ButtonSize.xxs]: 14
204
+ };
205
+ return sizes[size] || sizes[ButtonSize.xl];
206
+ };
207
+ const iconProps = {
208
+ size: getIconSize(),
209
+ color: getTextColor(),
210
+ weight: "regular"
211
+ };
212
+ const sizeStyles = getButtonSize();
213
+ const renderContent = () => {
214
+ if (loading) {
215
+ return (_jsx(CircularProgress, { size: 24, sx: {
216
+ color: getTextColor()
217
+ } }));
218
+ }
219
+ if (displayIconMode === ButtonDisplayMode.Only && displayIcon) {
220
+ return getIconComponent(displayIcon, iconProps);
221
+ }
222
+ return (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)' }, children: [showLeadingIcon && leadingIcon && getIconComponent(leadingIcon, iconProps), text, showTrailingIcon && trailingIcon && getIconComponent(trailingIcon, iconProps)] }));
223
+ };
224
+ return (_jsx(Button, { onClick: onClick ? onClick : () => { }, type: type, disabled: state === ButtonState.Disabled || disabled, sx: {
225
+ textTransform: "none",
226
+ ...sizeStyles,
227
+ borderRadius: getButtonShape(),
228
+ background: getBackgroundColor(),
229
+ color: getTextColor(),
230
+ border: `1px solid ${getBorderColor()}`,
231
+ boxShadow: state === ButtonState.Default ? 'var(--global-shadows-shadow-xs-offset-x) var(--global-shadows-shadow-xs-offset-y) var(--global-shadows-shadow-xs-blur) var(--global-shadows-shadow-xs-spread) var(--global-shadows-shadow-xs-color)' : 'none',
232
+ display: 'flex',
233
+ alignItems: 'center',
234
+ justifyContent: 'center',
235
+ minWidth: 'unset',
236
+ cursor: state === ButtonState.Disabled ? 'not-allowed' : 'pointer',
237
+ pointerEvents: state === ButtonState.Disabled ? 'none' : 'auto',
238
+ transition: 'all 0.2s ease-in-out',
239
+ '& > div': {
240
+ gap: sizeStyles.gap,
241
+ },
242
+ '&:hover': {
243
+ background: getBackgroundColor(true),
244
+ color: getTextColor(),
245
+ border: `1px solid ${getBorderColor(true)}`,
246
+ },
247
+ '&:disabled': {
248
+ background: getBackgroundColor(false),
249
+ color: getTextColor(),
250
+ border: `1px solid ${getBorderColor(false)}`,
251
+ cursor: 'not-allowed',
252
+ },
253
+ ...style,
254
+ }, children: renderContent() }));
255
+ };
256
+ export const Components = () => {
257
+ return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Buttons" }), _jsxs("div", { style: { display: 'flex', gap: '1rem', flexDirection: 'column' }, children: [_jsxs("div", { children: [_jsx("h2", { children: "Size: xl, Hierarchy: Primary" }), _jsx(MainButton, { text: "Primary Button", size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, destructive: false, showLeadingIcon: true, showTrailingIcon: true, leadingIcon: "Circle", trailingIcon: "Circle", onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "White Variant with Icons" }), _jsx(MainButton, { text: "White Button", size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, showLeadingIcon: true, showTrailingIcon: true, leadingIcon: "Circle", trailingIcon: "Circle", onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "Loading State" }), _jsx(MainButton, { text: "Loading Button", loading: true, size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "Disabled State" }), _jsx(MainButton, { text: "Disabled Button", disabled: true, size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "Destructive Button" }), _jsx(MainButton, { text: "Destructive Button", destructive: true, size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "Leading Icon Only" }), _jsx(MainButton, { text: "Leading Icon Button", size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, showLeadingIcon: true, showTrailingIcon: false, leadingIcon: "Circle", onClick: () => console.log('clicked') })] }), _jsxs("div", { children: [_jsx("h2", { children: "Trailing Icon Only" }), _jsx(MainButton, { text: "Trailing Icon Button", size: ButtonSize.xl, hierarchy: ButtonHierarchy.Primary, displayIcon: "Circle", state: ButtonState.Default, shape: ButtonShape.Square, showLeadingIcon: false, showTrailingIcon: true, trailingIcon: "Circle", onClick: () => console.log('clicked') })] })] })] }));
258
+ };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ interface ColorsProps {
3
+ }
4
+ export declare const Colors: React.FC<ColorsProps>;
5
+ export {};
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ export const Colors = () => {
3
+ return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Colors" }), _jsx("iframe", { style: {
4
+ border: '1px solid rgba(0, 0, 0, 0.1)',
5
+ width: '100%',
6
+ height: '800px',
7
+ borderRadius: '4px',
8
+ }, src: "https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FmIhjz2yJjcpLlIqw6oUivt%2FBeyond-Presence%3Fnode-id%3D4297-7361%26t%3DzNF2FPoCOVmOgBsY-4", allowFullScreen: true })] }));
9
+ };
@@ -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 '@mui/material';
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, children: "Log out" })] })) : (_jsxs(_Fragment, { children: [_jsx(Button, { size: "small", onClick: onLogin, children: "Log in" }), _jsx(Button, { size: "small", onClick: onCreateAccount, children: "Sign up" })] })) })] }) }));
@@ -0,0 +1,18 @@
1
+ import type { StoryObj } from '@storybook/react';
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("@vitest/spy").Mock<(...args: any[]) => any>;
11
+ onLogout: import("@vitest/spy").Mock<(...args: any[]) => any>;
12
+ onCreateAccount: import("@vitest/spy").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,3 @@
1
+ import React from 'react';
2
+ import './page.css';
3
+ export declare const Page: React.FC;
@@ -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';
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/component-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,108 @@
1
+ import type { SxProps, Theme } from '@mui/material';
2
+ import * as PhosphorIcons from '@phosphor-icons/react';
3
+ /**
4
+ * Button size variants
5
+ */
6
+ export declare enum ButtonSize {
7
+ xl = "xl",
8
+ lg = "lg",
9
+ md = "md",
10
+ sm = "sm",
11
+ xs = "xs",
12
+ xxs = "xxs"
13
+ }
14
+ /**
15
+ * Button hierarchy variants
16
+ */
17
+ export declare enum ButtonHierarchy {
18
+ Primary = "Primary",
19
+ Secondary = "Secondary",
20
+ SecondaryColor = "Secondary-color",
21
+ SecondaryTransparent = "Secondary-transparent",
22
+ Tetriary = "Tetriary",
23
+ TetriaryColor = "Tetriary-color"
24
+ }
25
+ /**
26
+ * Button states
27
+ */
28
+ export declare enum ButtonState {
29
+ Default = "Default",
30
+ Hover = "Hover",
31
+ Disabled = "Disabled"
32
+ }
33
+ /**
34
+ * Button shape variants
35
+ */
36
+ export declare enum ButtonShape {
37
+ Square = "Square",
38
+ Circle = "Circle"
39
+ }
40
+ /**
41
+ * Button display modes for icons
42
+ */
43
+ export declare enum ButtonDisplayMode {
44
+ Default = "Default",
45
+ Only = "Only"
46
+ }
47
+ /**
48
+ * Button HTML types
49
+ */
50
+ export declare enum ButtonType {
51
+ Button = "button",
52
+ Submit = "submit",
53
+ Reset = "reset"
54
+ }
55
+ /**
56
+ * Size configuration for a button
57
+ */
58
+ export interface ButtonSizeConfig {
59
+ width: string;
60
+ height: string;
61
+ padding: string;
62
+ fontSize: string;
63
+ gap: string;
64
+ }
65
+ /**
66
+ * Main button component props
67
+ */
68
+ export interface MainButtonProps {
69
+ /** Click handler for the button */
70
+ onClick?: () => void | Promise<boolean> | Promise<void>;
71
+ /** Text content of the button */
72
+ text: string;
73
+ /** Whether the button is disabled */
74
+ disabled?: boolean;
75
+ /** Whether the button is in loading state */
76
+ loading?: boolean;
77
+ /** HTML button type */
78
+ type?: ButtonType;
79
+ /** Custom styles for the button */
80
+ style?: SxProps<Theme>;
81
+ /** Size variant of the button */
82
+ size?: ButtonSize;
83
+ /** Visual hierarchy of the button */
84
+ hierarchy?: ButtonHierarchy;
85
+ /** Icon to display when in icon mode */
86
+ displayIcon?: keyof typeof PhosphorIcons;
87
+ /** How to display the icon */
88
+ displayIconMode?: ButtonDisplayMode;
89
+ /** Current state of the button */
90
+ state?: ButtonState;
91
+ /** Shape of the button */
92
+ shape?: ButtonShape;
93
+ /** Whether the button is destructive */
94
+ destructive?: boolean;
95
+ /** Whether to show the leading icon */
96
+ showLeadingIcon?: boolean;
97
+ /** Whether to show the trailing icon */
98
+ showTrailingIcon?: boolean;
99
+ /** Icon to show at the start of the button */
100
+ leadingIcon?: keyof typeof PhosphorIcons;
101
+ /** Icon to show at the end of the button */
102
+ trailingIcon?: keyof typeof PhosphorIcons;
103
+ }
104
+ /**
105
+ * Props for the Components wrapper
106
+ */
107
+ export interface ComponentsProps {
108
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Button size variants
3
+ */
4
+ export var ButtonSize;
5
+ (function (ButtonSize) {
6
+ ButtonSize["xl"] = "xl";
7
+ ButtonSize["lg"] = "lg";
8
+ ButtonSize["md"] = "md";
9
+ ButtonSize["sm"] = "sm";
10
+ ButtonSize["xs"] = "xs";
11
+ ButtonSize["xxs"] = "xxs";
12
+ })(ButtonSize || (ButtonSize = {}));
13
+ /**
14
+ * Button hierarchy variants
15
+ */
16
+ export var ButtonHierarchy;
17
+ (function (ButtonHierarchy) {
18
+ ButtonHierarchy["Primary"] = "Primary";
19
+ ButtonHierarchy["Secondary"] = "Secondary";
20
+ ButtonHierarchy["SecondaryColor"] = "Secondary-color";
21
+ ButtonHierarchy["SecondaryTransparent"] = "Secondary-transparent";
22
+ ButtonHierarchy["Tetriary"] = "Tetriary";
23
+ ButtonHierarchy["TetriaryColor"] = "Tetriary-color";
24
+ })(ButtonHierarchy || (ButtonHierarchy = {}));
25
+ /**
26
+ * Button states
27
+ */
28
+ export var ButtonState;
29
+ (function (ButtonState) {
30
+ ButtonState["Default"] = "Default";
31
+ ButtonState["Hover"] = "Hover";
32
+ ButtonState["Disabled"] = "Disabled";
33
+ })(ButtonState || (ButtonState = {}));
34
+ /**
35
+ * Button shape variants
36
+ */
37
+ export var ButtonShape;
38
+ (function (ButtonShape) {
39
+ ButtonShape["Square"] = "Square";
40
+ ButtonShape["Circle"] = "Circle";
41
+ })(ButtonShape || (ButtonShape = {}));
42
+ /**
43
+ * Button display modes for icons
44
+ */
45
+ export var ButtonDisplayMode;
46
+ (function (ButtonDisplayMode) {
47
+ ButtonDisplayMode["Default"] = "Default";
48
+ ButtonDisplayMode["Only"] = "Only";
49
+ })(ButtonDisplayMode || (ButtonDisplayMode = {}));
50
+ /**
51
+ * Button HTML types
52
+ */
53
+ export var ButtonType;
54
+ (function (ButtonType) {
55
+ ButtonType["Button"] = "button";
56
+ ButtonType["Submit"] = "submit";
57
+ ButtonType["Reset"] = "reset";
58
+ })(ButtonType || (ButtonType = {}));
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@beydesign/storybook",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "dev": "vite",
14
+ "build": "tsc && vite build",
15
+ "build:lib": "tsc",
16
+ "lint": "eslint .",
17
+ "preview": "vite preview",
18
+ "storybook": "storybook dev -p 6006",
19
+ "build-storybook": "storybook build"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "dependencies": {
25
+ "@beydesign/tokens": "latest",
26
+ "@emotion/react": "^11.11.4",
27
+ "@emotion/styled": "^11.11.0",
28
+ "@fortawesome/fontawesome-svg-core": "^6.5.1",
29
+ "@fortawesome/free-solid-svg-icons": "^6.5.1",
30
+ "@fortawesome/react-fontawesome": "^0.2.0",
31
+ "@mui/icons-material": "^5.15.12",
32
+ "@mui/material": "^5.15.12",
33
+ "@phosphor-icons/react": "^2.1.7",
34
+ "react": "^18.2.0",
35
+ "react-dom": "^18.2.0",
36
+ "style-dictionary": "^4.3.2",
37
+ "token-transformer": "^0.0.33"
38
+ },
39
+ "devDependencies": {
40
+ "@chromatic-com/storybook": "^3.2.4",
41
+ "@storybook/addon-designs": "^8.0.4",
42
+ "@storybook/addon-essentials": "^8.5.2",
43
+ "@storybook/addon-interactions": "^8.5.2",
44
+ "@storybook/addon-onboarding": "^8.5.2",
45
+ "@storybook/addon-themes": "^8.5.3",
46
+ "@storybook/blocks": "^8.5.2",
47
+ "@storybook/react": "^8.5.2",
48
+ "@storybook/react-vite": "^8.5.2",
49
+ "@storybook/test": "^8.5.2",
50
+ "@types/react": "^18.3.2",
51
+ "@types/react-dom": "^18.3.0",
52
+ "@vitejs/plugin-react": "^4.2.1",
53
+ "autoprefixer": "^10.4.18",
54
+ "eslint": "^8.57.0",
55
+ "eslint-config-prettier": "^9.1.0",
56
+ "eslint-plugin-jsx-a11y": "^6.8.0",
57
+ "eslint-plugin-prettier": "^5.1.3",
58
+ "eslint-plugin-react": "^7.34.0",
59
+ "eslint-plugin-react-hooks": "^4.6.0",
60
+ "eslint-plugin-react-refresh": "^0.4.5",
61
+ "eslint-plugin-storybook": "^0.11.2",
62
+ "postcss": "^8.4.35",
63
+ "prettier": "3.2.5",
64
+ "storybook": "^8.5.2",
65
+ "vite": "^5.1.6"
66
+ },
67
+ "eslintConfig": {
68
+ "extends": [
69
+ "plugin:storybook/recommended"
70
+ ]
71
+ }
72
+ }