@n8n/design-system 2.37.2 → 2.38.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 CHANGED
@@ -2,48 +2,186 @@
2
2
 
3
3
  # @n8n/design-system
4
4
 
5
- A component system for [n8n](https://n8n.io) using Storybook to preview.
5
+ The n8n component library for Vue 3. It gives you components, design tokens, icons, and
6
+ the directives plugin. Run `pnpm dev` to see the components in Storybook.
6
7
 
7
- ## Project setup
8
+ ## Table of Contents
8
9
 
9
- ```
10
- pnpm install
11
- ```
10
+ - [Consume the package](#consume-the-package)
11
+ - [Exports](#exports)
12
+ - [Develop the package](#develop-the-package)
13
+ - [Pack and publish](#pack-and-publish)
14
+ - [License](#license)
12
15
 
13
- ### Compiles and hot-reloads for development
16
+ ## Consume the package
14
17
 
15
- ```
16
- pnpm storybook
17
- ```
18
+ You need a Vue 3 app with Vite. You also need the `vue` and `vue-router` packages.
18
19
 
19
- ### Build static pages
20
+ `vue` and `vue-router` are peer dependencies. The barrel imports `vue-router` at load
21
+ time. If `vue-router` is absent, the build fails.
20
22
 
21
- ```
22
- pnpm build:storybook
23
+ ### 1. Install
24
+
25
+ Inside this monorepo, declare the package as a workspace dependency in your `package.json`:
26
+
27
+ ```json
28
+ {
29
+ "dependencies": {
30
+ "@n8n/design-system": "workspace:*",
31
+ "vue": "catalog:frontend",
32
+ "vue-router": "catalog:frontend"
33
+ }
34
+ }
23
35
  ```
24
36
 
25
- ### Run your unit tests
37
+ Outside this monorepo, install the package from npm:
26
38
 
39
+ ```sh
40
+ npm install @n8n/design-system@latest vue vue-router
27
41
  ```
28
- pnpm test:unit
42
+
43
+ Add `sass` as a dev dependency only when you `@use` the SCSS sources from
44
+ [`./css/*`](#exports).
45
+
46
+ ### 2. Build the package first
47
+
48
+ `.gitignore` excludes `dist`. So an in-repo app can resolve nothing before you build the
49
+ package. Build the package with turbo. Turbo builds the workspace dependencies first.
50
+
51
+ ```sh
52
+ pnpm turbo run build --filter=@n8n/design-system
29
53
  ```
30
54
 
31
- ### Lints and fixes files
55
+ A package that declares `@n8n/design-system` needs no extra step, because the `build` task
56
+ of turbo depends on `^build`. If you install from npm, skip this step, because the tarball
57
+ includes `dist`.
58
+
59
+ ### 3. Wire it into your app
60
+
61
+ Import the two stylesheets before your own styles. `theme.css` gives you the design tokens,
62
+ the CSS reset, and four `@font-face` rules. The components read their variables from these
63
+ tokens.
64
+
65
+ ```ts
66
+ // src/main.ts
67
+ import '@n8n/design-system/style.css';
68
+ import '@n8n/design-system/theme.css';
69
+ import './styles.scss';
70
+
71
+ import { IconBodyLoaderKey, loadLucideIconBody } from '@n8n/design-system/icons/lucide';
72
+ import { N8nPlugin } from '@n8n/design-system/plugin';
73
+ import { createApp } from 'vue';
74
+
75
+ import App from './App.vue';
32
76
 
77
+ const app = createApp(App);
78
+ app.use(N8nPlugin, {});
79
+ app.provide(IconBodyLoaderKey, loadLucideIconBody);
80
+ app.mount('#app');
33
81
  ```
34
- pnpm lint
82
+
83
+ `N8nPlugin` registers the `v-n8n-truncate` and `v-n8n-html` directives. Pass `{}` as the
84
+ options argument.
85
+
86
+ Do not skip this call. Ten components render their text through `v-n8n-html`: `N8nNotice`,
87
+ `N8nTooltip`, `N8nTabs`, `N8nSticky`, `N8nInputLabel`, `N8nInfoAccordion`, `N8nEmptyState`,
88
+ `CommandBarItem`, and the two `AskAssistantChat` message components. If the directive is
89
+ absent, these components render empty and show no error.
90
+
91
+ The `app.provide(IconBodyLoaderKey, loadLucideIconBody)` call gives you the full Lucide
92
+ set. If you omit the call, `N8nIcon` renders only the bundled icon set. That set holds
93
+ `triangle`, `status-error`, and the custom n8n icons. Every other Lucide name renders
94
+ empty, and a dev build writes a warning to the console.
95
+
96
+ The barrel gives you the components and their types:
97
+
98
+ ```vue
99
+ <!-- src/App.vue -->
100
+ <script setup lang="ts">
101
+ import { N8nButton, N8nIcon, N8nText } from '@n8n/design-system';
102
+ import type { ButtonVariant } from '@n8n/design-system';
103
+ import { ref } from 'vue';
104
+
105
+ const variant: ButtonVariant = 'solid';
106
+ const clicks = ref(0);
107
+ </script>
108
+
109
+ <template>
110
+ <main class="page">
111
+ <N8nText size="medium">clicks: {{ clicks }}</N8nText>
112
+ <N8nButton :variant="variant" label="Click me" @click="clicks++" />
113
+ <N8nIcon icon="anvil" />
114
+ </main>
115
+ </template>
35
116
  ```
36
117
 
37
- ### Build css files
118
+ The package includes the SCSS sources next to the compiled CSS. So an app with its own
119
+ sass toolchain can use the mixins and the token maps:
38
120
 
121
+ ```scss
122
+ // src/styles.scss
123
+ @use '@n8n/design-system/css/mixins/breakpoints' as breakpoints;
124
+
125
+ .page {
126
+ padding: var(--spacing--lg);
127
+
128
+ @include breakpoints.breakpoint('sm-and-down') {
129
+ padding: var(--spacing--2xs);
130
+ }
131
+ }
39
132
  ```
40
- pnpm build:theme
41
- ```
42
133
 
43
- ### Monitor theme files and build any changes
134
+ The `breakpoint` mixin compiles to `@media screen and (width<=991px)`.
135
+
136
+ ## Exports
137
+
138
+ Every subpath resolves from `dist`. The package has no CommonJS build and no `require`
139
+ condition.
140
+
141
+ | Subpath | Contents |
142
+ | --------------------------------- | -------------------------------------------------------------------------------------------- |
143
+ | `@n8n/design-system` | The barrel: components, composables, exported types, and the `locale` singleton. |
144
+ | `@n8n/design-system/plugin` | `N8nPlugin`. It registers the `v-n8n-truncate` and `v-n8n-html` directives. |
145
+ | `@n8n/design-system/icons/lucide` | `loadLucideIconBody` and `IconBodyLoaderKey`, for icons outside the bundled set. |
146
+ | `@n8n/design-system/style.css` | The component styles. |
147
+ | `@n8n/design-system/theme.css` | The design tokens, the CSS reset, four `@font-face` rules, and the element-plus overrides. |
148
+ | `@n8n/design-system/css/*` | The SCSS sources: mixins, token maps, and one stylesheet per component. You must add `sass`. |
149
+ | `@n8n/design-system/package.json` | The manifest. |
150
+
151
+ ## Develop the package
44
152
 
153
+ Run these commands from this directory.
154
+
155
+ | Command | What it does |
156
+ | ---------------- | ---------------------------------------------------------------------- |
157
+ | `pnpm dev` | It starts Storybook on http://localhost:6006. |
158
+ | `pnpm build` | It builds `dist`. Build the workspace dependencies first — see step 2. |
159
+ | `pnpm typecheck` | It runs `vue-tsc --noEmit` on `src`. |
160
+ | `pnpm test` | It runs the unit tests one time. |
161
+ | `pnpm lint` | It lints `src`. `pnpm lint:fix` applies the fixes. |
162
+ | `pnpm clean` | It removes `dist` and `.turbo`. |
163
+
164
+ ## Pack and publish
165
+
166
+ **Pack with `pnpm pack`. Never `npm pack`.**
167
+
168
+ When `pnpm` packs the package, it rewrites the workspace protocol and the catalog
169
+ references to fixed versions. For example, `"@n8n/composables": "workspace:*"` becomes
170
+ `"1.27.0"`, and `"vue": "catalog:frontend"` becomes `"^3.5.13"`. `npm` copies both strings
171
+ without a change. The npm registry client knows neither protocol. So an install of an
172
+ `npm`-packed tarball fails:
173
+
174
+ ```text
175
+ npm error code EUNSUPPORTEDPROTOCOL
176
+ npm error Unsupported URL Type "catalog:": catalog:frontend
45
177
  ```
46
- pnpm watch:theme
178
+
179
+ Build the package first, because `.gitignore` excludes `dist`. The `files` field includes
180
+ `dist`, `assets/fonts`, and this README.
181
+
182
+ ```sh
183
+ pnpm turbo run build --filter=@n8n/design-system
184
+ pnpm pack --pack-destination /tmp/ds-pack
47
185
  ```
48
186
 
49
187
  ## License
@@ -91,6 +91,7 @@ export { default as N8nResizeWrapper } from './N8nResizeWrapper';
91
91
  export { default as N8nSelect } from './N8nSelect';
92
92
  export { default as N8nSpinner } from './N8nSpinner';
93
93
  export { default as N8nStatusDot } from './N8nStatusDot';
94
+ export type { StatusDotProps, StatusDotVariant } from './N8nStatusDot';
94
95
  export { default as N8nStepper } from './N8nStepper/Stepper.vue';
95
96
  export { default as N8nSticky } from './N8nSticky';
96
97
  export { default as N8nResizeableSticky } from './N8nResizeableSticky';