@widgetic/design-system 0.3.89 → 0.5.7
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 +122 -690
- package/dist/components/CopyableHeader.svelte +11 -13
- package/dist/components/EmptyState.svelte +4 -2
- package/dist/components/EmptyState.svelte.d.ts +2 -1
- package/dist/components/GenerateLoader.svelte +50 -0
- package/dist/components/GenerateLoader.svelte.d.ts +21 -0
- package/dist/components/PasswordInput.svelte +5 -1
- package/dist/components/WScrollArea.svelte +3 -3
- package/dist/components/debug-grid/DebugGrid.svelte +1 -1
- package/dist/components/ic/browser/BrowserInputController.svelte +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/modals/BaseModal.svelte +1 -1
- package/dist/components/modals/BaseModal.svelte.d.ts +1 -1
- package/dist/components/modals/NewItemDialog.svelte +1 -1
- package/dist/components/modals/Portal.svelte +14 -15
- package/dist/components/modals/RenameDialog.svelte +7 -6
- package/dist/components/navigation/Breadcrumbs.svelte +65 -39
- package/dist/components/pdf/PDFViewer.svelte +10 -19
- package/dist/components/pdf/PDFViewer.svelte.d.ts +4 -4
- package/dist/components/search-input/SearchInput.svelte +3 -8
- package/dist/components/search-input/index.d.ts +3 -14
- package/dist/components/search-input/index.js +1 -2
- package/dist/components/search-input/index2.d.ts +14 -0
- package/dist/components/shad-editor/README.md +18 -0
- package/dist/components/shad-editor/custom/image-extended-component.svelte +1 -1
- package/dist/components/shad-editor/editor.css +8 -4
- package/dist/components/shad-editor/icons/table.svelte +3 -3
- package/dist/components/shad-editor/icons/text.svelte +1 -1
- package/dist/components/shad-editor/onedark.css +3 -0
- package/dist/components/shad-editor/shad-editor.svelte +1 -1
- package/dist/components/toast/ToasterModal.svelte +15 -9
- package/dist/components/ui/alert/index.d.ts +2 -2
- package/dist/components/ui/badge/badge.svelte +1 -1
- package/dist/components/ui/badge/badge.svelte.d.ts +2 -2
- package/dist/components/ui/button/button.svelte +1 -1
- package/dist/components/ui/calendar/calendar-day.svelte +4 -4
- package/dist/components/ui/card/card.svelte +1 -1
- package/dist/components/ui/checkbox/checkbox.svelte +1 -1
- package/dist/components/ui/collapsible/index.d.ts +1 -12
- package/dist/components/ui/command/command-dialog.svelte +1 -1
- package/dist/components/ui/command/command-input.svelte +1 -1
- package/dist/components/ui/command/command-item.svelte +1 -1
- package/dist/components/ui/command/command-link-item.svelte +1 -1
- package/dist/components/ui/dialog/dialog-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-checkbox-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-radio-item.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/dist/components/ui/dropdown-menu/index.d.ts +6 -14
- package/dist/components/ui/hover-card/hover-card-content.svelte +1 -1
- package/dist/components/ui/input/input.svelte +1 -1
- package/dist/components/ui/input-otp/input-otp.svelte +1 -1
- package/dist/components/ui/popover/popover-content.svelte +1 -1
- package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-day.svelte +6 -6
- package/dist/components/ui/select/index.d.ts +1 -1
- package/dist/components/ui/select/select-item.svelte +1 -1
- package/dist/components/ui/select/select-trigger.svelte +1 -1
- package/dist/components/ui/slider/slider.svelte +1 -1
- package/dist/components/ui/switch/switch.svelte +1 -1
- package/dist/components/ui/tabs/tabs-content.svelte +1 -1
- package/dist/components/ui/tabs/tabs-trigger.svelte +1 -1
- package/dist/components/ui/textarea/textarea.svelte +1 -1
- package/dist/components/ui/toggle/toggle.svelte +1 -1
- package/dist/components/ui/toggle/toggle.svelte.d.ts +2 -2
- package/dist/components/ui/tooltip/index.d.ts +4 -4
- package/dist/components/widget-system/Moveable.svelte +100 -23
- package/dist/components/widget-system/Moveable.svelte.d.ts +3 -1
- package/dist/icons/eye-off.svg +1 -0
- package/dist/icons/eye.svg +1 -0
- package/dist/shad-editor/index.d.ts +1 -0
- package/dist/shad-editor/index.js +1 -0
- package/dist/styles/fonts.css +59 -47
- package/dist/styles/global.css +119 -52
- package/package.json +158 -34
- package/tailwind.config.ts +13 -6
package/README.md
CHANGED
|
@@ -1,10 +1,52 @@
|
|
|
1
|
-
# Widgetic Design System
|
|
2
|
-
|
|
3
|
-
This is the design system package for the Widgetic platform.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
##
|
|
1
|
+
# Widgetic Design System (`@widgetic/design-system`)
|
|
2
|
+
|
|
3
|
+
This is the official design system package for the Widgetic platform.
|
|
4
|
+
|
|
5
|
+
Built with SvelteKit and Tailwind CSS (using shadcn-svelte components as a base), it provides reusable UI components, global styles, design tokens, icons, and fonts for building consistent interfaces across Widgetic projects.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
* **Styles:** Exports global CSS styles, including CSS variables for design tokens (colors, spacing, etc.) and utility classes based on Tailwind CSS v4.
|
|
10
|
+
* **UI Components:** A library of Svelte components built upon [shadcn-svelte](https://shadcn-svelte.com/), providing elements like Buttons, Cards, Dialogs, Input fields, Accordions, etc. Includes both base shadcn components and custom Widgetic components.
|
|
11
|
+
* **Icons:** Exports icons from [Lucide Svelte](https://lucide.dev/) and potentially [Tabler Icons](https://tabler-icons.io/), accessible via named imports.
|
|
12
|
+
* **Fonts:** Includes specific font families used across the Widgetic platform. Font files themselves are exported, but consuming projects need to ensure they are loaded correctly (e.g., via CSS `@import` or `<link>`).
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
1. **Install the package:**
|
|
17
|
+
```bash
|
|
18
|
+
npm install @widgetic/design-system
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
2. **Install Peer Dependencies:** This package relies on several peer dependencies that you need to install in your project if you haven't already. Ensure your `package.json` includes compatible versions:
|
|
22
|
+
```json
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
// Required by Tailwind v4 setup
|
|
25
|
+
"postcss": "^8.x.x",
|
|
26
|
+
"@tailwindcss/postcss": "^4.x.x",
|
|
27
|
+
"tailwindcss": "^4.x.x",
|
|
28
|
+
// Required by SvelteKit/Svelte 5
|
|
29
|
+
"svelte": "^5.x.x",
|
|
30
|
+
"@sveltejs/kit": "^2.x.x",
|
|
31
|
+
// Required by shadcn-svelte components used internally
|
|
32
|
+
"bits-ui": "^1.x.x",
|
|
33
|
+
"clsx": "^2.x.x",
|
|
34
|
+
"tailwind-merge": "^2.x.x",
|
|
35
|
+
"tailwind-variants": "^0.x.x",
|
|
36
|
+
"svelte-sonner": "^0.x.x",
|
|
37
|
+
// Required by specific components if used
|
|
38
|
+
"@internationalized/date": "^3.x.x",
|
|
39
|
+
"lucide-svelte": "^0.x.x",
|
|
40
|
+
"@tabler/icons-svelte": "^3.x.x",
|
|
41
|
+
"vaul-svelte": "^1.x.x-next.x"
|
|
42
|
+
// ... other project devDependencies
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
*Note: Replace `x.x` with appropriate version numbers compatible with the design system's requirements (check its `package.json` `peerDependencies` for specifics).* Make sure you have `postcss.config.js` (or `.mjs`) set up.
|
|
46
|
+
|
|
47
|
+
## Setup
|
|
48
|
+
|
|
49
|
+
### 1. Initial Setup (Required for Team Development)
|
|
8
50
|
|
|
9
51
|
After cloning the repository, run the install script which handles dependencies and Git configuration:
|
|
10
52
|
|
|
@@ -14,732 +56,122 @@ npm run i
|
|
|
14
56
|
|
|
15
57
|
This script installs dependencies, links the package, and automatically configures Git for proper case sensitivity. This prevents file case conflicts between different operating systems (macOS, Windows, Linux). **All team members should run this** when first working with the design system.
|
|
16
58
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
```svelte
|
|
20
|
-
<script>
|
|
21
|
-
import '@widgetic/design-system/styles';
|
|
22
|
-
</script>
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
0.1. To add new fonts:
|
|
26
|
-
- Add the font in the fonts folder.
|
|
27
|
-
- Add the font-face rule and the class in the fonts.css file and then the class can be used anywhere in the projects that import the design system's styles:
|
|
28
|
-
```css
|
|
29
|
-
/* First font-face rule */
|
|
30
|
-
@font-face {
|
|
31
|
-
font-family: 'BL Melody';
|
|
32
|
-
src: url('@widgetic/design-system/fonts/BLMelody/BLMelody-ExtraLight.woff2') format('woff2');
|
|
33
|
-
font-weight: 200;
|
|
34
|
-
font-style: normal;
|
|
35
|
-
font-display: swap;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Second fonte class(can be any custom name) */
|
|
39
|
-
.font-bl-melody-extra-light {
|
|
40
|
-
font-family: 'BL Melody';
|
|
41
|
-
font-weight: 200;
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
- Use the font-family in any class in the global.css file if needed like this:
|
|
46
|
-
```css
|
|
47
|
-
.my-button-class {
|
|
48
|
-
/* other CSS properties */
|
|
49
|
-
background-color: red;
|
|
50
|
-
|
|
51
|
-
/* font-family properties here */
|
|
52
|
-
font-family: 'BL Melody', sans-serif;
|
|
53
|
-
font-weight: 200;
|
|
54
|
-
font-style: normal;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
1.1. Components: It uses the SHADCN UI components for basic ui components and custom components for the Widgetic platform.
|
|
59
|
-
|
|
60
|
-
a. (Re)Install latest all shadcn components:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm run i-shadcn
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
At prompt answer like this:
|
|
67
|
-
```bash
|
|
68
|
-
Which style would you like to use?
|
|
69
|
-
│ Default
|
|
70
|
-
│
|
|
71
|
-
◇ Which base color would you like to use?
|
|
72
|
-
│ Slate
|
|
73
|
-
│
|
|
74
|
-
◇ Where is your global CSS file? (this file will be overwritten)
|
|
75
|
-
│ src/app.css (!!! add local project's css file as we don't want to overwrite our project's global styles)
|
|
76
|
-
│
|
|
77
|
-
◇ Where is your Tailwind config located? (this file will be overwritten)
|
|
78
|
-
│ tailwind.config.ts
|
|
79
|
-
│
|
|
80
|
-
◇ Configure the import alias for components:
|
|
81
|
-
│ $lib/components
|
|
82
|
-
│
|
|
83
|
-
◆ Configure the import alias for utils:
|
|
84
|
-
│ $lib/utils
|
|
85
|
-
│
|
|
86
|
-
◆ Configure the import alias for hooks:
|
|
87
|
-
│ $lib/hooks
|
|
88
|
-
│
|
|
89
|
-
◆ Configure the import alias for ui:
|
|
90
|
-
│ $lib/components/ui
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Components to install:
|
|
94
|
-
│ accordion, badge, button, calendar, range-calendar, card, checkbox, collapsible, dialog,
|
|
95
|
-
│ drawer, dropdown-menu, input, input-otp, label, popover, progress, radio-group, scroll-area,
|
|
96
|
-
│ select, separator, slider, switch, table, tabs, textarea, tooltip
|
|
97
|
-
│
|
|
98
|
-
◆ Ready to install components and dependencies?
|
|
99
|
-
│ ● Yes / ○ No
|
|
100
|
-
...
|
|
101
|
-
tooltip installed at src/lib/components/ui/tooltip
|
|
102
|
-
│
|
|
103
|
-
◇ Dependencies installed with npm
|
|
104
|
-
│
|
|
105
|
-
◇ Config file components.json updated
|
|
106
|
-
│
|
|
107
|
-
└ Success! Component installation completed.
|
|
108
|
-
|
|
109
|
-
!!! On commit the change uncheck the grouped components(Table, Select, etc.) baerel file.
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
b. Installing the shadcn-svelte package:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
npx shadcn-svelte@next init
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
c. Add one or more SHADCN UI components:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
npx shadcn-svelte@next add <component-name component-name2>
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
d. Check tailwind.config.ts file to see if you didn't lose any of the project's config.
|
|
125
|
-
|
|
126
|
-
e. Check /src/lib/utils/utils.ts file to see if you didn't lose any of the project's utils.
|
|
127
|
-
|
|
128
|
-
f. Check /src/lib/hooks/hooks.ts file to see if you didn't lose any of the project's hooks.
|
|
129
|
-
|
|
130
|
-
g. Check SHADCN UI Grouped components(eg. Table or Select) barel file to export a constant with the subcomponents.
|
|
131
|
-
We do that just be wrapping the first part of the export statement with a constant named as the component ("Table" here) and replace the exported subcomponent: "Table" in this case with "TableRoot".
|
|
132
|
-
```ts
|
|
133
|
-
// src/lib/components/ui/table/index.ts
|
|
134
|
-
const Table = {
|
|
135
|
-
Root,
|
|
136
|
-
Body,
|
|
137
|
-
Caption,
|
|
138
|
-
Cell,
|
|
139
|
-
Footer,
|
|
140
|
-
Head,
|
|
141
|
-
Header,
|
|
142
|
-
Row
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export {
|
|
146
|
-
Table, // add the constant name "Table" that will be the namespace for the grouped components
|
|
147
|
-
Root as TableRoot, // Change the name of the Root component from "Table" to "TableRoot"
|
|
148
|
-
Body as TableBody,
|
|
149
|
-
Caption as TableCaption,
|
|
150
|
-
Cell as TableCell,
|
|
151
|
-
Footer as TableFooter,
|
|
152
|
-
Head as TableHead,
|
|
153
|
-
Header as TableHeader,
|
|
154
|
-
Row as TableRow,
|
|
155
|
-
};
|
|
156
|
-
```
|
|
157
|
-
Then you can import and use the namespace in the project:
|
|
158
|
-
```svelte
|
|
159
|
-
import { Table } from '@widgetic/design-system';
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
h. If there is a component that looks compound but is not, add the @notCompound marker in the file:
|
|
163
|
-
```ts
|
|
164
|
-
// @notCompound
|
|
165
|
-
export {
|
|
166
|
-
Root,
|
|
167
|
-
Scrollbar,
|
|
168
|
-
//,
|
|
169
|
-
Root as ScrollArea,
|
|
170
|
-
Scrollbar as ScrollAreaScrollbar,
|
|
171
|
-
};
|
|
172
|
-
```
|
|
173
|
-
ScrollArea is not a compound component but it looks like one.
|
|
174
|
-
|
|
175
|
-
h. If you want to export only the main component and not the subcomponents, add the @noSubcomponents marker in the file:
|
|
176
|
-
```ts
|
|
177
|
-
// @noSubcomponents
|
|
178
|
-
export {
|
|
179
|
-
Day,
|
|
180
|
-
Cell,
|
|
181
|
-
Grid,
|
|
182
|
-
Header,
|
|
183
|
-
Months,
|
|
184
|
-
GridRow,
|
|
185
|
-
Heading,
|
|
186
|
-
GridBody,
|
|
187
|
-
GridHead,
|
|
188
|
-
HeadCell,
|
|
189
|
-
NextButton,
|
|
190
|
-
PrevButton,
|
|
191
|
-
//
|
|
192
|
-
Root as RangeCalendar,
|
|
193
|
-
};
|
|
194
|
-
```
|
|
195
|
-
RangeCalendar share the same subcomponents with Calendar so we don't want to export them.
|
|
196
|
-
|
|
197
|
-
1.2. In general we should follow the shadcn-svelte approach to export the components with more subcomponents or compound components.
|
|
198
|
-
|
|
199
|
-
2. Icons: It also uses the Lucide and Tabler icons or custom icons for the platform.
|
|
200
|
-
|
|
201
|
-
```svelte
|
|
202
|
-
import { IconName } from '@widgetic/design-system/icons';
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
3. Fonts: The design system uses Google Fonts that we need to import in the project where the design system is imported.
|
|
207
|
-
|
|
208
|
-
```svelte
|
|
209
|
-
import { FontName } from '@widgetic/design-system/fonts';
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
## Performance Optimization for Linked Design System
|
|
214
|
-
|
|
215
|
-
When using the linked design system in development mode, you may experience slow initial load times and delayed navigation. This is because Vite's default file watching behavior can create performance issues when working with linked packages.
|
|
216
|
-
|
|
217
|
-
### Common Issues:
|
|
218
|
-
- Long initial loading time (>1 minute)
|
|
219
|
-
- "Pending" status on network requests when navigating between pages
|
|
220
|
-
- High CPU usage during development
|
|
221
|
-
|
|
222
|
-
### Solution:
|
|
223
|
-
|
|
224
|
-
#### 1. For consuming projects (like site, context-chat, etc.):
|
|
225
|
-
|
|
226
|
-
Optimize your `vite.config.ts` with these settings:
|
|
227
|
-
|
|
228
|
-
```ts
|
|
229
|
-
server: {
|
|
230
|
-
watch: {
|
|
231
|
-
// Don't use polling (which causes high CPU usage)
|
|
232
|
-
// Remove the following if present:
|
|
233
|
-
// usePolling: true,
|
|
234
|
-
// interval: 2000,
|
|
235
|
-
// binaryInterval: 2000,
|
|
236
|
-
|
|
237
|
-
// Ignore all node_modules EXCEPT the design system dist folder if needed
|
|
238
|
-
ignored: [
|
|
239
|
-
'**/node_modules/**',
|
|
240
|
-
'**/*.map',
|
|
241
|
-
'**/*.d.ts',
|
|
242
|
-
'**/*.log'
|
|
243
|
-
]
|
|
244
|
-
},
|
|
245
|
-
hmr: {
|
|
246
|
-
// Reduce timeout for faster updates
|
|
247
|
-
timeout: 2000
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
optimizeDeps: {
|
|
251
|
-
// Don't include the design system in optimizeDeps
|
|
252
|
-
// Remove this if present:
|
|
253
|
-
// include: ['@widgetic/design-system']
|
|
254
|
-
|
|
255
|
-
// Keep other settings
|
|
256
|
-
exclude: ['@sveltejs/kit']
|
|
257
|
-
},
|
|
258
|
-
build: {
|
|
259
|
-
// Add these for faster builds
|
|
260
|
-
sourcemap: false,
|
|
261
|
-
reportCompressedSize: false
|
|
262
|
-
}
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
#### 2. For production deployments:
|
|
266
|
-
|
|
267
|
-
When deploying to production, you'll use the published npm package instead of the linked development version. No special configuration is needed beyond the optimizations above.
|
|
268
|
-
|
|
269
|
-
#### 3. Development vs. Production Mode:
|
|
270
|
-
|
|
271
|
-
The design system's `vite.config.ts` already includes development-specific optimizations. When publishing the package to npm, the built version will be used, and these configurations won't affect end users.
|
|
272
|
-
|
|
273
|
-
**Note:** These optimizations are only needed during development with linked packages and won't affect the published npm package performance.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
## How to link DS into another project and develop it(first time)
|
|
277
|
-
|
|
278
|
-
0. Go into the DS project and link it in the system and start it with: `cd Frontend/design-system && npm link && npm run dev`
|
|
279
|
-
|
|
280
|
-
1. Go into the consuming project and make sure you have installed tailwindcss and postcss by checking in package.json if it has these dependencies:
|
|
281
|
-
|
|
282
|
-
```json
|
|
283
|
-
"dependencies": {
|
|
284
|
-
"tailwindcss": "^3.4.16",
|
|
285
|
-
"@tailwindcss/postcss": "^4.1.2",
|
|
286
|
-
}
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Also make sure you have a 'tailwind.config.ts'(if there is a '.js' version rename it to '.ts') and a 'postcss.config.js' file.
|
|
290
|
-
(optional)If not already in the project follow the install guide at: https://tailwindcss.com/docs/installation/using-postcss.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
2. Also add these dependencies and overrides(that are needed for DS) with these exact versions into the package.json file of the consuming project:
|
|
294
|
-
```json package.json
|
|
295
|
-
"dependencies": {
|
|
296
|
-
"@sveltejs/kit": "^2.20.2",
|
|
297
|
-
"svelte": "^5.25.6",
|
|
298
|
-
"@tabler/icons-svelte": "^3.24.0",
|
|
299
|
-
"lucide-svelte": "^0.468.0",
|
|
300
|
-
"bits-ui": "^1.3.0",
|
|
301
|
-
"svelte-sonner": "^0.3.28",
|
|
302
|
-
|
|
303
|
-
"tailwind-merge": "^2.5.2",
|
|
304
|
-
"tailwind-variants": "^0.2.1",
|
|
305
|
-
"tailwindcss-animate": "^1.0.7",
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
"overrides": {
|
|
309
|
-
"bits-ui": {
|
|
310
|
-
"@melt-ui/svelte": "^0.86.3"
|
|
311
|
-
},
|
|
312
|
-
"vaul-svelte": {
|
|
313
|
-
"bits-ui": {
|
|
314
|
-
"@melt-ui/svelte": "^0.86.3"
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
"svelte": "^5.25.6"
|
|
318
|
-
},
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
Also keep the exact versions mentioned above and check and remove these dependencies from devDependencies or peerDependencies in the package.json of the consuming project.
|
|
59
|
+
### 2. Tailwind Configuration
|
|
322
60
|
|
|
323
|
-
|
|
324
|
-
"i": "rm -rf node_modules && npm i && npm run lds",
|
|
325
|
-
"lds": "volta run npm link @widgetic/design-system",
|
|
326
|
-
Then run it with: `npm run i`
|
|
61
|
+
To ensure Tailwind processes the design system's classes and applies your project's customizations correctly, configure your project's `tailwind.config.ts` (or `.js`) to use the design system's configuration as a preset:
|
|
327
62
|
|
|
328
|
-
4. Also add these "dev" scripts into the package.json file for usual start of the consuming project:
|
|
329
|
-
"dev": "npm run dev-sv -- --open",
|
|
330
|
-
"dev-sv": "NODE_ENV=development vite dev",
|
|
331
|
-
|
|
332
|
-
5. Import DS config into the tailwind.config.ts file(of consuming project) and add it in the presets array:
|
|
333
63
|
```ts
|
|
334
64
|
// tailwind.config.ts
|
|
335
|
-
|
|
336
|
-
import designSystemPreset from '@widgetic/design-system/tailwind.config';
|
|
65
|
+
import type { Config } from 'tailwindcss';
|
|
66
|
+
import designSystemPreset from '@widgetic/design-system/tailwind.config'; // Import the preset
|
|
337
67
|
|
|
338
68
|
const config = {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
69
|
+
// Use the design system preset
|
|
70
|
+
presets: [designSystemPreset],
|
|
71
|
+
|
|
72
|
+
// Add your project's paths AND the design system's path to the content array
|
|
73
|
+
content: [
|
|
74
|
+
'./src/**/*.{html,js,svelte,ts}', // Your project files
|
|
75
|
+
'./node_modules/@widgetic/design-system/dist/**/*.{html,js,svelte,ts}' // Design system package files
|
|
76
|
+
],
|
|
77
|
+
|
|
78
|
+
// You can optionally extend the theme further here
|
|
79
|
+
theme: {
|
|
80
|
+
extend: {
|
|
81
|
+
// Your project-specific theme extensions
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
plugins: [
|
|
86
|
+
// Your project-specific plugins (if any)
|
|
87
|
+
]
|
|
88
|
+
} satisfies Config;
|
|
356
89
|
|
|
357
90
|
export default config;
|
|
358
91
|
```
|
|
359
|
-
Also make sure you remove the type of the config to avoid conflicts with the DS config.
|
|
360
|
-
Then leave the rest of the config as it is.
|
|
361
|
-
|
|
362
|
-
6. Import styles and a test component from DS in the consuming project:
|
|
363
|
-
a. In the root layout of the project import the global styles:
|
|
364
|
-
```svelte
|
|
365
|
-
<!-- +layout.svelte -->
|
|
366
|
-
<script>
|
|
367
|
-
import '@widgetic/design-system/styles';
|
|
368
|
-
</script>
|
|
369
|
-
```
|
|
370
|
-
b. In the root page of the consuming project import any component(e.g. Button) and use it:
|
|
371
|
-
```svelte
|
|
372
|
-
<!-- +page.svelte -->
|
|
373
|
-
<script>
|
|
374
|
-
import { Button } from '@widgetic/design-system/';
|
|
375
|
-
</script>
|
|
376
|
-
|
|
377
|
-
<!-- HTML zone -->
|
|
378
|
-
<Button>Click me</Button>
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
7. Finally: go into the in the consuming project's folder and start the development server with:
|
|
382
|
-
```bash
|
|
383
|
-
npm run dev
|
|
384
|
-
```
|
|
385
92
|
|
|
386
|
-
|
|
93
|
+
* **Presets:** The `presets` array applies the design system's base configuration (colors, fonts, plugins like `tailwindcss-animate`).
|
|
94
|
+
* **Content:** It's crucial to include the path to the installed design system package (`./node_modules/@widgetic/design-system/dist/...`) in your `content` array. This allows Tailwind to scan the design system's components and generate the necessary utility classes.
|
|
387
95
|
|
|
96
|
+
### 3. Global Styles
|
|
388
97
|
|
|
98
|
+
Import the design system's global CSS file into your main layout file (e.g., `src/routes/+layout.svelte`). This file includes base styles, CSS variables (design tokens), and imports necessary fonts.
|
|
389
99
|
|
|
390
|
-
## Developing inside this project:
|
|
391
|
-
|
|
392
|
-
1. Install dependencies with `npm install`
|
|
393
|
-
|
|
394
|
-
2. Link the package in the system with npm:
|
|
395
|
-
```bash
|
|
396
|
-
npm link
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
3. Start the development server with:
|
|
400
|
-
```bash
|
|
401
|
-
npm run dev
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
3. Test the design system in action:
|
|
405
|
-
- In the root layout of the DS project there is a global styles import to test the design system's global styles.
|
|
406
|
-
- In the root page of the project there is a button component import to test the design system's components.
|
|
407
|
-
|
|
408
|
-
Open in new tab in browser with address: http://localhost:5173/ to see the design system in action.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
### Global Tailwind CSS and Design Tokens:
|
|
413
|
-
|
|
414
|
-
```css
|
|
415
|
-
/* src/lib/styles/global.css */
|
|
416
|
-
@tailwind base;
|
|
417
|
-
@tailwind components;
|
|
418
|
-
@tailwind utilities;
|
|
419
|
-
|
|
420
|
-
/* CUSTOM GLOBAL STYLES */
|
|
421
|
-
/* ADD HERE CLASSES AND CSS VARIABLES that are used in the projects where the design system is imported */
|
|
422
|
-
|
|
423
|
-
/* Base styles */
|
|
424
|
-
@layer base {
|
|
425
|
-
:root {
|
|
426
|
-
/* Design tokens */
|
|
427
|
-
--color-primary: 30 158 210; /* RGB values for easier theming */
|
|
428
|
-
--color-secondary: 46 204 113;
|
|
429
|
-
--radius: 0.5rem;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/* Dark mode tokens */
|
|
433
|
-
.dark {
|
|
434
|
-
--color-primary: 100 200 255;
|
|
435
|
-
--color-secondary: 100 255 150;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/* Reusable component classes */
|
|
440
|
-
@layer components {
|
|
441
|
-
.btn-primary {
|
|
442
|
-
@apply bg-[rgb(var(--color-primary))] text-white rounded-[var(--radius)];
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
.card {
|
|
446
|
-
@apply shadow-md rounded-lg p-4 bg-white dark:bg-gray-800;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/* Custom utility classes */
|
|
451
|
-
@layer utilities {
|
|
452
|
-
.text-balance {
|
|
453
|
-
text-wrap: balance;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
2. In the project where the design system is imported:
|
|
459
|
-
- Import the global styles in the +layout.svelte file:
|
|
460
100
|
```svelte
|
|
101
|
+
<!-- src/routes/+layout.svelte -->
|
|
461
102
|
<script>
|
|
462
|
-
import '@widgetic/design-system/styles';
|
|
463
|
-
</script>
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
### Create a Custom Shared Component in the Design System project using a SHADCN UI component and classes from the global styles:
|
|
103
|
+
import '@widgetic/design-system/styles'; // Import global styles
|
|
468
104
|
|
|
469
|
-
|
|
470
|
-
```svelte
|
|
471
|
-
<script>
|
|
472
|
-
// Import Button from the SHADCN UI components
|
|
473
|
-
import { Button } from './components/ui';
|
|
105
|
+
// Your layout script...
|
|
474
106
|
</script>
|
|
475
107
|
|
|
476
|
-
<
|
|
477
|
-
{type}
|
|
478
|
-
class="btn-primary"
|
|
479
|
-
on:click
|
|
480
|
-
>
|
|
481
|
-
<slot />
|
|
482
|
-
</MyButton>
|
|
483
|
-
```
|
|
484
|
-
Then export the component in the "src/lib/components/index.ts" file:
|
|
485
|
-
```ts
|
|
486
|
-
export {default as MyButton } from './components/MyButton.svelte';
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
## Deployment of Design System
|
|
491
|
-
|
|
492
|
-
To deploy the design system, run the following command:
|
|
493
|
-
```bash
|
|
494
|
-
npm run prepublishOnly
|
|
495
|
-
```
|
|
496
|
-
This will create a `dist` folder with the production build of the design system.
|
|
497
|
-
|
|
498
|
-
To publish the design system to the npm registry, run the following command:
|
|
499
|
-
```bash
|
|
500
|
-
npm run publish-package
|
|
108
|
+
<slot />
|
|
501
109
|
```
|
|
502
110
|
|
|
503
|
-
##
|
|
504
|
-
|
|
505
|
-
The design system implements three distinct responsive grid layouts:
|
|
506
|
-
|
|
507
|
-
1. Site Grid
|
|
508
|
-
2. Dashboard Grid
|
|
509
|
-
3. App Grid
|
|
510
|
-
|
|
511
|
-
### Grid Breakpoints
|
|
512
|
-
- Desktop: > 744px
|
|
513
|
-
- Tablet: 393px - 744px
|
|
514
|
-
- Mobile: ≤ 393px
|
|
515
|
-
|
|
516
|
-
### 1. Site Grid
|
|
517
|
-
|
|
518
|
-
**Desktop (>744px)**
|
|
519
|
-
- 12 columns
|
|
520
|
-
- 144px margins
|
|
521
|
-
- 24px gutters
|
|
522
|
-
- Stretching columns with auto width
|
|
523
|
-
|
|
524
|
-
**Tablet (≤744px)**
|
|
525
|
-
- 8 columns
|
|
526
|
-
- 32px margins
|
|
527
|
-
- 16px gutters
|
|
528
|
-
- Stretching columns with auto width
|
|
529
|
-
|
|
530
|
-
**Mobile (≤393px)**
|
|
531
|
-
- 4 columns
|
|
532
|
-
- 16px margins
|
|
533
|
-
- 16px gutters
|
|
534
|
-
- Stretching columns with auto width
|
|
535
|
-
|
|
536
|
-
### 2. Dashboard Grid
|
|
537
|
-
|
|
538
|
-
**Desktop (>744px)**
|
|
539
|
-
- Header: 12 columns, 24px margins, 20px gutters
|
|
540
|
-
- Sidebar: 240px fixed width
|
|
541
|
-
- Main Content: 12 columns, 24px margins, 20px gutters
|
|
542
|
-
- 56px header height
|
|
543
|
-
|
|
544
|
-
**Tablet (≤744px)**
|
|
545
|
-
- Header: 8 columns
|
|
546
|
-
- Sidebar: 200px fixed width
|
|
547
|
-
- Main Content: 8 columns
|
|
548
|
-
- 16px margins and gutters
|
|
549
|
-
|
|
550
|
-
**Mobile (≤393px)**
|
|
551
|
-
- Header: 4 columns
|
|
552
|
-
- Sidebar replaced with menu component
|
|
553
|
-
- Main Content: 4 columns
|
|
554
|
-
- 16px margins and gutters
|
|
111
|
+
## Usage
|
|
555
112
|
|
|
556
|
-
###
|
|
113
|
+
### Components
|
|
557
114
|
|
|
558
|
-
|
|
559
|
-
- Header: 12 columns, 24px margins, 20px gutters
|
|
560
|
-
- Main Content: 12 columns, 144px margins, 20px gutters
|
|
561
|
-
- 56px header height
|
|
562
|
-
|
|
563
|
-
**Tablet (≤744px)**
|
|
564
|
-
- Header: 8 columns
|
|
565
|
-
- Main Content: 8 columns, 32px margins
|
|
566
|
-
- 16px gutters
|
|
567
|
-
|
|
568
|
-
**Mobile (≤393px)**
|
|
569
|
-
- Header: 4 columns
|
|
570
|
-
- Menu component added below header
|
|
571
|
-
- Main Content: 4 columns
|
|
572
|
-
- 16px margins and gutters
|
|
573
|
-
|
|
574
|
-
### Usage Example
|
|
115
|
+
Import components directly from the package:
|
|
575
116
|
|
|
576
117
|
```svelte
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
<footer class="grid-footer">Footer Content</footer>
|
|
583
|
-
<div class="grid-margin-right"></div>
|
|
584
|
-
</div>
|
|
585
|
-
|
|
586
|
-
<!-- Dashboard Grid -->
|
|
587
|
-
<div class="dashboard-grid">
|
|
588
|
-
<div class="grid-margin-left"></div>
|
|
589
|
-
<header class="dashboard-header-grid">
|
|
590
|
-
<!-- Header content with 12/8/4 columns based on viewport -->
|
|
591
|
-
</header>
|
|
592
|
-
<nav class="grid-sidebar">
|
|
593
|
-
<!-- Sidebar content (hidden on mobile) -->
|
|
594
|
-
</nav>
|
|
595
|
-
<main class="dashboard-main-grid">
|
|
596
|
-
<!-- Main content with 12/8/4 columns based on viewport -->
|
|
597
|
-
</main>
|
|
598
|
-
<div class="grid-margin-right"></div>
|
|
599
|
-
<!-- Mobile menu appears automatically on small screens -->
|
|
600
|
-
<div class="grid-menu">
|
|
601
|
-
<!-- Mobile menu content -->
|
|
602
|
-
</div>
|
|
603
|
-
</div>
|
|
604
|
-
|
|
605
|
-
<!-- App Grid -->
|
|
606
|
-
<div class="app-grid">
|
|
607
|
-
<div class="grid-margin-left"></div>
|
|
608
|
-
<header class="app-header-grid">
|
|
609
|
-
<!-- Header content with 12/8/4 columns based on viewport -->
|
|
610
|
-
</header>
|
|
611
|
-
<main class="app-main-grid">
|
|
612
|
-
<!-- Main content with 12/8/4 columns based on viewport -->
|
|
613
|
-
</main>
|
|
614
|
-
<div class="grid-margin-right"></div>
|
|
615
|
-
<!-- Mobile menu appears automatically on small screens -->
|
|
616
|
-
<div class="grid-menu">
|
|
617
|
-
<!-- Mobile menu content -->
|
|
618
|
-
</div>
|
|
619
|
-
</div>
|
|
620
|
-
```
|
|
621
|
-
|
|
622
|
-
### Grid Area Classes
|
|
623
|
-
The following classes are available to position elements within the grid:
|
|
624
|
-
```css
|
|
625
|
-
.grid-header /* Header area */
|
|
626
|
-
.grid-main /* Main content area */
|
|
627
|
-
.grid-sidebar /* Sidebar area (dashboard only) */
|
|
628
|
-
.grid-footer /* Footer area (site only) */
|
|
629
|
-
.grid-toolbar /* Toolbar area (app only) */
|
|
630
|
-
.grid-margin-left /* Left margin area */
|
|
631
|
-
.grid-margin-right/* Right margin area */
|
|
632
|
-
.grid-menu /* Mobile menu area */
|
|
633
|
-
.grid-gap /* Gap area (dashboard only) */
|
|
634
|
-
```
|
|
118
|
+
<script>
|
|
119
|
+
import { Button, Card, CardHeader, CardTitle, CardContent } from '@widgetic/design-system';
|
|
120
|
+
// For grouped components (like Table, Accordion), use the namespace
|
|
121
|
+
import { Table } from '@widgetic/design-system';
|
|
122
|
+
</script>
|
|
635
123
|
|
|
636
|
-
|
|
124
|
+
<Button>Click Me</Button>
|
|
637
125
|
|
|
638
|
-
|
|
126
|
+
<Card.Root>
|
|
127
|
+
<Card.Header>
|
|
128
|
+
<Card.Title>Card Title</Card.Title>
|
|
129
|
+
</Card.Header>
|
|
130
|
+
<Card.Content>
|
|
131
|
+
<p>Card body content...</p>
|
|
132
|
+
</Card.Content>
|
|
133
|
+
</Card.Root>
|
|
639
134
|
|
|
640
|
-
|
|
135
|
+
<Table.Root>
|
|
136
|
+
<Table.Header>
|
|
137
|
+
<Table.Row>
|
|
138
|
+
<Table.Head>Header 1</Table.Head>
|
|
139
|
+
</Table.Row>
|
|
140
|
+
</Table.Header>
|
|
141
|
+
<Table.Body>
|
|
142
|
+
<Table.Row>
|
|
143
|
+
<Table.Cell>Cell 1</Table.Cell>
|
|
144
|
+
</Table.Row>
|
|
145
|
+
</Table.Body>
|
|
146
|
+
</Table.Root>
|
|
147
|
+
```
|
|
641
148
|
|
|
642
|
-
|
|
149
|
+
Refer to the specific component documentation or source code for available props and variants.
|
|
643
150
|
|
|
644
|
-
|
|
645
|
-
- Customizable title, message, and button labels
|
|
646
|
-
- Works with any type of items to be deleted
|
|
647
|
-
- Dispatches events for both confirmation and cancellation
|
|
151
|
+
### Icons
|
|
648
152
|
|
|
649
|
-
|
|
153
|
+
Import required icons by name:
|
|
650
154
|
|
|
651
155
|
```svelte
|
|
652
156
|
<script>
|
|
653
|
-
import {
|
|
654
|
-
|
|
655
|
-
let showDeleteConfirmation = false;
|
|
656
|
-
let itemsToDelete = [
|
|
657
|
-
{ id: '1', name: 'Document.pdf', type: 'file' },
|
|
658
|
-
{ id: '2', name: 'Images', type: 'folder' }
|
|
659
|
-
];
|
|
660
|
-
|
|
661
|
-
function handleDelete(event) {
|
|
662
|
-
const deletedItems = event.detail.items;
|
|
663
|
-
console.log('Items to delete:', deletedItems);
|
|
664
|
-
// Perform deletion logic here
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
function handleCancel() {
|
|
668
|
-
showDeleteConfirmation = false;
|
|
669
|
-
console.log('Deletion cancelled');
|
|
670
|
-
}
|
|
157
|
+
import { ChevronUp, IconSettings } from '@widgetic/design-system/icons'; // Example names
|
|
671
158
|
</script>
|
|
672
159
|
|
|
673
|
-
<button
|
|
674
|
-
|
|
160
|
+
<button>
|
|
161
|
+
<ChevronUp class="size-4" /> Settings <IconSettings class="size-4" />
|
|
675
162
|
</button>
|
|
676
|
-
|
|
677
|
-
<DeleteConfirmation
|
|
678
|
-
bind:isOpen={showDeleteConfirmation}
|
|
679
|
-
items={itemsToDelete}
|
|
680
|
-
modalId="my-delete-confirmation"
|
|
681
|
-
on:delete={handleDelete}
|
|
682
|
-
on:cancel={handleCancel}
|
|
683
|
-
/>
|
|
684
163
|
```
|
|
685
164
|
|
|
686
|
-
###
|
|
687
|
-
|
|
688
|
-
| Prop | Type | Default | Description |
|
|
689
|
-
|------|------|---------|-------------|
|
|
690
|
-
| `isOpen` | boolean | `false` | Controls the visibility of the modal |
|
|
691
|
-
| `items` | array | `[]` | Array of items to be deleted |
|
|
692
|
-
| `title` | string | `''` | Custom title for the modal (autogenerated if empty) |
|
|
693
|
-
| `message` | string | `''` | Custom message for the modal (autogenerated if empty) |
|
|
694
|
-
| `confirmLabel` | string | `'Confirm'` | Label for the confirm button |
|
|
695
|
-
| `cancelLabel` | string | `'Cancel'` | Label for the cancel button |
|
|
696
|
-
| `width` | string | `'410px'` | Width of the modal |
|
|
697
|
-
| `height` | string | `'168px'` | Height of the modal |
|
|
698
|
-
| `modalId` | string | `'delete-confirmation-modal'` | ID for targeting the modal |
|
|
699
|
-
|
|
700
|
-
### Events
|
|
701
|
-
|
|
702
|
-
- `delete` - Dispatched when the user confirms deletion, with `items` in the event detail
|
|
703
|
-
- `cancel` - Dispatched when the user cancels deletion
|
|
704
|
-
|
|
705
|
-
### Custom Title and Message Example
|
|
165
|
+
### Fonts & Typography
|
|
706
166
|
|
|
707
|
-
You can
|
|
167
|
+
The global styles load the necessary `@font-face` rules. You can apply typography using standard Tailwind utility classes (e.g., `text-lg`, `font-semibold`) or the custom typography utility classes exported by the design system (defined in `fonts.css`, like `h1`, `body-medium`, `subtext`).
|
|
708
168
|
|
|
709
169
|
```svelte
|
|
710
|
-
<
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
let showDeleteConfirmation = false;
|
|
714
|
-
let selectedItems = [
|
|
715
|
-
{ id: '1', name: 'Document.pdf', type: 'file' },
|
|
716
|
-
{ id: '2', name: 'Images', type: 'folder' }
|
|
717
|
-
];
|
|
718
|
-
|
|
719
|
-
function handleDelete(event) {
|
|
720
|
-
const deletedItems = event.detail.items;
|
|
721
|
-
console.log('Items to delete:', deletedItems);
|
|
722
|
-
// Perform deletion logic here
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
function handleCancel() {
|
|
726
|
-
showDeleteConfirmation = false;
|
|
727
|
-
console.log('Deletion cancelled');
|
|
728
|
-
}
|
|
729
|
-
</script>
|
|
730
|
-
|
|
731
|
-
<DeleteConfirmation
|
|
732
|
-
bind:isOpen={showDeleteConfirmation}
|
|
733
|
-
items={selectedItems}
|
|
734
|
-
title="Delete Assets"
|
|
735
|
-
message="These assets will be permanently deleted. This action cannot be undone."
|
|
736
|
-
confirmLabel="Delete Permanently"
|
|
737
|
-
on:delete={handleDelete}
|
|
738
|
-
on:cancel={handleCancel}
|
|
739
|
-
/>
|
|
170
|
+
<h1 class="h1">Main Title</h1>
|
|
171
|
+
<p class="body-medium">This is body text.</p>
|
|
172
|
+
<span class="subtext">Some smaller text.</span>
|
|
740
173
|
```
|
|
741
174
|
|
|
742
|
-
|
|
743
175
|
## Troubleshooting
|
|
744
176
|
|
|
745
177
|
### File Case Sensitivity Issues (macOS/Windows Teams)
|