@beydesign/storybook 0.0.1 → 0.0.4

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.
Files changed (43) hide show
  1. package/README.md +49 -40
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/stories/Avatar.d.ts +4 -0
  5. package/dist/stories/Avatar.js +79 -0
  6. package/dist/stories/Avatar.stories.d.ts +8 -0
  7. package/dist/stories/Avatar.stories.js +76 -0
  8. package/dist/stories/Badge.stories.d.ts +11 -0
  9. package/dist/stories/Badge.stories.js +98 -0
  10. package/dist/stories/Bagde.d.ts +3 -0
  11. package/dist/stories/Bagde.js +113 -0
  12. package/dist/stories/Button.js +62 -23
  13. package/dist/stories/Button.stories.d.ts +27 -0
  14. package/dist/stories/Button.stories.js +295 -0
  15. package/dist/stories/Checkbox.d.ts +3 -0
  16. package/dist/stories/Checkbox.js +66 -0
  17. package/dist/stories/Checkbox.stories.d.ts +13 -0
  18. package/dist/stories/Checkbox.stories.js +121 -0
  19. package/dist/stories/Colors.d.ts +1 -4
  20. package/dist/stories/Colors.js +251 -6
  21. package/dist/stories/Colors.stories.d.ts +6 -0
  22. package/dist/stories/Colors.stories.js +10 -0
  23. package/dist/stories/Typography.d.ts +4 -0
  24. package/dist/stories/Typography.js +36 -0
  25. package/dist/stories/Typography.stories.d.ts +25 -0
  26. package/dist/stories/Typography.stories.js +189 -0
  27. package/dist/stories/types/avatar.d.ts +44 -0
  28. package/dist/stories/types/avatar.js +28 -0
  29. package/dist/stories/types/badge.d.ts +47 -0
  30. package/dist/stories/types/badge.js +25 -0
  31. package/dist/stories/types/checkbox.d.ts +26 -0
  32. package/dist/stories/types/checkbox.js +5 -0
  33. package/dist/stories/types/typography.d.ts +43 -0
  34. package/dist/stories/types/typography.js +27 -0
  35. package/package.json +10 -5
  36. package/dist/stories/Header.d.ts +0 -12
  37. package/dist/stories/Header.js +0 -4
  38. package/dist/stories/Header.stories.d.ts +0 -18
  39. package/dist/stories/Header.stories.js +0 -26
  40. package/dist/stories/Page.d.ts +0 -3
  41. package/dist/stories/Page.js +0 -8
  42. package/dist/stories/Page.stories.d.ts +0 -12
  43. package/dist/stories/Page.stories.js +0 -24
@@ -0,0 +1,189 @@
1
+ import { Typography } from './Typography';
2
+ import { TypographySize, TypographyWeight } from './types/typography';
3
+ const meta = {
4
+ title: 'Design System/Foundations/Typography',
5
+ component: Typography,
6
+ parameters: {
7
+ layout: 'centered',
8
+ design: {
9
+ type: 'figspec',
10
+ url: 'https://www.figma.com/design/mIhjz2yJjcpLlIqw6oUivt/Beyond-Presence?node-id=4312-2152&t=mUqFCoPkymh9swiA-1',
11
+ },
12
+ },
13
+ tags: ['autodocs'],
14
+ argTypes: {
15
+ text: {
16
+ control: 'text',
17
+ description: 'Typography text content',
18
+ table: {
19
+ type: { summary: 'string' },
20
+ },
21
+ },
22
+ size: {
23
+ control: 'select',
24
+ options: Object.values(TypographySize),
25
+ description: 'Size of the typography',
26
+ table: {
27
+ type: { summary: 'string' },
28
+ defaultValue: { summary: 'HeadingXL' },
29
+ },
30
+ },
31
+ weight: {
32
+ control: 'select',
33
+ options: Object.values(TypographyWeight),
34
+ description: 'Weight of the typography',
35
+ table: {
36
+ type: { summary: 'string' },
37
+ defaultValue: { summary: 'Bold' },
38
+ },
39
+ },
40
+ color: {
41
+ control: 'color',
42
+ description: 'Color of the typography',
43
+ table: {
44
+ type: { summary: 'string' },
45
+ },
46
+ },
47
+ },
48
+ };
49
+ export default meta;
50
+ export const HeadingXLBold = {
51
+ args: {
52
+ text: 'Typography',
53
+ size: TypographySize.HeadingXL,
54
+ weight: TypographyWeight.Bold,
55
+ },
56
+ };
57
+ export const HeadingXLSemiBold = {
58
+ args: {
59
+ text: 'Typography',
60
+ size: TypographySize.HeadingXL,
61
+ weight: TypographyWeight.SemiBold,
62
+ },
63
+ };
64
+ export const HeadingXLMedium = {
65
+ args: {
66
+ text: 'Typography',
67
+ size: TypographySize.HeadingXL,
68
+ weight: TypographyWeight.Medium,
69
+ },
70
+ };
71
+ export const HeadingXLRegular = {
72
+ args: {
73
+ text: 'Typography',
74
+ size: TypographySize.HeadingXL,
75
+ weight: TypographyWeight.Regular,
76
+ },
77
+ };
78
+ export const HeadingLBold = {
79
+ args: {
80
+ text: 'Typography',
81
+ size: TypographySize.HeadingL,
82
+ weight: TypographyWeight.Bold,
83
+ },
84
+ };
85
+ export const HeadingLSemiBold = {
86
+ args: {
87
+ text: 'Typography',
88
+ size: TypographySize.HeadingL,
89
+ weight: TypographyWeight.SemiBold,
90
+ },
91
+ };
92
+ export const HeadingLMedium = {
93
+ args: {
94
+ text: 'Typography',
95
+ size: TypographySize.HeadingL,
96
+ weight: TypographyWeight.Medium,
97
+ },
98
+ };
99
+ export const HeadingLRegular = {
100
+ args: {
101
+ text: 'Typography',
102
+ size: TypographySize.HeadingL,
103
+ weight: TypographyWeight.Regular,
104
+ },
105
+ };
106
+ export const HeadingMBold = {
107
+ args: {
108
+ text: 'Typography',
109
+ size: TypographySize.HeadingM,
110
+ weight: TypographyWeight.Bold,
111
+ },
112
+ };
113
+ export const Heading2XSRegular = {
114
+ args: {
115
+ text: 'Typography',
116
+ size: TypographySize.Heading2XS,
117
+ weight: TypographyWeight.Regular,
118
+ },
119
+ };
120
+ export const TextLBold = {
121
+ args: {
122
+ text: 'Typography',
123
+ size: TypographySize.TextL,
124
+ weight: TypographyWeight.Bold,
125
+ },
126
+ };
127
+ export const TextLSemiBold = {
128
+ args: {
129
+ text: 'Typography',
130
+ size: TypographySize.TextL,
131
+ weight: TypographyWeight.SemiBold,
132
+ },
133
+ };
134
+ export const TextLMedium = {
135
+ args: {
136
+ text: 'Typography',
137
+ size: TypographySize.TextL,
138
+ weight: TypographyWeight.Medium,
139
+ },
140
+ };
141
+ export const TextLRegular = {
142
+ args: {
143
+ text: 'Typography',
144
+ size: TypographySize.TextL,
145
+ weight: TypographyWeight.Regular,
146
+ },
147
+ };
148
+ export const TextMBold = {
149
+ args: {
150
+ text: 'Typography',
151
+ size: TypographySize.TextM,
152
+ weight: TypographyWeight.Bold,
153
+ },
154
+ };
155
+ export const TextMSemiBold = {
156
+ args: {
157
+ text: 'Typography',
158
+ size: TypographySize.TextM,
159
+ weight: TypographyWeight.SemiBold,
160
+ },
161
+ };
162
+ export const TextMMedium = {
163
+ args: {
164
+ text: 'Typography',
165
+ size: TypographySize.TextM,
166
+ weight: TypographyWeight.Medium,
167
+ },
168
+ };
169
+ export const TextMRegular = {
170
+ args: {
171
+ text: 'Typography',
172
+ size: TypographySize.TextM,
173
+ weight: TypographyWeight.Regular,
174
+ },
175
+ };
176
+ export const TextSBold = {
177
+ args: {
178
+ text: 'Typography',
179
+ size: TypographySize.TextS,
180
+ weight: TypographyWeight.Bold,
181
+ },
182
+ };
183
+ export const TextSSemiBold = {
184
+ args: {
185
+ text: 'Typography',
186
+ size: TypographySize.TextS,
187
+ weight: TypographyWeight.SemiBold,
188
+ },
189
+ };
@@ -0,0 +1,44 @@
1
+ import type { SxProps, Theme } from '@mui/material';
2
+ /**
3
+ * Avatar size variants
4
+ */
5
+ export declare enum AvatarSize {
6
+ xxl = "xxl",
7
+ xl = "xl",
8
+ lg = "lg",
9
+ md = "md",
10
+ sm = "sm",
11
+ xs = "xs"
12
+ }
13
+ /**
14
+ * Avatar style variants
15
+ */
16
+ export declare enum AvatarStyle {
17
+ Placeholder = "Placeholder",
18
+ Picture = "Picture",
19
+ Letters = "Letters"
20
+ }
21
+ export declare const AvatarImage = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTTAUPUG0r--EDZzf-f9Afj_Jp7N96yIGsWPgCYIkrAS1rCJHIcdm_RCq_me44bJc0dvvY&usqp=CAU";
22
+ export declare const getInitials: (text: string) => string;
23
+ /**
24
+ * Avatar component props
25
+ */
26
+ export type AvatarProps = {
27
+ /** Style variant of the avatar */
28
+ avatarStyle: AvatarStyle;
29
+ /** Text content of the avatar if avatarStyle is Letters */
30
+ text?: string;
31
+ /** Image source of the avatar if avatarStyle is Picture */
32
+ image?: string;
33
+ /** Custom style of the avatar */
34
+ style?: SxProps<Theme>;
35
+ /** Size variant of the avatar */
36
+ size?: AvatarSize;
37
+ /** Visual hierarchy of the avatar */
38
+ border?: boolean;
39
+ };
40
+ /**
41
+ * Props for the Components wrapper
42
+ */
43
+ export interface ComponentsProps {
44
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Avatar size variants
3
+ */
4
+ export var AvatarSize;
5
+ (function (AvatarSize) {
6
+ AvatarSize["xxl"] = "xxl";
7
+ AvatarSize["xl"] = "xl";
8
+ AvatarSize["lg"] = "lg";
9
+ AvatarSize["md"] = "md";
10
+ AvatarSize["sm"] = "sm";
11
+ AvatarSize["xs"] = "xs";
12
+ })(AvatarSize || (AvatarSize = {}));
13
+ /**
14
+ * Avatar style variants
15
+ */
16
+ export var AvatarStyle;
17
+ (function (AvatarStyle) {
18
+ AvatarStyle["Placeholder"] = "Placeholder";
19
+ AvatarStyle["Picture"] = "Picture";
20
+ AvatarStyle["Letters"] = "Letters";
21
+ })(AvatarStyle || (AvatarStyle = {}));
22
+ export const AvatarImage = `https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTTAUPUG0r--EDZzf-f9Afj_Jp7N96yIGsWPgCYIkrAS1rCJHIcdm_RCq_me44bJc0dvvY&usqp=CAU`;
23
+ export const getInitials = (text) => {
24
+ return text
25
+ .split(' ')
26
+ .map((word) => word[0]?.toUpperCase())
27
+ .join('');
28
+ };
@@ -0,0 +1,47 @@
1
+ import type { SxProps, Theme } from '@mui/material';
2
+ import * as PhosphorIcons from '@phosphor-icons/react';
3
+ /**
4
+ * Badge size variants
5
+ */
6
+ export declare enum BadgeSize {
7
+ lg = "lg",
8
+ md = "md",
9
+ xs = "xs"
10
+ }
11
+ /**
12
+ * Badge color variants
13
+ */
14
+ export declare enum BadgeColor {
15
+ Default = "Default",
16
+ Violet = "Violet",
17
+ Lemon = "Lemon",
18
+ Green = "Green",
19
+ Red = "Red",
20
+ Yellow = "Yellow",
21
+ Blue = "Blue",
22
+ Cyan = "Cyan",
23
+ Pink = "Pink",
24
+ DarkTransparent = "DarkTransparent"
25
+ }
26
+ /**
27
+ * Badge component props
28
+ */
29
+ export type BadgeProps = {
30
+ /** Size variant of the badge */
31
+ size?: BadgeSize;
32
+ /** Color variant of the badge */
33
+ color?: BadgeColor;
34
+ /** Text content of the badge */
35
+ text: string;
36
+ /** Custom style of the badge */
37
+ style?: SxProps<Theme>;
38
+ /** Icon to display in the badge */
39
+ icon?: keyof typeof PhosphorIcons;
40
+ /** Whether to fill the icon */
41
+ fill?: boolean;
42
+ };
43
+ /**
44
+ * Props for the Components wrapper
45
+ */
46
+ export interface ComponentsProps {
47
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Badge size variants
3
+ */
4
+ export var BadgeSize;
5
+ (function (BadgeSize) {
6
+ BadgeSize["lg"] = "lg";
7
+ BadgeSize["md"] = "md";
8
+ BadgeSize["xs"] = "xs";
9
+ })(BadgeSize || (BadgeSize = {}));
10
+ /**
11
+ * Badge color variants
12
+ */
13
+ export var BadgeColor;
14
+ (function (BadgeColor) {
15
+ BadgeColor["Default"] = "Default";
16
+ BadgeColor["Violet"] = "Violet";
17
+ BadgeColor["Lemon"] = "Lemon";
18
+ BadgeColor["Green"] = "Green";
19
+ BadgeColor["Red"] = "Red";
20
+ BadgeColor["Yellow"] = "Yellow";
21
+ BadgeColor["Blue"] = "Blue";
22
+ BadgeColor["Cyan"] = "Cyan";
23
+ BadgeColor["Pink"] = "Pink";
24
+ BadgeColor["DarkTransparent"] = "DarkTransparent";
25
+ })(BadgeColor || (BadgeColor = {}));
@@ -0,0 +1,26 @@
1
+ export declare enum CheckboxType {
2
+ Radio = "Radio",
3
+ Checkbox = "Checkbox"
4
+ }
5
+ /**
6
+ * Checkbox component props
7
+ */
8
+ export type CheckboxProps = {
9
+ /** Type variant of the checkbox */
10
+ type?: CheckboxType;
11
+ /** Label of the checkbox */
12
+ label: string;
13
+ /** Whether the checkbox is checked */
14
+ checked?: boolean;
15
+ /** Whether the checkbox is disabled */
16
+ disabled?: boolean;
17
+ /** Whether the checkbox is read-only */
18
+ required?: boolean;
19
+ /** Event handler for the checkbox */
20
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
21
+ };
22
+ /**
23
+ * Props for the Components wrapper
24
+ */
25
+ export interface ComponentsProps {
26
+ }
@@ -0,0 +1,5 @@
1
+ export var CheckboxType;
2
+ (function (CheckboxType) {
3
+ CheckboxType["Radio"] = "Radio";
4
+ CheckboxType["Checkbox"] = "Checkbox";
5
+ })(CheckboxType || (CheckboxType = {}));
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Typography size variants
3
+ */
4
+ export declare enum TypographySize {
5
+ HeadingXL = "HeadingXL",
6
+ HeadingL = "HeadingL",
7
+ HeadingM = "HeadingM",
8
+ HeadingS = "HeadingS",
9
+ HeadingXS = "HeadingXS",
10
+ Heading2XS = "Heading2XS",
11
+ TextL = "TextL",
12
+ TextM = "TextM",
13
+ TextS = "TextS",
14
+ TextXS = "TextXS",
15
+ Text2XS = "Text2XS"
16
+ }
17
+ /**
18
+ * Typography weight variants
19
+ */
20
+ export declare enum TypographyWeight {
21
+ Bold = "Bold",
22
+ SemiBold = "SemiBold",
23
+ Medium = "Medium",
24
+ Regular = "Regular"
25
+ }
26
+ /**
27
+ * Typography component props
28
+ */
29
+ export interface TypographyProps {
30
+ /** Text content of the typography */
31
+ text: string;
32
+ /** Size variant of the typography */
33
+ size?: TypographySize;
34
+ /** Weight variant of the typography */
35
+ weight?: TypographyWeight;
36
+ /** Color variant of the typography */
37
+ color?: string;
38
+ }
39
+ /**
40
+ * Props for the Components wrapper
41
+ */
42
+ export interface ComponentsProps {
43
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Typography size variants
3
+ */
4
+ export var TypographySize;
5
+ (function (TypographySize) {
6
+ TypographySize["HeadingXL"] = "HeadingXL";
7
+ TypographySize["HeadingL"] = "HeadingL";
8
+ TypographySize["HeadingM"] = "HeadingM";
9
+ TypographySize["HeadingS"] = "HeadingS";
10
+ TypographySize["HeadingXS"] = "HeadingXS";
11
+ TypographySize["Heading2XS"] = "Heading2XS";
12
+ TypographySize["TextL"] = "TextL";
13
+ TypographySize["TextM"] = "TextM";
14
+ TypographySize["TextS"] = "TextS";
15
+ TypographySize["TextXS"] = "TextXS";
16
+ TypographySize["Text2XS"] = "Text2XS";
17
+ })(TypographySize || (TypographySize = {}));
18
+ /**
19
+ * Typography weight variants
20
+ */
21
+ export var TypographyWeight;
22
+ (function (TypographyWeight) {
23
+ TypographyWeight["Bold"] = "Bold";
24
+ TypographyWeight["SemiBold"] = "SemiBold";
25
+ TypographyWeight["Medium"] = "Medium";
26
+ TypographyWeight["Regular"] = "Regular";
27
+ })(TypographyWeight || (TypographyWeight = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.0.1",
4
+ "version": "0.0.4",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -15,8 +15,11 @@
15
15
  "build:lib": "tsc",
16
16
  "lint": "eslint .",
17
17
  "preview": "vite preview",
18
- "storybook": "storybook dev -p 6006",
19
- "build-storybook": "storybook build"
18
+ "storybook": "npm update @beydesign/tokens && storybook dev -p 6006",
19
+ "build-storybook": "storybook build",
20
+ "version:patch": "npm version patch -m \"🔖 Release %s\"",
21
+ "version:minor": "npm version minor -m \"🔖 Release %s\"",
22
+ "version:major": "npm version major -m \"🔖 Release %s\""
20
23
  },
21
24
  "publishConfig": {
22
25
  "access": "public"
@@ -33,8 +36,7 @@
33
36
  "@phosphor-icons/react": "^2.1.7",
34
37
  "react": "^18.2.0",
35
38
  "react-dom": "^18.2.0",
36
- "style-dictionary": "^4.3.2",
37
- "token-transformer": "^0.0.33"
39
+ "typescript": "~5.5.0"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@chromatic-com/storybook": "^3.2.4",
@@ -49,6 +51,8 @@
49
51
  "@storybook/test": "^8.5.2",
50
52
  "@types/react": "^18.3.2",
51
53
  "@types/react-dom": "^18.3.0",
54
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
55
+ "@typescript-eslint/parser": "^7.1.1",
52
56
  "@vitejs/plugin-react": "^4.2.1",
53
57
  "autoprefixer": "^10.4.18",
54
58
  "eslint": "^8.57.0",
@@ -62,6 +66,7 @@
62
66
  "postcss": "^8.4.35",
63
67
  "prettier": "3.2.5",
64
68
  "storybook": "^8.5.2",
69
+ "typescript-eslint": "^7.1.1",
65
70
  "vite": "^5.1.6"
66
71
  },
67
72
  "eslintConfig": {
@@ -1,12 +0,0 @@
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 {};
@@ -1,4 +0,0 @@
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" })] })) })] }) }));
@@ -1,18 +0,0 @@
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;
@@ -1,26 +0,0 @@
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 = {};
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import './page.css';
3
- export declare const Page: React.FC;
@@ -1,8 +0,0 @@
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
- };
@@ -1,12 +0,0 @@
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;
@@ -1,24 +0,0 @@
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
- };