crayon-design-system-ui 0.0.1 → 0.0.2
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 +98 -89
- package/package.json +18 -5
package/README.md
CHANGED
|
@@ -38,16 +38,16 @@ Everything inside `src/lib` is part of your library, everything inside `src/rout
|
|
|
38
38
|
|
|
39
39
|
## Building
|
|
40
40
|
|
|
41
|
-
To build
|
|
41
|
+
To build the library and browser bundle (runs `vite build`, `build:browser`, then `prepack`):
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
|
-
npm
|
|
44
|
+
npm run build
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
To create a
|
|
47
|
+
To create a publishable package (includes `prepack`: Svelte package, component builds, React/Angular build):
|
|
48
48
|
|
|
49
49
|
```sh
|
|
50
|
-
npm
|
|
50
|
+
npm pack
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
You can preview the production build with `npm run preview`.
|
|
@@ -83,7 +83,9 @@ Example:
|
|
|
83
83
|
<ui-button></ui-button>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
**Component usage docs:** See [docs/README.md](docs/README.md) for a list of per-component usage documents
|
|
86
|
+
**Component usage docs:** See [docs/README.md](docs/README.md) for a list of per-component usage documents. When you change a component in `src/lib/components/`, update its doc in `docs/components/` so the docs stay in sync.
|
|
87
|
+
|
|
88
|
+
**Design tokens:** Import `crayon-design-system-ui/tokens.css` for CSS custom properties (colors, spacing, etc.); see [docs/design-tokens.md](docs/design-tokens.md) if present.
|
|
87
89
|
|
|
88
90
|
---
|
|
89
91
|
|
|
@@ -115,19 +117,22 @@ design-system-ui/
|
|
|
115
117
|
src/
|
|
116
118
|
lib/
|
|
117
119
|
components/
|
|
118
|
-
Button.svelte
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
button/Button.svelte
|
|
121
|
+
accordion/Accordion.svelte
|
|
122
|
+
input/Input.svelte
|
|
123
|
+
... (one folder per component)
|
|
124
|
+
register.ts ← SSR-safe registration (registers all custom elements)
|
|
125
|
+
index.ts ← Svelte component exports
|
|
126
|
+
register.ts ← Entry that imports lib/register (used by package)
|
|
127
|
+
register-browser.ts ← Browser bundle entry (imports all components)
|
|
128
|
+
|
|
129
|
+
vite.config.ts ← SvelteKit app build
|
|
130
|
+
vite.browser.config.ts ← Browser bundle (dist-browser/bundle.js)
|
|
131
|
+
vite.components.config.ts ← Custom element .js builds (dist/components/...)
|
|
126
132
|
package.json
|
|
127
133
|
|
|
128
|
-
|
|
129
|
-
dist/
|
|
130
|
-
dist-browser/
|
|
134
|
+
dist/ ← Library build (Svelte, types, register, react, angular)
|
|
135
|
+
dist-browser/ ← Browser bundle + tokens.css
|
|
131
136
|
```
|
|
132
137
|
|
|
133
138
|
---
|
|
@@ -155,29 +160,25 @@ Supports:
|
|
|
155
160
|
|
|
156
161
|
# Build Commands
|
|
157
162
|
|
|
158
|
-
##
|
|
163
|
+
## Full build
|
|
159
164
|
|
|
160
165
|
```
|
|
161
166
|
npm run build
|
|
162
167
|
```
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
Runs `vite build`, then `npm run build:browser`, then `npm run prepack`. Produces `dist/` (library + register + React/Angular) and `dist-browser/` (bundle.js, tokens.css).
|
|
165
170
|
|
|
166
|
-
|
|
167
|
-
dist/
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Build browser bundle
|
|
171
|
+
## Build browser bundle only
|
|
171
172
|
|
|
172
173
|
```
|
|
173
174
|
npm run build:browser
|
|
174
175
|
```
|
|
175
176
|
|
|
176
|
-
Output:
|
|
177
|
+
Output: `dist-browser/bundle.js` and `dist-browser/tokens.css`.
|
|
177
178
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
## Prepack (library + single-component register)
|
|
180
|
+
|
|
181
|
+
`npm run prepack` (or `npm pack`) runs: SvelteKit sync, `svelte-package`, component build, scripts (add-default-export, patch-index, generate-register-entries, strip-svelte-types), TypeScript for React and Angular, then publint. Required before publishing.
|
|
181
182
|
|
|
182
183
|
---
|
|
183
184
|
|
|
@@ -189,40 +190,47 @@ Create installable package:
|
|
|
189
190
|
npm pack
|
|
190
191
|
```
|
|
191
192
|
|
|
192
|
-
Produces:
|
|
193
|
+
Produces (package name + version):
|
|
193
194
|
|
|
194
195
|
```
|
|
195
|
-
design-system-ui-0.0.1.tgz
|
|
196
|
+
crayon-design-system-ui-0.0.1.tgz
|
|
196
197
|
```
|
|
197
198
|
|
|
198
199
|
Install in another project:
|
|
199
200
|
|
|
200
201
|
```
|
|
201
|
-
npm install
|
|
202
|
+
npm install ./crayon-design-system-ui-0.0.1.tgz
|
|
202
203
|
```
|
|
203
204
|
|
|
204
205
|
---
|
|
205
206
|
|
|
206
207
|
# Usage — Plain HTML
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
With a bundler (e.g. Vite, Rollup), use the register entry:
|
|
210
|
+
|
|
211
|
+
```html
|
|
209
212
|
<script type="module">
|
|
210
|
-
import 'design-system-ui';
|
|
213
|
+
import 'crayon-design-system-ui/register';
|
|
211
214
|
</script>
|
|
215
|
+
<ui-button variant="primary">Click Me</ui-button>
|
|
216
|
+
```
|
|
212
217
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
218
|
+
Without a bundler, use the browser bundle (e.g. copy `node_modules/crayon-design-system-ui/dist-browser/bundle.js` and optionally `tokens.css` to your server, or use a CDN):
|
|
219
|
+
|
|
220
|
+
```html
|
|
221
|
+
<link rel="stylesheet" href="tokens.css" />
|
|
222
|
+
<script type="module" src="bundle.js"></script>
|
|
223
|
+
<ui-button variant="primary">Click Me</ui-button>
|
|
216
224
|
```
|
|
217
225
|
|
|
218
226
|
Optional click event:
|
|
219
227
|
|
|
220
|
-
```
|
|
228
|
+
```js
|
|
221
229
|
document.querySelector('ui-button')
|
|
222
230
|
.addEventListener('ui-click', () => alert('Clicked'));
|
|
223
231
|
```
|
|
224
232
|
|
|
225
|
-
Run
|
|
233
|
+
Run with a local server:
|
|
226
234
|
|
|
227
235
|
```
|
|
228
236
|
npx serve .
|
|
@@ -269,6 +277,8 @@ In Svelte apps you can also use the **Svelte component** directly (package name:
|
|
|
269
277
|
|
|
270
278
|
Other named exports: `Input`, `Textarea`, `Accordion`, `AccordionItem`, `FormSelect`, `FormSelectOption`, `Checkbox`, `Radio`, `Label`, `Form`, `Avatar`, `Card`. Use this when your app and the design system are on the same major Svelte version; otherwise use the custom elements above.
|
|
271
279
|
|
|
280
|
+
For a single component (smaller bundle), import the Svelte file directly: `import Button from 'crayon-design-system-ui/components/button/Button.svelte'`.
|
|
281
|
+
|
|
272
282
|
---
|
|
273
283
|
|
|
274
284
|
# Usage — SvelteKit
|
|
@@ -366,59 +376,65 @@ import 'crayon-design-system-ui/register';
|
|
|
366
376
|
|
|
367
377
|
# SSR-safe Registration
|
|
368
378
|
|
|
369
|
-
|
|
379
|
+
Registration runs only in the browser. Logic lives in `src/lib/register.ts`; the package entry `src/register.ts` imports it.
|
|
370
380
|
|
|
371
|
-
```
|
|
372
|
-
src/register.ts
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
```
|
|
381
|
+
```js
|
|
382
|
+
// src/lib/register.ts (simplified)
|
|
376
383
|
if (typeof window !== 'undefined' && 'customElements' in window) {
|
|
377
|
-
import('./
|
|
384
|
+
void import('./components/button/Button.svelte');
|
|
385
|
+
void import('./components/accordion/Accordion.svelte');
|
|
386
|
+
// ... all components
|
|
378
387
|
}
|
|
379
388
|
```
|
|
380
389
|
|
|
381
|
-
Prevents server-side rendering errors
|
|
390
|
+
Prevents server-side rendering errors when using `import 'crayon-design-system-ui/register'`.
|
|
382
391
|
|
|
383
392
|
---
|
|
384
393
|
|
|
385
394
|
# package.json (important fields)
|
|
386
395
|
|
|
396
|
+
Main entry is the library (Svelte + types); custom elements are registered via `crayon-design-system-ui/register` or the browser bundle.
|
|
397
|
+
|
|
387
398
|
```
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
399
|
+
"main": "./dist/index.js",
|
|
400
|
+
"module": "./dist/index.js",
|
|
401
|
+
"types": "./dist/index.d.ts",
|
|
402
|
+
"svelte": "./dist/index.js",
|
|
391
403
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
},
|
|
404
|
+
"exports": {
|
|
405
|
+
".": { "types": "./dist/index.d.ts", "svelte": "./dist/index.js", "import": "./dist/index.js", "default": "./dist/index.js" },
|
|
406
|
+
"./register": { "types": "./dist/register.d.ts", "import": "./dist/register.js", "default": "./dist/register.js" },
|
|
407
|
+
"./register/*": { "types": "./dist/register/*.d.ts", "import": "./dist/register/*.js", "default": "./dist/register/*.js" },
|
|
408
|
+
"./components/*": { "types": "./dist/components/*.svelte.d.ts", "svelte": "./dist/components/*.svelte", "import": "./dist/components/*.svelte" },
|
|
409
|
+
"./react": { "types": "./dist/react/index.d.ts", "import": "./dist/react/index.js", "default": "./dist/react/index.js" },
|
|
410
|
+
"./angular": { "types": "./dist/angular/index.d.ts", "import": "./dist/angular/index.js", "default": "./dist/angular/index.js" },
|
|
411
|
+
"./tokens.css": "./dist/tokens.css"
|
|
412
|
+
},
|
|
398
413
|
|
|
399
|
-
|
|
400
|
-
"dist",
|
|
401
|
-
"dist-browser"
|
|
402
|
-
]
|
|
403
|
-
}
|
|
414
|
+
"files": [ "dist", "dist-browser" ]
|
|
404
415
|
```
|
|
405
416
|
|
|
406
|
-
|
|
417
|
+
Peer dependencies (all optional): `svelte`, `react`, `react-dom`, `@angular/core`.
|
|
407
418
|
|
|
408
419
|
---
|
|
409
420
|
|
|
410
421
|
# Development
|
|
411
422
|
|
|
412
|
-
Run dev server:
|
|
423
|
+
Run dev server (showcase app):
|
|
413
424
|
|
|
414
425
|
```
|
|
415
426
|
npm run dev
|
|
416
427
|
```
|
|
417
428
|
|
|
418
|
-
Build everything:
|
|
429
|
+
Build everything (library + browser bundle + prepack):
|
|
419
430
|
|
|
420
431
|
```
|
|
421
432
|
npm run build
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Build only the browser bundle:
|
|
436
|
+
|
|
437
|
+
```
|
|
422
438
|
npm run build:browser
|
|
423
439
|
```
|
|
424
440
|
|
|
@@ -426,19 +442,13 @@ npm run build:browser
|
|
|
426
442
|
|
|
427
443
|
# How It Works
|
|
428
444
|
|
|
429
|
-
When
|
|
445
|
+
When you import the register entry:
|
|
430
446
|
|
|
431
|
-
```
|
|
432
|
-
import 'design-system-ui'
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
The browser bundle executes:
|
|
436
|
-
|
|
437
|
-
```
|
|
438
|
-
customElements.define('ui-button', ...)
|
|
447
|
+
```js
|
|
448
|
+
import 'crayon-design-system-ui/register';
|
|
439
449
|
```
|
|
440
450
|
|
|
441
|
-
|
|
451
|
+
the package loads and, in the browser, dynamically imports each component’s compiled output. Each component calls `customElements.define('ui-button', ...)` (and the other tags), so the custom elements are registered globally. Using the single-component entry (e.g. `import 'crayon-design-system-ui/register/button'`) registers only that component.
|
|
442
452
|
|
|
443
453
|
---
|
|
444
454
|
|
|
@@ -446,29 +456,27 @@ Registers the component globally.
|
|
|
446
456
|
|
|
447
457
|
Works in:
|
|
448
458
|
|
|
449
|
-
- Plain HTML
|
|
450
|
-
- SvelteKit
|
|
451
|
-
- React
|
|
452
|
-
- Angular
|
|
453
|
-
- Vue
|
|
454
|
-
- Any browser-based framework
|
|
459
|
+
- **Plain HTML** (with a bundler, or by loading `dist-browser/bundle.js` and `tokens.css`)
|
|
460
|
+
- **Svelte / SvelteKit** (named Svelte components or custom elements)
|
|
461
|
+
- **React** (wrapper components from `crayon-design-system-ui/react`; register once)
|
|
462
|
+
- **Angular** (wrapper components / `CrayonDesignSystemModule` from `crayon-design-system-ui/angular`; register once)
|
|
463
|
+
- **Vue** and any other framework (use custom elements after `import 'crayon-design-system-ui/register'`)
|
|
455
464
|
|
|
456
465
|
---
|
|
457
466
|
|
|
458
467
|
# Next Steps
|
|
459
468
|
|
|
460
|
-
|
|
469
|
+
Current components: Button, Accordion, AccordionItem, Input, Textarea, FormSelect, FormSelectOption, Checkbox, Radio, Label, Form, Avatar, Card.
|
|
470
|
+
|
|
471
|
+
Ideas for more:
|
|
461
472
|
|
|
462
|
-
-
|
|
463
|
-
- Card
|
|
464
|
-
- Modal
|
|
465
|
-
- Select
|
|
473
|
+
- Modal, Tabs, Tooltip, Dropdown
|
|
466
474
|
|
|
467
475
|
Optional:
|
|
468
476
|
|
|
469
477
|
- Storybook
|
|
470
478
|
- Private npm publish
|
|
471
|
-
-
|
|
479
|
+
- Expand design tokens (see `tokens.css` and `./tokens.css` export)
|
|
472
480
|
|
|
473
481
|
---
|
|
474
482
|
|
|
@@ -476,11 +484,12 @@ Optional:
|
|
|
476
484
|
|
|
477
485
|
This design system:
|
|
478
486
|
|
|
479
|
-
- Uses Web Components
|
|
480
|
-
- Framework independent
|
|
481
|
-
- npm installable
|
|
482
|
-
- SSR-safe
|
|
483
|
-
-
|
|
487
|
+
- Uses **Svelte 5** and **Web Components** (custom elements)
|
|
488
|
+
- **Framework independent**: HTML, Svelte, React, Angular, Vue (custom elements + optional wrappers for React/Angular)
|
|
489
|
+
- **npm installable** as `crayon-design-system-ui`
|
|
490
|
+
- **SSR-safe** registration
|
|
491
|
+
- Exports: main (Svelte), `register` / `register/*`, `components/*`, `react`, `angular`, `tokens.css`
|
|
492
|
+
- Production-ready foundation
|
|
484
493
|
|
|
485
494
|
---
|
|
486
495
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crayon-design-system-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "vite dev",
|
|
6
6
|
"build": "vite build && npm run build:browser && npm run prepack",
|
|
@@ -40,6 +40,11 @@
|
|
|
40
40
|
"import": "./dist/register.js",
|
|
41
41
|
"default": "./dist/register.js"
|
|
42
42
|
},
|
|
43
|
+
"./register/*": {
|
|
44
|
+
"types": "./dist/register/*.d.ts",
|
|
45
|
+
"import": "./dist/register/*.js",
|
|
46
|
+
"default": "./dist/register/*.js"
|
|
47
|
+
},
|
|
43
48
|
"./components/*": {
|
|
44
49
|
"types": "./dist/components/*.svelte.d.ts",
|
|
45
50
|
"svelte": "./dist/components/*.svelte",
|
|
@@ -64,10 +69,18 @@
|
|
|
64
69
|
"@angular/core": ">=17.0.0"
|
|
65
70
|
},
|
|
66
71
|
"peerDependenciesMeta": {
|
|
67
|
-
"svelte": {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"
|
|
72
|
+
"svelte": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"react": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"react-dom": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"@angular/core": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
71
84
|
},
|
|
72
85
|
"devDependencies": {
|
|
73
86
|
"@angular/core": "^19.0.0",
|