@ssejal8/recipe-ui-kit 0.1.0

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.
Files changed (87) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/.npmr +1 -0
  3. package/README.md +354 -0
  4. package/apps/recipe-web/package.json +31 -0
  5. package/apps/recipe-web/src/app.css +418 -0
  6. package/apps/recipe-web/src/app.d.ts +32 -0
  7. package/apps/recipe-web/src/app.html +25 -0
  8. package/apps/recipe-web/src/lib/api/mealdb.ts +240 -0
  9. package/apps/recipe-web/src/lib/components/AppHeader.svelte +290 -0
  10. package/apps/recipe-web/src/lib/components/ConfirmDialog.svelte +46 -0
  11. package/apps/recipe-web/src/lib/components/Modal.svelte +33 -0
  12. package/apps/recipe-web/src/lib/components/RecipeCard.svelte +100 -0
  13. package/apps/recipe-web/src/lib/components/RecipeForm.svelte +560 -0
  14. package/apps/recipe-web/src/lib/components/RecipeGrid.svelte +77 -0
  15. package/apps/recipe-web/src/lib/components/RecipePickerDialog.svelte +185 -0
  16. package/apps/recipe-web/src/lib/components/Toaster.svelte +111 -0
  17. package/apps/recipe-web/src/lib/domain/recipe.ts +130 -0
  18. package/apps/recipe-web/src/lib/domain/validation.ts +189 -0
  19. package/apps/recipe-web/src/lib/stencil/WebComponent.svelte +145 -0
  20. package/apps/recipe-web/src/lib/stencil/register.ts +28 -0
  21. package/apps/recipe-web/src/lib/stores/favorites.svelte.ts +81 -0
  22. package/apps/recipe-web/src/lib/stores/myRecipes.svelte.ts +98 -0
  23. package/apps/recipe-web/src/lib/stores/persisted.svelte.ts +73 -0
  24. package/apps/recipe-web/src/lib/stores/planner.svelte.ts +275 -0
  25. package/apps/recipe-web/src/lib/stores/theme.svelte.ts +67 -0
  26. package/apps/recipe-web/src/lib/stores/toast.svelte.ts +66 -0
  27. package/apps/recipe-web/src/routes/+error.svelte +36 -0
  28. package/apps/recipe-web/src/routes/+layout.svelte +62 -0
  29. package/apps/recipe-web/src/routes/+page.svelte +352 -0
  30. package/apps/recipe-web/src/routes/+page.ts +107 -0
  31. package/apps/recipe-web/src/routes/favorites/+page.svelte +170 -0
  32. package/apps/recipe-web/src/routes/my-recipes/+layout.ts +55 -0
  33. package/apps/recipe-web/src/routes/my-recipes/+page.svelte +180 -0
  34. package/apps/recipe-web/src/routes/my-recipes/[id]/edit/+page.svelte +104 -0
  35. package/apps/recipe-web/src/routes/my-recipes/new/+page.svelte +67 -0
  36. package/apps/recipe-web/src/routes/planner/+page.svelte +422 -0
  37. package/apps/recipe-web/src/routes/recipes/[id]/+page.svelte +538 -0
  38. package/apps/recipe-web/src/routes/recipes/[id]/+page.ts +24 -0
  39. package/apps/recipe-web/static/favicon.svg +8 -0
  40. package/apps/recipe-web/static/robots.txt +2 -0
  41. package/apps/recipe-web/svelte.config.js +35 -0
  42. package/apps/recipe-web/tsconfig.json +14 -0
  43. package/apps/recipe-web/vite.config.ts +23 -0
  44. package/package.json +29 -0
  45. package/packages/recipe-kit-stencil/LICENSE +21 -0
  46. package/packages/recipe-kit-stencil/README.md +185 -0
  47. package/packages/recipe-kit-stencil/package-lock.json +4772 -0
  48. package/packages/recipe-kit-stencil/package.json +91 -0
  49. package/packages/recipe-kit-stencil/src/components/rk-badge/readme.md +38 -0
  50. package/packages/recipe-kit-stencil/src/components/rk-badge/rk-badge.css +102 -0
  51. package/packages/recipe-kit-stencil/src/components/rk-badge/rk-badge.tsx +31 -0
  52. package/packages/recipe-kit-stencil/src/components/rk-chip/readme.md +52 -0
  53. package/packages/recipe-kit-stencil/src/components/rk-chip/rk-chip.css +155 -0
  54. package/packages/recipe-kit-stencil/src/components/rk-chip/rk-chip.tsx +105 -0
  55. package/packages/recipe-kit-stencil/src/components/rk-empty-state/readme.md +44 -0
  56. package/packages/recipe-kit-stencil/src/components/rk-empty-state/rk-empty-state.css +64 -0
  57. package/packages/recipe-kit-stencil/src/components/rk-empty-state/rk-empty-state.tsx +50 -0
  58. package/packages/recipe-kit-stencil/src/components/rk-meal-slot/readme.md +58 -0
  59. package/packages/recipe-kit-stencil/src/components/rk-meal-slot/rk-meal-slot.css +225 -0
  60. package/packages/recipe-kit-stencil/src/components/rk-meal-slot/rk-meal-slot.tsx +182 -0
  61. package/packages/recipe-kit-stencil/src/components/rk-modal/readme.md +57 -0
  62. package/packages/recipe-kit-stencil/src/components/rk-modal/rk-modal.css +163 -0
  63. package/packages/recipe-kit-stencil/src/components/rk-modal/rk-modal.tsx +176 -0
  64. package/packages/recipe-kit-stencil/src/components/rk-rating/readme.md +42 -0
  65. package/packages/recipe-kit-stencil/src/components/rk-rating/rk-rating.css +71 -0
  66. package/packages/recipe-kit-stencil/src/components/rk-rating/rk-rating.tsx +114 -0
  67. package/packages/recipe-kit-stencil/src/components/rk-recipe-card/readme.md +66 -0
  68. package/packages/recipe-kit-stencil/src/components/rk-recipe-card/rk-recipe-card.css +280 -0
  69. package/packages/recipe-kit-stencil/src/components/rk-recipe-card/rk-recipe-card.tsx +179 -0
  70. package/packages/recipe-kit-stencil/src/components/rk-recipe-card/test/rk-recipe-card.spec.tsx +70 -0
  71. package/packages/recipe-kit-stencil/src/components/rk-search-bar/readme.md +67 -0
  72. package/packages/recipe-kit-stencil/src/components/rk-search-bar/rk-search-bar.css +141 -0
  73. package/packages/recipe-kit-stencil/src/components/rk-search-bar/rk-search-bar.tsx +152 -0
  74. package/packages/recipe-kit-stencil/src/components/rk-search-bar/test/rk-search-bar.spec.tsx +93 -0
  75. package/packages/recipe-kit-stencil/src/components/rk-segmented-control/readme.md +41 -0
  76. package/packages/recipe-kit-stencil/src/components/rk-segmented-control/rk-segmented-control.css +91 -0
  77. package/packages/recipe-kit-stencil/src/components/rk-segmented-control/rk-segmented-control.tsx +115 -0
  78. package/packages/recipe-kit-stencil/src/components/rk-tag-input/readme.md +47 -0
  79. package/packages/recipe-kit-stencil/src/components/rk-tag-input/rk-tag-input.css +146 -0
  80. package/packages/recipe-kit-stencil/src/components/rk-tag-input/rk-tag-input.tsx +181 -0
  81. package/packages/recipe-kit-stencil/src/components/rk-tag-input/test/rk-tag-input.spec.tsx +76 -0
  82. package/packages/recipe-kit-stencil/src/components.d.ts +1192 -0
  83. package/packages/recipe-kit-stencil/src/global/rk-global.css +104 -0
  84. package/packages/recipe-kit-stencil/src/index.html +259 -0
  85. package/packages/recipe-kit-stencil/src/index.ts +6 -0
  86. package/packages/recipe-kit-stencil/stencil.config.ts +41 -0
  87. package/packages/recipe-kit-stencil/tsconfig.json +24 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sejal Sharma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,185 @@
1
+ # recipe-kit-stencil
2
+
3
+ Framework-agnostic web components for recipe discovery, favorites and meal-planning UIs, built with [StencilJS](https://stenciljs.com/).
4
+
5
+ The library ships **standard custom elements**, so it works in SvelteKit, React, Vue, Angular or plain HTML with no framework-specific wrapper. It is consumed by the [Recipe Finder & Meal Planner](https://github.com/sejal-sharma/recipe-ui) SvelteKit application.
6
+
7
+ ```
8
+ npm install recipe-kit-stencil
9
+ ```
10
+
11
+ ---
12
+
13
+ ## Quick start
14
+
15
+ ### 1. Register the elements
16
+
17
+ ```js
18
+ import { defineCustomElements } from 'recipe-kit-stencil/loader';
19
+
20
+ defineCustomElements();
21
+ ```
22
+
23
+ `defineCustomElements()` registers every tag lazily — the code for a component is only fetched when that tag first appears in the DOM.
24
+
25
+ ### 2. Load the design tokens
26
+
27
+ ```js
28
+ import 'recipe-kit-stencil/dist/recipe-kit/recipe-kit.css';
29
+ ```
30
+
31
+ This stylesheet defines the `--rk-*` custom properties. Because custom properties inherit through the shadow boundary, it is the single place to re-theme the whole library.
32
+
33
+ ### 3. Use the elements
34
+
35
+ ```html
36
+ <rk-recipe-card
37
+ recipe-id="52772"
38
+ name="Teriyaki Chicken Casserole"
39
+ image="https://…/teriyaki.jpg"
40
+ category="Chicken"
41
+ area="Japanese"
42
+ minutes="45"
43
+ >
44
+ <rk-badge tone="accent" small>weeknight</rk-badge>
45
+ <button slot="actions">Add to plan</button>
46
+ </rk-recipe-card>
47
+ ```
48
+
49
+ ### SSR / SvelteKit note
50
+
51
+ Custom elements are a browser API, so registration must happen on the client only:
52
+
53
+ ```svelte
54
+ <script>
55
+ import { browser } from '$app/environment';
56
+ import { onMount } from 'svelte';
57
+
58
+ onMount(async () => {
59
+ const { defineCustomElements } = await import('recipe-kit-stencil/loader');
60
+ await defineCustomElements();
61
+ });
62
+ </script>
63
+ ```
64
+
65
+ Unknown tags render as inert elements during SSR and hydrate once the definitions land.
66
+
67
+ ---
68
+
69
+ ## Components
70
+
71
+ | Tag | Purpose | Key events |
72
+ | --- | --- | --- |
73
+ | `<rk-search-bar>` | Debounced search field with clear button and an `actions` slot | `rkSearch`, `rkClear` |
74
+ | `<rk-chip>` | Selectable / dismissible filter chip | `rkChipToggle`, `rkChipDismiss` |
75
+ | `<rk-segmented-control>` | Single-select segmented control (sorting, view switching) | `rkSegmentChange` |
76
+ | `<rk-recipe-card>` | Recipe tile with favorite toggle, badges slot and actions slot | `rkCardSelect`, `rkFavoriteToggle` |
77
+ | `<rk-rating>` | Star rating, read-only or interactive | `rkRatingChange` |
78
+ | `<rk-badge>` | Small slot-driven label with tone/variant options | — |
79
+ | `<rk-tag-input>` | Tag / token editor with de-duplication and a max-tags cap | `rkTagsChange` |
80
+ | `<rk-meal-slot>` | One planner cell: add target, filled slot, and drop zone | `rkMealAdd`, `rkMealSwap`, `rkMealRemove`, `rkMealOpen`, `rkMealDrop` |
81
+ | `<rk-modal>` | Accessible dialog with focus trap, Escape handling and slots | `rkModalClose` |
82
+ | `<rk-empty-state>` | Empty / error placeholder with an actions slot | — |
83
+
84
+ Per-component prop, event, slot and CSS-part tables are generated from source into each component folder — see [`src/components`](./src/components).
85
+
86
+ ---
87
+
88
+ ## Design principles
89
+
90
+ **Primitive props over object props.** `<rk-recipe-card>` takes `name`, `image`, `category` … as separate primitive properties rather than one `recipe` object. Primitives round-trip through HTML attributes, so the component is usable from plain markup in any framework.
91
+
92
+ **Complex props accept a string fallback.** `rk-segmented-control.options` and `rk-tag-input.values` are arrays. Assign them as DOM properties for the normal path; both also parse a JSON-encoded (or comma-separated) string attribute for consumers that cannot set properties.
93
+
94
+ **Components are controlled.** They emit an intent and let the host application own the state. `rkFavoriteToggle` reports the state to move *to*; the app persists it and passes `favorite` back down. Nothing is silently mutated behind the application's back.
95
+
96
+ **No global CSS leakage.** Every component uses shadow DOM. Styling hooks are exposed deliberately, via `--rk-*` custom properties and `part="…"` attributes.
97
+
98
+ ---
99
+
100
+ ## Theming
101
+
102
+ Override any token on `:root` — or on any ancestor, to scope a theme to a subtree:
103
+
104
+ ```css
105
+ :root {
106
+ --rk-primary: #7c3aed;
107
+ --rk-radius-lg: 8px;
108
+ --rk-font-display: 'Fraunces', serif;
109
+ }
110
+ ```
111
+
112
+ A dark palette is included and activates on `<html data-rk-theme="dark">` (or `data-theme="dark"`).
113
+
114
+ For finer control, target the exposed shadow parts:
115
+
116
+ ```css
117
+ rk-recipe-card::part(title) {
118
+ text-transform: uppercase;
119
+ }
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Events
125
+
126
+ Every event name is prefixed `rk` and bubbles with `composed: true`, so it can be handled on an ancestor rather than each element:
127
+
128
+ ```js
129
+ document.addEventListener('rkFavoriteToggle', (event) => {
130
+ const { recipeId, favorite } = event.detail;
131
+ });
132
+ ```
133
+
134
+ Payload types are exported for TypeScript consumers:
135
+
136
+ ```ts
137
+ import type { RkFavoriteToggleDetail, RkMealDropDetail, RkSegmentOption } from 'recipe-kit-stencil';
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Local development
143
+
144
+ ```bash
145
+ npm install
146
+ npm start # dev server with the component gallery at src/index.html
147
+ npm run build # production build + generated docs
148
+ npm test # spec tests
149
+ ```
150
+
151
+ `npm start` serves a gallery page that renders every component and logs every emitted event — useful for verifying behaviour outside the consuming app.
152
+
153
+ ---
154
+
155
+ ## Output targets
156
+
157
+ | Target | Output | Use case |
158
+ | --- | --- | --- |
159
+ | `dist` | `dist/`, `loader/` | Lazy-loaded elements. The default, and what the SvelteKit app uses. |
160
+ | `dist-custom-elements` | `dist/components/*.js` | Import and register a single component; tree-shakeable. |
161
+
162
+ ```js
163
+ // Single-component import
164
+ import { RkRecipeCard } from 'recipe-kit-stencil/components/rk-recipe-card';
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Versioning
170
+
171
+ [Semantic versioning](https://semver.org/):
172
+
173
+ - **patch** — bug fixes, styling corrections, no API change
174
+ - **minor** — new components, new optional props, new events
175
+ - **major** — renamed or removed props/events/tags, changed event payloads
176
+
177
+ ```bash
178
+ npm run release:patch # or release:minor / release:major
179
+ ```
180
+
181
+ `prepublishOnly` runs a clean production build, so a published tarball can never contain stale output.
182
+
183
+ ## License
184
+
185
+ MIT © Sejal Sharma