@menumalsuite/design-system 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,75 @@
1
+ # Nuxt Layer Starter
2
+
3
+ Create Nuxt extendable layer with this GitHub template.
4
+
5
+ ## Setup
6
+
7
+ Make sure to install the dependencies:
8
+
9
+ ```bash
10
+ pnpm install
11
+ ```
12
+
13
+ ## Working on your layer
14
+
15
+ Your layer is at the root of this repository, it is exactly like a regular Nuxt project, except you can publish it on NPM.
16
+
17
+ The `.playground` directory should help you on trying your layer during development.
18
+
19
+ Running `pnpm dev` will prepare and boot `.playground` directory, which imports your layer itself.
20
+
21
+ ## Distributing your layer
22
+
23
+ Your Nuxt layer is shaped exactly the same as any other Nuxt project, except you can publish it on NPM.
24
+
25
+ To do so, you only have to check if `files` in `package.json` are valid, then run:
26
+
27
+ ```bash
28
+ npm publish --access public
29
+ ```
30
+
31
+ Once done, your users will only have to run:
32
+
33
+ ```bash
34
+ npm install --save your-layer
35
+ ```
36
+
37
+ Then add the dependency to their `extends` in `nuxt.config`:
38
+
39
+ ```ts
40
+ defineNuxtConfig({
41
+ extends: "your-layer",
42
+ });
43
+ ```
44
+
45
+ ## Development Server
46
+
47
+ Start the development server on http://localhost:3000
48
+
49
+ ```bash
50
+ pnpm dev
51
+ ```
52
+
53
+ ## Production
54
+
55
+ Build the application for production:
56
+
57
+ ```bash
58
+ pnpm build
59
+ ```
60
+
61
+ Or statically generate it with:
62
+
63
+ ```bash
64
+ pnpm generate
65
+ ```
66
+
67
+ Locally preview production build:
68
+
69
+ ```bash
70
+ pnpm preview
71
+ ```
72
+
73
+ Checkout the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
74
+
75
+ https://storybook.js.org/docs/get-started/frameworks/vue3-vite?renderer=vue&ref=readme
@@ -0,0 +1,36 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { fn } from 'storybook/test';
3
+ import Button from './Button.vue';
4
+
5
+ const meta = {
6
+ title: 'Components/Button',
7
+ component: Button,
8
+ tags: ['autodocs'],
9
+ argTypes: {
10
+ size: { control: 'select', options: ['small', 'medium', 'large'] },
11
+ backgroundColor: { control: 'color' },
12
+ },
13
+ args: {
14
+ primary: false,
15
+ onClick: fn(),
16
+ },
17
+ } satisfies Meta<typeof Button>;
18
+
19
+ export default meta;
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ export const Primary: Story = {
23
+ args: { primary: true, label: 'Button' },
24
+ };
25
+
26
+ export const Secondary: Story = {
27
+ args: { primary: false, label: 'Button' },
28
+ };
29
+
30
+ export const Large: Story = {
31
+ args: { label: 'Button', size: 'large' },
32
+ };
33
+
34
+ export const Small: Story = {
35
+ args: { label: 'Button', size: 'small' },
36
+ };
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <button type="button" :class="classes" @click="onClick" :style="style">
3
+ {{ label }}
4
+ <span v-if="fetchStatus">({{ fetchStatus }})</span>
5
+ </button>
6
+ </template>
7
+
8
+ <script lang="ts" setup>
9
+ const props = withDefaults(
10
+ defineProps<{
11
+ label: string;
12
+ primary?: boolean;
13
+ size?: "small" | "medium" | "large";
14
+ backgroundColor?: string;
15
+ to?: string;
16
+ apiUrl?: string;
17
+ }>(),
18
+ { primary: false },
19
+ );
20
+
21
+ const emit = defineEmits<{
22
+ (e: "click", id: number): void;
23
+ }>();
24
+
25
+ const router = useRouter();
26
+ const fetchStatus = ref<string | null>(null);
27
+
28
+ const classes = computed(() => ({
29
+ "storybook-button": true,
30
+ "storybook-button--primary": props.primary,
31
+ "storybook-button--secondary": !props.primary,
32
+ [`storybook-button--${props.size || "medium"}`]: true,
33
+ }));
34
+
35
+ const style = computed(() => ({
36
+ backgroundColor: props.backgroundColor,
37
+ }));
38
+
39
+ const onClick = async () => {
40
+ emit("click", 1);
41
+
42
+ if (props.apiUrl) {
43
+ fetchStatus.value = "loading...";
44
+ try {
45
+ await $fetch(props.apiUrl);
46
+ fetchStatus.value = "ok";
47
+ } catch {
48
+ fetchStatus.value = "error";
49
+ }
50
+ }
51
+
52
+ if (props.to) {
53
+ await router.push(props.to);
54
+ }
55
+ };
56
+ </script>
57
+
58
+ <style>
59
+ .storybook-button {
60
+ display: inline-block;
61
+ cursor: pointer;
62
+ border: 0;
63
+ border-radius: 3em;
64
+ font-weight: 700;
65
+ line-height: 1;
66
+ font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
67
+ }
68
+ .storybook-button--primary {
69
+ background-color: #555ab9;
70
+ color: white;
71
+ }
72
+ .storybook-button--secondary {
73
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
74
+ background-color: transparent;
75
+ color: #333;
76
+ }
77
+ .storybook-button--small {
78
+ padding: 10px 16px;
79
+ font-size: 12px;
80
+ }
81
+ .storybook-button--medium {
82
+ padding: 11px 20px;
83
+ font-size: 14px;
84
+ }
85
+ .storybook-button--large {
86
+ padding: 12px 24px;
87
+ font-size: 16px;
88
+ }
89
+ </style>
@@ -0,0 +1,26 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { fn } from 'storybook/test';
3
+ import Header from './Header.vue';
4
+
5
+ const meta = {
6
+ title: 'Components/Header',
7
+ component: Header,
8
+ parameters: { layout: 'fullscreen' },
9
+ args: {
10
+ onLogin: fn(),
11
+ onLogout: fn(),
12
+ onCreateAccount: fn(),
13
+ },
14
+ tags: ['autodocs'],
15
+ } satisfies Meta<typeof Header>;
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof meta>;
19
+
20
+ export const LoggedIn: Story = {
21
+ args: { user: { name: 'Jane Doe' } },
22
+ };
23
+
24
+ export const LoggedOut: Story = {
25
+ args: { user: null },
26
+ };
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <header>
3
+ <div class="storybook-header">
4
+ <div>
5
+ <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
6
+ <g fill="none" fill-rule="evenodd">
7
+ <path
8
+ d="M10 0h12a10 10 0 0110 10v12a10 10 0 01-10 10H10A10 10 0 010 22V10A10 10 0 0110 0z"
9
+ fill="#FFF"
10
+ />
11
+ <path
12
+ d="M5.3 10.6l10.4 6v11.1l-10.4-6v-11zm11.4-6.2l9.7 5.5-9.7 5.6V4.4z"
13
+ fill="#555AB9"
14
+ />
15
+ <path
16
+ d="M27.2 10.6v11.2l-10.5 6V16.5l10.5-6zM15.7 4.4v11L6 10l9.7-5.5z"
17
+ fill="#91BAF8"
18
+ />
19
+ </g>
20
+ </svg>
21
+ <h1>Acme</h1>
22
+ </div>
23
+ <div>
24
+ <span class="welcome" v-if="user">Welcome, <b>{{ user.name }}</b>!</span>
25
+ <Button size="small" @click="$emit('logout')" label="Log out" v-if="user" />
26
+ <Button size="small" @click="$emit('login')" label="Log in" v-if="!user" />
27
+ <Button primary size="small" @click="$emit('createAccount')" label="Sign up" v-if="!user" />
28
+ </div>
29
+ </div>
30
+ </header>
31
+ </template>
32
+
33
+ <script lang="ts" setup>
34
+ defineProps<{ user: { name: string } | null }>();
35
+
36
+ defineEmits<{
37
+ (event: 'createAccount'): void;
38
+ (event: 'login'): void;
39
+ (event: 'logout'): void;
40
+ }>();
41
+ </script>
42
+
43
+ <style>
44
+ .storybook-header {
45
+ display: flex;
46
+ justify-content: space-between;
47
+ align-items: center;
48
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
49
+ padding: 15px 20px;
50
+ font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
51
+ }
52
+
53
+ .storybook-header svg {
54
+ display: inline-block;
55
+ vertical-align: top;
56
+ }
57
+
58
+ .storybook-header h1 {
59
+ display: inline-block;
60
+ vertical-align: top;
61
+ margin: 6px 0 6px 10px;
62
+ font-weight: 700;
63
+ font-size: 20px;
64
+ line-height: 1;
65
+ }
66
+
67
+ .storybook-header button + button {
68
+ margin-left: 10px;
69
+ }
70
+
71
+ .storybook-header .welcome {
72
+ margin-right: 10px;
73
+ color: #333;
74
+ font-size: 14px;
75
+ }
76
+ </style>
@@ -0,0 +1,28 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, userEvent, within } from 'storybook/test';
3
+ import Page from './Page.vue';
4
+
5
+ const meta = {
6
+ title: 'Components/Page',
7
+ component: Page,
8
+ parameters: { layout: 'fullscreen' },
9
+ tags: ['autodocs'],
10
+ } satisfies Meta<typeof Page>;
11
+
12
+ export default meta;
13
+ type Story = StoryObj<typeof meta>;
14
+
15
+ export const LoggedIn: Story = {
16
+ play: async ({ canvasElement }: any) => {
17
+ const canvas = within(canvasElement);
18
+ const loginButton = canvas.getByRole('button', { name: /Log in/i });
19
+ await expect(loginButton).toBeInTheDocument();
20
+ await userEvent.click(loginButton);
21
+ await expect(loginButton).not.toBeInTheDocument();
22
+
23
+ const logoutButton = canvas.getByRole('button', { name: /Log out/i });
24
+ await expect(logoutButton).toBeInTheDocument();
25
+ },
26
+ };
27
+
28
+ export const LoggedOut: Story = {};
@@ -0,0 +1,121 @@
1
+ <template>
2
+ <article>
3
+ <Header :user="user" @login="onLogin" @logout="onLogout" @create-account="onCreateAccount" />
4
+
5
+ <section class="storybook-page">
6
+ <h2>Pages in Storybook</h2>
7
+ <p>
8
+ We recommend building UIs with a
9
+ <a href="https://componentdriven.org" target="_blank" rel="noopener noreferrer">
10
+ <strong>component-driven</strong>
11
+ </a>
12
+ process starting with atomic components and ending with pages.
13
+ </p>
14
+ <p>
15
+ Render pages with mock data. This makes it easy to build and review page states without
16
+ needing to navigate to them in your app. Here are some handy patterns for managing page data
17
+ in Storybook:
18
+ </p>
19
+ <ul>
20
+ <li>
21
+ Use a higher-level connected component. Storybook helps you compose such data from the
22
+ "args" of child component stories
23
+ </li>
24
+ <li>
25
+ Assemble data in the page component from your services. You can mock these services out
26
+ using Storybook.
27
+ </li>
28
+ </ul>
29
+ <p>
30
+ Get a guided tutorial on component-driven development at
31
+ <a href="https://storybook.js.org/tutorials/" target="_blank" rel="noopener noreferrer">Storybook tutorials</a>.
32
+ Read more in the
33
+ <a href="https://storybook.js.org/docs" target="_blank" rel="noopener noreferrer">docs</a>.
34
+ </p>
35
+ <div class="tip-wrapper">
36
+ <span class="tip">Tip</span>
37
+ Adjust the width of the canvas with the
38
+ <svg width="10" height="10" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
39
+ <g fill="none" fill-rule="evenodd">
40
+ <path
41
+ 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"
42
+ id="a"
43
+ fill="#999"
44
+ />
45
+ </g>
46
+ </svg>
47
+ Viewports addon in the toolbar
48
+ </div>
49
+ </section>
50
+ </article>
51
+ </template>
52
+
53
+ <script lang="ts" setup>
54
+ const user = ref<{ name: string } | null>(null);
55
+
56
+ const onLogin = () => { user.value = { name: 'Jane Doe' }; };
57
+ const onLogout = () => { user.value = null; };
58
+ const onCreateAccount = () => { user.value = { name: 'Jane Doe' }; };
59
+ </script>
60
+
61
+ <style>
62
+ .storybook-page {
63
+ margin: 0 auto;
64
+ padding: 48px 20px;
65
+ max-width: 600px;
66
+ color: #333;
67
+ font-size: 14px;
68
+ line-height: 24px;
69
+ font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
70
+ }
71
+
72
+ .storybook-page h2 {
73
+ display: inline-block;
74
+ vertical-align: top;
75
+ margin: 0 0 4px;
76
+ font-weight: 700;
77
+ font-size: 32px;
78
+ line-height: 1;
79
+ }
80
+
81
+ .storybook-page p { margin: 1em 0; }
82
+ .storybook-page a { color: inherit; }
83
+
84
+ .storybook-page ul {
85
+ margin: 1em 0;
86
+ padding-left: 30px;
87
+ }
88
+
89
+ .storybook-page li { margin-bottom: 8px; }
90
+
91
+ .storybook-page .tip {
92
+ display: inline-block;
93
+ vertical-align: top;
94
+ margin-right: 10px;
95
+ border-radius: 1em;
96
+ background: #e7fdd8;
97
+ padding: 4px 12px;
98
+ color: #357a14;
99
+ font-weight: 700;
100
+ font-size: 11px;
101
+ line-height: 12px;
102
+ }
103
+
104
+ .storybook-page .tip-wrapper {
105
+ margin-top: 40px;
106
+ margin-bottom: 40px;
107
+ font-size: 13px;
108
+ line-height: 20px;
109
+ }
110
+
111
+ .storybook-page .tip-wrapper svg {
112
+ display: inline-block;
113
+ vertical-align: top;
114
+ margin-top: 3px;
115
+ margin-right: 4px;
116
+ width: 12px;
117
+ height: 12px;
118
+ }
119
+
120
+ .storybook-page .tip-wrapper svg path { fill: #1ea7fd; }
121
+ </style>
package/app.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ export default defineAppConfig({
2
+ myLayer: {
3
+ name: "Hello from Nuxt layer",
4
+ },
5
+ });
6
+
7
+ declare module "@nuxt/schema" {
8
+ interface AppConfigInput {
9
+ myLayer?: {
10
+ /** Project name */
11
+ name?: string;
12
+ };
13
+ }
14
+ }
package/nuxt.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ // https://nuxt.com/docs/api/configuration/nuxt-config
2
+ export default defineNuxtConfig({
3
+ devtools: { enabled: true },
4
+ components: [{ path: './app/components', pathPrefix: false }],
5
+ vite: {
6
+ optimizeDeps: {
7
+ include: ["@vue/devtools-core", "@vue/devtools-kit"],
8
+ },
9
+ },
10
+ });
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@menumalsuite/design-system",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "main": "./nuxt.config.ts",
6
+ "exports": {
7
+ ".": "./nuxt.config.ts"
8
+ },
9
+ "files": [
10
+ "app/**",
11
+ "nuxt.config.ts",
12
+ "app.config.ts"
13
+ ],
14
+ "scripts": {
15
+ "dev": "nuxi dev .playground",
16
+ "dev:prepare": "nuxt prepare .playground",
17
+ "build": "nuxt build .playground",
18
+ "generate": "nuxt generate .playground",
19
+ "preview": "nuxt preview .playground",
20
+ "storybook": "storybook dev -p 6006",
21
+ "build-storybook": "storybook build",
22
+ "lint": "eslint ."
23
+ },
24
+ "peerDependencies": {
25
+ "nuxt": ">=4.0.0",
26
+ "vue": ">=3.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "@chromatic-com/storybook": "^5.1.2",
30
+ "@nuxt/eslint": "latest",
31
+ "@storybook/addon-a11y": "^10.3.6",
32
+ "@storybook/addon-docs": "^10.3.6",
33
+ "@storybook/addon-vitest": "^10.3.6",
34
+ "@storybook/vue3-vite": "^10.3.6",
35
+ "@types/node": "^24.12.2",
36
+ "@vitejs/plugin-vue": "^6.0.6",
37
+ "@vitest/browser-playwright": "^4.1.5",
38
+ "@vitest/coverage-v8": "^4.1.5",
39
+ "eslint": "^10.3.0",
40
+ "nuxt": "^4.4.4",
41
+ "playwright": "^1.59.1",
42
+ "storybook": "^10.3.6",
43
+ "typescript": "^6.0.3",
44
+ "unplugin-auto-import": "^21.0.0",
45
+ "vitest": "^4.1.5",
46
+ "vue": "^3.5.34"
47
+ }
48
+ }