@menumalsuite/design-system 0.0.2 → 0.0.3
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/app/components/MButton/MButton.mdx +32 -0
- package/app/components/MButton/MButton.stories.ts +11 -11
- package/app/components/MHeader/MHeader.mdx +33 -1
- package/app/components/MHeader/MHeader.stories.ts +7 -7
- package/app/components/MPage/MPage.mdx +30 -1
- package/app/components/MPage/MPage.stories.ts +8 -8
- package/package.json +1 -1
|
@@ -28,6 +28,38 @@ Core interactive element for actions and navigation.
|
|
|
28
28
|
|
|
29
29
|
<Controls />
|
|
30
30
|
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Basic button:
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<MButton label="Save" primary @click="handleSave" />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Secondary action:
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<MButton label="Cancel" @click="handleCancel" />
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Navigation — pushes route via `useRouter`:
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<MButton label="Go to dashboard" to="/dashboard" />
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
API call — fires `$fetch` on click, shows inline loading/ok/error:
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<MButton label="Submit" apiUrl="/api/submit" primary />
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Small in a table row:
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<MButton label="Edit" size="small" @click="edit(row.id)" />
|
|
61
|
+
```
|
|
62
|
+
|
|
31
63
|
## Notes
|
|
32
64
|
|
|
33
65
|
- `to` triggers internal navigation via `useRouter`
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { fn } from
|
|
3
|
-
import MButton from
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { fn } from "storybook/test";
|
|
3
|
+
import MButton from "./MButton.vue";
|
|
4
4
|
|
|
5
5
|
const meta = {
|
|
6
|
-
title:
|
|
6
|
+
title: "Components/MButton",
|
|
7
7
|
component: MButton,
|
|
8
|
-
tags: ['autodocs'],
|
|
8
|
+
// tags: ['autodocs'],
|
|
9
9
|
argTypes: {
|
|
10
|
-
size: { control:
|
|
11
|
-
backgroundColor: { control:
|
|
10
|
+
size: { control: "select", options: ["small", "medium", "large"] },
|
|
11
|
+
backgroundColor: { control: "color" },
|
|
12
12
|
},
|
|
13
13
|
args: {
|
|
14
14
|
primary: false,
|
|
@@ -20,17 +20,17 @@ export default meta;
|
|
|
20
20
|
type Story = StoryObj<typeof meta>;
|
|
21
21
|
|
|
22
22
|
export const Primary: Story = {
|
|
23
|
-
args: { primary: true, label:
|
|
23
|
+
args: { primary: true, label: "Button" },
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const Secondary: Story = {
|
|
27
|
-
args: { primary: false, label:
|
|
27
|
+
args: { primary: false, label: "Button" },
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
export const Large: Story = {
|
|
31
|
-
args: { label:
|
|
31
|
+
args: { label: "Button", size: "large" },
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const Small: Story = {
|
|
35
|
-
args: { label:
|
|
35
|
+
args: { label: "Button", size: "small" },
|
|
36
36
|
};
|
|
@@ -20,8 +20,40 @@ Global layout component — place in `app.vue` or the main layout. One instance
|
|
|
20
20
|
|
|
21
21
|
<Controls />
|
|
22
22
|
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
In `app.vue` or a layout file:
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<template>
|
|
29
|
+
<MHeader
|
|
30
|
+
:user="authUser"
|
|
31
|
+
@login="openLoginModal"
|
|
32
|
+
@logout="signOut"
|
|
33
|
+
@create-account="openSignupModal"
|
|
34
|
+
/>
|
|
35
|
+
<slot />
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup>
|
|
39
|
+
const authUser = useCurrentUser()
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Logged-out state:
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<MHeader :user="null" @login="handleLogin" @create-account="handleSignup" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Logged-in state:
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<MHeader :user="{ name: 'Jane Doe' }" @logout="handleLogout" />
|
|
53
|
+
```
|
|
54
|
+
|
|
23
55
|
## Notes
|
|
24
56
|
|
|
25
57
|
- Handles three events internally: `login`, `logout`, `createAccount`
|
|
26
58
|
- The `user` prop is `null` when unauthenticated
|
|
27
|
-
- Internal buttons use `<
|
|
59
|
+
- Internal buttons use `<MButton>` from the design system
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { fn } from
|
|
3
|
-
import MHeader from
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { fn } from "storybook/test";
|
|
3
|
+
import MHeader from "./MHeader.vue";
|
|
4
4
|
|
|
5
5
|
const meta = {
|
|
6
|
-
title:
|
|
6
|
+
title: "Components/MHeader",
|
|
7
7
|
component: MHeader,
|
|
8
|
-
parameters: { layout:
|
|
8
|
+
parameters: { layout: "fullscreen" },
|
|
9
9
|
args: {
|
|
10
10
|
onLogin: fn(),
|
|
11
11
|
onLogout: fn(),
|
|
12
12
|
onCreateAccount: fn(),
|
|
13
13
|
},
|
|
14
|
-
tags: ['autodocs'],
|
|
14
|
+
// tags: ['autodocs'],
|
|
15
15
|
} satisfies Meta<typeof MHeader>;
|
|
16
16
|
|
|
17
17
|
export default meta;
|
|
18
18
|
type Story = StoryObj<typeof meta>;
|
|
19
19
|
|
|
20
20
|
export const LoggedIn: Story = {
|
|
21
|
-
args: { user: { name:
|
|
21
|
+
args: { user: { name: "Jane Doe" } },
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const LoggedOut: Story = {
|
|
@@ -20,8 +20,37 @@ Starting point for new pages — includes `<Header>` and manages authentication
|
|
|
20
20
|
|
|
21
21
|
<Controls />
|
|
22
22
|
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Basic page:
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<MPage />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Extended with custom content via default slot:
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<MPage>
|
|
35
|
+
<section>
|
|
36
|
+
<h2>Welcome</h2>
|
|
37
|
+
<p>Your dashboard content here.</p>
|
|
38
|
+
</section>
|
|
39
|
+
</MPage>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Inside a Nuxt layout (`layouts/default.vue`):
|
|
43
|
+
|
|
44
|
+
```vue
|
|
45
|
+
<template>
|
|
46
|
+
<MPage>
|
|
47
|
+
<slot />
|
|
48
|
+
</MPage>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
23
52
|
## Notes
|
|
24
53
|
|
|
25
54
|
- Manages `user` state internally — no need to pass it from outside
|
|
26
|
-
- Composes `<
|
|
55
|
+
- Composes `<MHeader>` + `<MButton>` from the design system
|
|
27
56
|
- Extend with slots for page-specific content
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { expect, userEvent, within } from
|
|
3
|
-
import MPage from
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/vue3-vite";
|
|
2
|
+
import { expect, userEvent, within } from "storybook/test";
|
|
3
|
+
import MPage from "./MPage.vue";
|
|
4
4
|
|
|
5
5
|
const meta = {
|
|
6
|
-
title:
|
|
6
|
+
title: "Components/MPage",
|
|
7
7
|
component: MPage,
|
|
8
|
-
parameters: { layout:
|
|
9
|
-
tags: ['autodocs'],
|
|
8
|
+
parameters: { layout: "fullscreen" },
|
|
9
|
+
// tags: ['autodocs'],
|
|
10
10
|
} satisfies Meta<typeof MPage>;
|
|
11
11
|
|
|
12
12
|
export default meta;
|
|
@@ -15,12 +15,12 @@ type Story = StoryObj<typeof meta>;
|
|
|
15
15
|
export const LoggedIn: Story = {
|
|
16
16
|
play: async ({ canvasElement }: any) => {
|
|
17
17
|
const canvas = within(canvasElement);
|
|
18
|
-
const loginButton = canvas.getByRole(
|
|
18
|
+
const loginButton = canvas.getByRole("button", { name: /Log in/i });
|
|
19
19
|
await expect(loginButton).toBeInTheDocument();
|
|
20
20
|
await userEvent.click(loginButton);
|
|
21
21
|
await expect(loginButton).not.toBeInTheDocument();
|
|
22
22
|
|
|
23
|
-
const logoutButton = canvas.getByRole(
|
|
23
|
+
const logoutButton = canvas.getByRole("button", { name: /Log out/i });
|
|
24
24
|
await expect(logoutButton).toBeInTheDocument();
|
|
25
25
|
},
|
|
26
26
|
};
|