@eldrajs/theme-cli 0.2.4 → 0.2.5

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 (93) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +6 -0
  3. package/dist/cli.js +8 -2
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.js +1 -1
  6. package/dist/{validate-FjQ-5_ne.js → validate-CC6Mp5i_.js} +2 -1
  7. package/package.json +3 -3
  8. package/template/.eldra/previews.json +35 -35
  9. package/template/README.md +3 -1
  10. package/template/app/app.vue +1 -3
  11. package/template/app/assets/main.css +13 -15
  12. package/template/app/components/ui/UiImage.vue +29 -17
  13. package/template/app/components/ui/__tests__/UiImage.spec.ts +24 -15
  14. package/template/app/pages/[...slug].vue +1 -1
  15. package/template/blocks/announcement-bar/Block.vue +3 -2
  16. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
  17. package/template/blocks/article/Block.vue +3 -4
  18. package/template/blocks/article-list/Block.vue +18 -9
  19. package/template/blocks/breadcrumbs/Block.vue +1 -1
  20. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
  21. package/template/blocks/cart/Block.vue +1 -1
  22. package/template/blocks/cart/parts/CartLines.vue +3 -2
  23. package/template/blocks/cart/parts/ShippingBar.vue +1 -1
  24. package/template/blocks/cart/parts/Summary.vue +5 -9
  25. package/template/blocks/collection-grid/Block.vue +11 -14
  26. package/template/blocks/collection-grid/__tests__/Block.spec.ts +12 -14
  27. package/template/blocks/collection-header/Block.vue +5 -5
  28. package/template/blocks/contact/Block.vue +1 -1
  29. package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
  30. package/template/blocks/cta/Block.vue +16 -18
  31. package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
  32. package/template/blocks/faq/Block.vue +3 -13
  33. package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
  34. package/template/blocks/feature-grid/Block.vue +1 -1
  35. package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
  36. package/template/blocks/footer/Block.vue +14 -11
  37. package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
  38. package/template/blocks/form/Block.vue +1 -1
  39. package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
  40. package/template/blocks/hero/Block.vue +8 -11
  41. package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
  42. package/template/blocks/image/Block.vue +4 -4
  43. package/template/blocks/image/__tests__/Block.spec.ts +5 -6
  44. package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
  45. package/template/blocks/navigation/Block.vue +16 -26
  46. package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
  47. package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
  48. package/template/blocks/order-status/Block.vue +8 -9
  49. package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
  50. package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
  51. package/template/blocks/product-carousel/Block.vue +6 -6
  52. package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
  53. package/template/blocks/product-detail/Block.vue +8 -8
  54. package/template/blocks/product-detail/__tests__/Block.spec.ts +1 -1
  55. package/template/blocks/product-detail/parts/Gallery.vue +1 -1
  56. package/template/blocks/quote/Block.vue +1 -1
  57. package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
  58. package/template/blocks/search/Block.vue +2 -2
  59. package/template/blocks/search/PopularChips.vue +1 -1
  60. package/template/blocks/split-content/Block.vue +2 -3
  61. package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
  62. package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
  63. package/template/blocks/tabs/Block.vue +4 -5
  64. package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
  65. package/template/blocks/testimonials/Block.vue +10 -9
  66. package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
  67. package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
  68. package/template/blocks/trust-strip/Block.vue +1 -1
  69. package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
  70. package/template/blocks/video-embed/Block.vue +3 -3
  71. package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
  72. package/template/blocks/wishlist/Block.vue +1 -1
  73. package/template/nuxt.config.ts +5 -4
  74. package/template/package.json +1 -0
  75. package/template/stories/pages/article.stories.ts +2 -3
  76. package/template/stories/pages/cart.stories.ts +2 -3
  77. package/template/stories/pages/category.stories.ts +2 -3
  78. package/template/stories/pages/collection.stories.ts +2 -3
  79. package/template/stories/pages/home.stories.ts +2 -3
  80. package/template/stories/pages/product.stories.ts +3 -4
  81. package/template/stories/pages/products.stories.ts +2 -3
  82. package/template/stories/pages/search.stories.ts +2 -3
  83. package/template/stories/pages/wishlist.stories.ts +2 -3
  84. package/template/test/carouselKeyboard.spec.ts +2 -2
  85. package/template/test/carouselRing.browser.spec.ts +2 -2
  86. package/template/test/carouselSlideWidth.browser.spec.ts +9 -9
  87. package/template/test/eldraIcon.spec.ts +1 -1
  88. package/template/test/mainCss.spec.ts +7 -0
  89. package/template/test/pages/article.spec.ts +5 -5
  90. package/template/test/pages/collection.spec.ts +5 -5
  91. package/template/test/pages/hydration.spec.ts +10 -10
  92. package/template/test/prerenderRefresh.browser.spec.ts +1 -1
  93. package/template/test/support/mountPage.ts +2 -3
package/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ Release-please writes the generated notes from commit messages and does not repl
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ - `eldra-theme types` asks the gateway for the `declare module '@eldrajs/sdk'` augmentation and
9
+ writes it with the CMS types, so `product.extensions` is typed through the SDK's
10
+ `EldraProductExtensions` registry (WS-434, contract 6.1.0). It is on by default;
11
+ `--no-sdk-augmentation` leaves it out, for a project that does not depend on `@eldrajs/sdk`.
8
12
  - `eldra-theme deploy` explains a 413 whose body is not JSON instead of printing `gateway responded 413`: a proxy or CDN in front of the API may have refused the upload as too large, with the platform's own artifact limits for comparison.
9
13
  - `eldra-theme init` scaffolds a starter whose `studioOrigins` default to production Studio (`https://eldra.app`) instead of `https://localhost:4311`, so a deploy that forgets `ELDRA_STUDIO_ORIGIN` still lets production Studio connect to the preview rather than failing silently; `ELDRA_STUDIO_ORIGIN` accepts a comma-separated list.
10
14
  - `eldra-theme validate` and the plugin build fail naming `package.json: eldra.themeId` when a theme
package/README.md CHANGED
@@ -19,6 +19,12 @@ pnpm exec eldra-theme types --schemas page,hero --out generated/eldra.d.ts
19
19
  pnpm exec eldra-theme deploy
20
20
  ```
21
21
 
22
+ `eldra-theme types` writes the org's CMS schema types, including a `declare module '@eldrajs/sdk'`
23
+ block that fills the SDK's `EldraProductExtensions` registry, so `product.extensions` is typed. Pass
24
+ `--no-sdk-augmentation` in a project that does not depend on `@eldrajs/sdk`; the file then has plain
25
+ interfaces only and never names a module the project cannot resolve. `eldra-theme types --blocks`
26
+ writes only `.eldra/block-types.d.ts`, from the theme's `block.json` files, with no gateway.
27
+
22
28
  See [docs/themes.md](../../docs/themes.md) for the full theme integration guide.
23
29
 
24
30
  ## Development
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as initTheme, i as scaffoldBlock, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-FjQ-5_ne.js";
2
+ import { a as initTheme, i as scaffoldBlock, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-CC6Mp5i_.js";
3
3
  import { resolve } from "node:path";
4
4
  import { defineCommand, runMain } from "citty";
5
5
  // src/cli.ts
@@ -116,6 +116,11 @@ const main = defineCommand({
116
116
  default: false,
117
117
  description: "Write only .eldra/block-types.d.ts from blocks/*/block.json (no gateway)"
118
118
  },
119
+ "sdk-augmentation": {
120
+ type: "boolean",
121
+ default: true,
122
+ description: "Leave out the declare module '@eldrajs/sdk' block that types product extensions (for a project that does not depend on @eldrajs/sdk)"
123
+ },
119
124
  ...gatewayArgs
120
125
  },
121
126
  async run({ args }) {
@@ -139,7 +144,8 @@ const main = defineCommand({
139
144
  gatewayUrl,
140
145
  orgId,
141
146
  out: String(args.out),
142
- schemas: typeof args.schemas === "string" ? args.schemas.split(",").map((schema) => schema.trim()).filter(Boolean) : void 0
147
+ schemas: typeof args.schemas === "string" ? args.schemas.split(",").map((schema) => schema.trim()).filter(Boolean) : void 0,
148
+ sdkAugmentation: args["sdk-augmentation"] !== false
143
149
  });
144
150
  console.log(`wrote ${target}`);
145
151
  } catch (error) {
package/dist/index.d.ts CHANGED
@@ -133,6 +133,12 @@ export declare function generateTypes(opts: {
133
133
  orgId: string;
134
134
  out: string;
135
135
  schemas?: string[];
136
+ /**
137
+ * Ask for the `declare module '@eldrajs/sdk'` block that fills `EldraProductExtensions`. On by
138
+ * default, since a theme normally depends on the SDK; turn it off for a project that does not,
139
+ * which could not resolve that module.
140
+ */
141
+ sdkAugmentation?: boolean;
136
142
  fetch?: typeof globalThis.fetch;
137
143
  }): Promise<string>;
138
144
  /**
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as initTheme, c as detectCommitSha, i as scaffoldBlock, l as fieldMigrationLines, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-FjQ-5_ne.js";
1
+ import { a as initTheme, c as detectCommitSha, i as scaffoldBlock, l as fieldMigrationLines, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-CC6Mp5i_.js";
2
2
  import { scanTheme } from "@eldrajs/vite-plugin-theme/scan";
3
3
  export { DeployError, deployTheme, detectCommitSha, fieldMigrationLines, generateBlockTypesFile, generateTypes, initTheme, scaffoldBlock, scanTheme, validateTheme };
@@ -407,7 +407,8 @@ async function generateTypes(opts) {
407
407
  fetch: opts.fetch
408
408
  }).getTypeScriptDefinitions({
409
409
  schemas: opts.schemas,
410
- moduleName: "Eldra"
410
+ moduleName: "Eldra",
411
+ sdkAugmentation: opts.sdkAugmentation ?? true
411
412
  });
412
413
  const target = resolve(opts.themeDir, opts.out);
413
414
  mkdirSync(dirname(target), { recursive: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "CLI for Eldra themes: init from the starter, scaffold blocks, validate, generate types, deploy a static build to Eldra.",
5
5
  "keywords": [
6
6
  "cli",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "citty": "^0.1.6",
44
44
  "tar": "^7.4.3",
45
- "@eldrajs/theme-core": "^0.3.3",
46
- "@eldrajs/vite-plugin-theme": "^0.3.3"
45
+ "@eldrajs/theme-core": "^0.3.4",
46
+ "@eldrajs/vite-plugin-theme": "^0.3.4"
47
47
  },
48
48
  "devDependencies": {
49
49
  "execa": "^9.5.2"
@@ -1,37 +1,37 @@
1
1
  {
2
- "announcement-bar": "2b057546d7d017f6481e5c89e7af3ee67c1f03fc503ba29ef3485a8b3b72ca3e",
3
- "article": "0f1d1229dc640ef3580442855b1eb4be83bbad43e6d828b71edd218018581b7e",
4
- "article-list": "4132ded9bc945513dbdf0d6138c85a081aaeae65cb66f101e091acbd302c3274",
5
- "breadcrumbs": "637c19cb81ba8e5a979df0e5f7bf6444ce85feb618c8168ac76df91434e00aad",
6
- "cart": "7163dc4cdb18e2ea39b573e0e33c70c04202261266616671f06fd0837c141c70",
7
- "collection-grid": "2062ade27f90aac810114c3d9a4bbd5efddd5b74c869a2b891dc3589c149eda6",
8
- "collection-header": "cbcfacb1d8ab6638fb8094a8517baec3ff3911f9df744007babeee402e75715f",
9
- "contact": "0af119acf554c453d8f545f3cd7a37ed4f3afa9a2472e105978e4f48f7d51616",
10
- "cta": "0e3fc7d629f34d451b9f785d57fdd88c7853f737dab55136ec2e07b282cc4d81",
11
- "faq": "90baa9a0832632aa47cd9ce1fe29682c16e045ea9739464e67d7287c6b0b94c8",
12
- "feature-grid": "9bb14686453ba8ec7758442a6a55ffec797208ad02aed05d465ab384b42ff6c1",
13
- "footer": "cbf8e902d28cc54eed9b57c75f1de122bbdbbda9845097a5f751e4864f3b3b9e",
14
- "form": "55c897592a0048fb4465485d66c240084173479dad56e692608111c20f9d1a1d",
15
- "gallery": "aaaae7b8b72f8a54c96bdac673317ba260e946c52fc7a62dbc439aab87f1f5a3",
16
- "hero": "17309fd9ed6ca109725906c064c07d24187a7888175db2a1fb900966999a69f9",
17
- "image": "7e2eaff913b3daf5eb96013e4e1762400b0c1eb06ccfb51cdb4eaee39e54c4aa",
18
- "logo-cloud": "281e3cd1b8a4d3f3983623b22cfad7072aed6ab467a0d06eafcf3d884655a25a",
19
- "navigation": "6377021a405f0ced6ad0f4013a19e20f42b2f1ea0d2a35f0646d9584b0a75088",
20
- "newsletter": "fed26701771229ce4573d01ee79383ed482683bc904e225b30549d28f5b25697",
21
- "order-status": "260384a10709343107828059b42a3e1238083aae94b9bc812c6feaa999adf522",
22
- "pricing-table": "99890127509926177dc6a55b74a355577c8c8179a053290a3e866846e875be80",
23
- "product-carousel": "4f2d1269f8432e1e7ba39abc57f4bc2330efbf7db1cd473004731c066fc23cd3",
24
- "product-detail": "8e4cd802a3b0e9f7514edb4978b7dfff2fc1bd32d5fd0f7da9c041b1259b7222",
25
- "quote": "e173b6e75861006d6c9a7397f9cf7d11834a2116bff27029e8df58799143bdf4",
26
- "rich-text": "3239b3aa81b99b807409bbc5e1def629db64c8ee73140c7f6382d535c7a2ae48",
27
- "search": "d6501ae66f353842724b2dd90413d01ead20ab75f2c17722a9cd87527ccf6418",
28
- "split-content": "41b84b530d65d37777c3df6f55cf12a62a090edf938f784491641c5967b6d602",
29
- "stats": "e7bf6d2134a6f404d9e3cce87892c36838e9b4ed247f7b3e34882eca61412ad1",
30
- "tabs": "352eaed3dea3c54d7bcb7665feafb770a9977f0fa0029abf9e3fb83c23960936",
31
- "team": "52ca9e5827f11c68344593aa44508cb41f3322576a6aac3cb9454df2c381827a",
32
- "testimonials": "a4477a2a42c2634ea7180ba2801412580962661651baee2697703b1ca854dd45",
33
- "timeline": "c5ab8481388681dec370959c815f835130da75f37cbaa0745dbc39f1afc825b6",
34
- "trust-strip": "babe3d988c88a93a8452881a0d8ecc6d1872004c604d550471edcae52d565066",
35
- "video-embed": "4cd7b65b4ee6c7cc86b0dc5ef27e29c2e144afcdc9736bf6b2ac5b750ada4ce0",
36
- "wishlist": "6051e425cb5b40a638c08b86d452bbeed4cba590582ed7092f29697ea2fd1636"
2
+ "announcement-bar": "9045755a9e6b7d95c4e88740af2058ca909f84dd645168359c134000c5b2d413",
3
+ "article": "a545a8cd07e5212879f66fbfedae201f8df9e722167b1a0602f1550ec9478e57",
4
+ "article-list": "2e33e94c938d934951ae2887857a358fa2aed325d70f35081f4549052263fd39",
5
+ "breadcrumbs": "84056359c861caba20825c39d17d9f7f2279ecc228ff6739851e58c4fd23830e",
6
+ "cart": "6c1fb1e7ee45b806f57c4968bcbd0a05637e5234d87132ea3525b67be8cf029f",
7
+ "collection-grid": "206ef930ae19515117fdab52e09d7f3f1fb335de703175e5b00a0f17c8c8edbc",
8
+ "collection-header": "71d81a4d45ff672a42ed083c54dd13ee3a3cc1fd5b77b7410369b7d446f45521",
9
+ "contact": "665b6201afcc398ee8c631964522d3268359b929ded1fe59b240dfb240edaf84",
10
+ "cta": "34b64a3a0e151ada3fe2a4faab441cbe0358c5b8cd141468939fb04e6ee8bfd1",
11
+ "faq": "f5ac1a7383c2c936e0fe460dd71d7f08cc42262ed28a94743605de5c62ac7cfb",
12
+ "feature-grid": "7703f4200168a0ebcfbae3cc8af87204a8d657045449ac7390caa9a8d1fa37b9",
13
+ "footer": "a47eb516f5f8b1418eabd81e11aff72e76d417dd24ca67c5e6c78e0e87fd6849",
14
+ "form": "e129a99c7929a212ed3856b58f75da1ae2398db5fe70831ba25067808bf5fdda",
15
+ "gallery": "43994cf3fa2fa21404f4430fe0267cee07427eefd5d0051f5de29ad32317a709",
16
+ "hero": "37d286b9d820cb2487b0e69a59b7397c2390241deb4e17f33cc7a48ce7e8bed6",
17
+ "image": "70edb75fee2daaaccb2af32cfc84e1e97e3d60c3f46edd249a92c8e05a20ca87",
18
+ "logo-cloud": "fb7eb0e1eeb5fbe35c20b83603c4fd3e45610fbf1127e6761872a8df76e7c1c8",
19
+ "navigation": "3d79de52c5f71d3ffd2d6f6065f883ef9d7e45d1c677b818dd6610be2f2bf7e2",
20
+ "newsletter": "cd26a6073f05cd66a2e72e04e88e719e68d23aaa8a8e7654f24f3419d448308c",
21
+ "order-status": "725a17d026088d5fc240883fd5ea6dddad08496ba5fccdf2ccc22061069bc53f",
22
+ "pricing-table": "840239eee9cdca343007d48696b27dc444ec0db59455d37bb96cc596870e6b12",
23
+ "product-carousel": "ebac1c39b0c55f14171dbf82b11486c5140f77b0f39e1d0c4fedb8f07201a419",
24
+ "product-detail": "39349300273d4f042f76b813cda537fd570f5a5d24a55287edb94a7bf1039f2f",
25
+ "quote": "e3bec06185a23458a1f519f34f1d24dd711f2048928c42d6f4075b88d54bde62",
26
+ "rich-text": "537e0fd1f037b3f8c2881a0dca27ef9a9e4ab0d06e83b41d658747220e3cb702",
27
+ "search": "205254b7f86e00420a770af67132149563d85f9a70821fb69861d9580439116a",
28
+ "split-content": "b87d48e5e082354bb2d1857bc95db9d2662f7389c2430a89c0f093f888b2e813",
29
+ "stats": "f27aeb767eddc14419d856b4d9228037ed448fde3998eafc0c9101d3cfc8b349",
30
+ "tabs": "c02163f996490c26dfd4464d586be8f5626e7aece3f9347caa8a843eae58dc4b",
31
+ "team": "a34950d7c393a5e66734548d5119b2e4ee49e34ad4b20fd01578aa0c3e266e45",
32
+ "testimonials": "f391a0eb5393945bc95a5b1471f7117a44f40aa9ef7cb5fbe2d33752e0cbea23",
33
+ "timeline": "f4ce46f8fc089f28a665deb2973531998fe976621fb9bee41ede74277acc4337",
34
+ "trust-strip": "390174236553a7b48c38a3bbb3f23317883a8131010688a1b0428557217fdfa9",
35
+ "video-embed": "4d37291f2d38a29bb37d307e080ab6bad6039d7b12cb254146ed2712031515d2",
36
+ "wishlist": "208c84c289891ba70a5591ff0db680fdbe8b3fee29ab10f62f857812ca9fcfe0"
37
37
  }
@@ -239,7 +239,9 @@ true`). Each id becomes a `--eldra-color-<id>` custom property, which is the _sa
239
239
  - **`app/assets/main.css`** — `@import 'tailwindcss'` then `@import '@eldrajs/ui/tailwind.css'`,
240
240
  which brings in the `--eldra-*` variables, the Tailwind `@theme` mapping over them
241
241
  (`bg-primary`, `rounded-md`, `shadow-md`, `font-heading`, `text-body`, …) and the package's own
242
- utilities. What is left in the file is the theme's own: the section spacing scale, the container
242
+ utilities, then `@import '@eldrajs/ui/components.css'`, the package's components prebuilt (every
243
+ class `eldra:`-prefixed, below this file's utilities, so a class a block puts on a component
244
+ wins). What is left in the file is the theme's own: the section spacing scale, the container
243
245
  rules, the base layer and the rich-text typography. Edit it directly; there's no build step.
244
246
  Fonts are `--eldra-font-heading` / `--eldra-font-body` — override them here (the package names
245
247
  its two faces but never loads them).
@@ -114,9 +114,7 @@ const drawerEntry = computed(
114
114
  href="#main"
115
115
  :as="EldraRouterLink"
116
116
  variant="standalone"
117
- :classes="{
118
- root: 'bg-primary text-primary-contrast rounded-md sr-only px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50',
119
- }"
117
+ class="bg-primary text-primary-contrast sr-only rounded-md px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50"
120
118
  >
121
119
  {{ t('nav.skipToContent') }}
122
120
  </Link>
@@ -1,21 +1,19 @@
1
1
  @import 'tailwindcss';
2
- /* `@eldrajs/ui`'s Tailwind entry: its `tokens.css` (`--eldra-*` — colours,
3
- radii, spacing, type, motion, z-index), the `@theme` block mapping those
4
- onto Tailwind's own namespaces (`--color-primary`, `--radius-md`,
5
- `--font-heading`, `--shadow-md`, …), the package's custom utilities
6
- (`eldra-focus`, `control-h`, `text-body`, …) and a `@source "./"` so this
7
- build also scans the package's compiled components — without it a class
8
- only `@eldrajs/ui`'s own `dist/*.js` uses (a Button fill, an Input border)
9
- would never be emitted here.
2
+ /* `@eldrajs/ui`'s Tailwind entry: its `tokens.css` (`--eldra-*` — colours, radii, spacing,
3
+ type, motion, z-index), the `@theme` block mapping those onto Tailwind's own namespaces
4
+ (`--color-primary`, `--radius-md`, `--font-heading`, …) and the package's custom utilities
5
+ (`eldra-focus`, `control-h`, `text-body`, …), for this theme's own markup. It builds none of the
6
+ package's components: those come prebuilt in `components.css` below, every class `eldra:`-
7
+ prefixed and in the `components` layer, so a class written here or on a component wins.
10
8
 
11
- The colour variables it declares are the *defaults*; the theme's own token
12
- CSS (`virtual:eldra/tokens.css`, generated from `tokens.json` by
13
- @eldrajs/theme-core's `generateDesignTokenCss`) declares the same
14
- `--eldra-color-<role>` names on `:root` and is what Studio edits, live
15
- (`useEldraPreview` appends its own `<style>` to `<head>`, which wins over
16
- every stylesheet). Keep `tokens.json`'s colour ids and the package's role
17
- names identical: that name match is the whole wiring. */
9
+ The colour variables it declares are the *defaults*; the theme's own token CSS
10
+ (`virtual:eldra/tokens.css`, generated from `tokens.json` by @eldrajs/theme-core's
11
+ `generateDesignTokenCss`) declares the same `--eldra-color-<role>` names on `:root` and is what
12
+ Studio edits, live (`useEldraPreview` appends its own `<style>` to `<head>`, which wins over
13
+ every stylesheet). Keep `tokens.json`'s colour ids and the package's role names identical:
14
+ that name match is the whole wiring. */
18
15
  @import '@eldrajs/ui/tailwind.css';
16
+ @import '@eldrajs/ui/components.css';
19
17
 
20
18
  /* Nuxt's Vite root is `app/`, and Tailwind's automatic source detection starts at that root, so
21
19
  `blocks/` (a sibling of `app/`) is never scanned in the site build: every class only a block
@@ -34,7 +34,7 @@
34
34
  * default `'none'`) — the two presets the design spec's frame radius actually has.
35
35
  * - **`fill`** is for a background image that has to cover its positioned ancestor (the hero
36
36
  * `image-background` variant): it sets `ratio="auto"` and adds `absolute inset-0 h-full w-full`
37
- * to `classes.root` and `h-full w-full` to `classes.frame`, so the frame's own height tracks its
37
+ * to the root and `h-full w-full` to `classes.frame`, so the frame's own height tracks its
38
38
  * *positioned ancestor* (via the `inset-0`/`h-full` chain) instead of trying to derive one from
39
39
  * `media`, which this wrapper never has `width`/`height` for. `media`'s own `object-cover`
40
40
  * (`Image`'s default) does the rest.
@@ -53,9 +53,9 @@
53
53
  * the media, so the browser's replaced-element sizing algorithm scales the image down to fit
54
54
  * inside both caps at once, the same thing the original bare `<img class="max-h-[85vh] w-auto
55
55
  * object-contain">` did by being the frame itself).
56
- * - **`classes`** is `Image`'s own `classes` prop, passed straight through and merged with
57
- * whatever `rounded`/`fill`/`fit` above already set (the caller's own value for a part always
58
- * wins) — the general escape hatch for a radius `rounded` has no preset for (`rounded-full`,
56
+ * - **`classes`** is `Image`'s own `classes` prop, passed straight through. `fill`/`fit`'s own
57
+ * classes and the caller's (`class` for the root, `classes` for a part) are all app utilities in
58
+ * one layer, so they are combined with `twMerge` and the caller's wins a conflict — the general escape hatch for a radius `rounded` has no preset for (`rounded-full`,
59
59
  * `rounded-md`) or a frame-level size constraint neither `fill` nor `fit` covers on their own
60
60
  * (the gallery lightbox's `max-h-[85vh]`).
61
61
  *
@@ -65,10 +65,13 @@
65
65
  * class landing on the `<img>` now use `rounded`/`fill`/`fit`/`classes` instead — see each block's
66
66
  * own diff and `docs/starter-kit.md`'s `UiImage` row.
67
67
  */
68
- import { computed } from 'vue';
69
- import { Image, cx, type ImagePart, type ImageRatio } from '@eldrajs/ui';
68
+ import { computed, normalizeClass, useAttrs } from 'vue';
69
+ import { twMerge } from 'tailwind-merge';
70
+ import { Image, type ImagePart, type ImageRatio } from '@eldrajs/ui';
70
71
  import { imageFramingAttrs, type ImageFraming } from '@eldrajs/theme-vue';
71
72
 
73
+ defineOptions({ inheritAttrs: false });
74
+
72
75
  const props = withDefaults(
73
76
  defineProps<{
74
77
  src: string;
@@ -98,8 +101,8 @@ const props = withDefaults(
98
101
  /** `Image`'s media covers its frame by default (`cover`); `contain` letterboxes instead, for a
99
102
  * full, uncropped view (a lightbox). */
100
103
  fit?: 'cover' | 'contain';
101
- /** Passed straight through to `Image`'s own `classes` prop, merged with whatever `rounded`/
102
- * `fill`/`fit` above already set — the caller's own value for a part always wins. */
104
+ /** Passed straight through to `Image`'s own `classes` prop, merged with whatever `fill`/`fit`
105
+ * above already set — the caller's own value for a part always wins. */
103
106
  classes?: Partial<Record<ImagePart, string>>;
104
107
  }>(),
105
108
  {
@@ -156,19 +159,27 @@ const CONTAIN_FRAME_CLASS = 'w-auto max-w-full';
156
159
  * height exceeds that cap. */
157
160
  const CONTAIN_MEDIA_CLASS = 'object-contain h-auto w-auto max-w-full max-h-[inherit]';
158
161
 
159
- /** `fill`/`fit` set `root`/`frame`/`media` first; the caller's own `classes` prop is merged on top
160
- * of each (via `cx`, so a real conflict resolves in the caller's favour) rather than replacing it
161
- * outright, and every other part passes through untouched. */
162
+ const attrs = useAttrs();
163
+ const forwardedAttrs = computed(() => {
164
+ const { class: _class, style: _style, ...rest } = attrs;
165
+ return rest;
166
+ });
167
+
168
+ /** `fill`'s root classes, then the caller's `class` on top (`twMerge`: the caller wins). */
169
+ const rootClass = computed(() =>
170
+ twMerge(props.fill ? FILL_ROOT_CLASS : '', normalizeClass(attrs.class))
171
+ );
172
+
173
+ /** `fill`/`fit` set `frame`/`media` first, the caller's `classes` on top; other parts pass through. */
162
174
  const mergedClasses = computed<Partial<Record<ImagePart, string>>>(() => {
163
175
  const base = props.classes ?? {};
164
176
  const result: Partial<Record<ImagePart, string>> = { ...base };
165
177
  if (props.fill) {
166
- result.root = cx(FILL_ROOT_CLASS, base.root);
167
- result.frame = cx(FILL_FRAME_CLASS, base.frame);
178
+ result.frame = twMerge(FILL_FRAME_CLASS, base.frame);
168
179
  }
169
180
  if (props.fit === 'contain') {
170
- result.frame = cx(CONTAIN_FRAME_CLASS, result.frame ?? base.frame);
171
- result.media = cx(CONTAIN_MEDIA_CLASS, base.media);
181
+ result.frame = twMerge(CONTAIN_FRAME_CLASS, result.frame ?? base.frame);
182
+ result.media = twMerge(CONTAIN_MEDIA_CLASS, base.media);
172
183
  }
173
184
  return result;
174
185
  });
@@ -217,8 +228,9 @@ const framingDataAttrs = computed(() => {
217
228
  :rounded="rounded"
218
229
  :sizes="sizes"
219
230
  :priority="priority"
231
+ v-bind="{ ...forwardedAttrs, ...framingDataAttrs }"
232
+ :class="rootClass || undefined"
220
233
  :classes="mergedClasses"
221
- :style="rootStyle"
222
- v-bind="framingDataAttrs"
234
+ :style="[rootStyle, attrs.style]"
223
235
  />
224
236
  </template>
@@ -77,7 +77,7 @@ describe('UiImage', () => {
77
77
  },
78
78
  });
79
79
  const img = wrapper.get('[data-part="media"]');
80
- expect(img.classes()).toContain('object-cover');
80
+ expect(img.classes()).toContain('eldra:object-cover');
81
81
  expect(img.attributes('style')).toContain('object-position: 25% 75%');
82
82
  expect(img.attributes('data-eldra-framing')).toBeUndefined();
83
83
  });
@@ -134,13 +134,13 @@ describe('UiImage', () => {
134
134
  it('applies no radius class by default', () => {
135
135
  const wrapper = mount(UiImage, { props: { src: '/demo/hero.svg', alt: 'Hero' } });
136
136
  const frame = wrapper.get('[data-part="frame"]');
137
- expect(frame.classes()).not.toContain('rounded-lg');
138
- expect(frame.classes()).not.toContain('rounded-xl');
137
+ expect(frame.classes()).not.toContain('eldra:rounded-lg');
138
+ expect(frame.classes()).not.toContain('eldra:rounded-xl');
139
139
  });
140
140
 
141
141
  it.each(['lg', 'xl'] as const)('forwards rounded="%s" to the frame', (rounded) => {
142
142
  const wrapper = mount(UiImage, { props: { src: '/demo/hero.svg', alt: 'Hero', rounded } });
143
- expect(wrapper.get('[data-part="frame"]').classes()).toContain(`rounded-${rounded}`);
143
+ expect(wrapper.get('[data-part="frame"]').classes()).toContain(`eldra:rounded-${rounded}`);
144
144
  });
145
145
  });
146
146
 
@@ -158,7 +158,7 @@ describe('UiImage', () => {
158
158
  const frame = wrapper.get('[data-part="frame"]');
159
159
  expect(frame.classes()).toEqual(expect.arrayContaining(['h-full', 'w-full']));
160
160
  const media = wrapper.get('[data-part="media"]');
161
- expect(media.classes()).toContain('object-cover');
161
+ expect(media.classes()).toContain('eldra:object-cover');
162
162
  });
163
163
 
164
164
  it('resolves to ratio="auto" (no forced aspect-ratio) while filling', () => {
@@ -183,11 +183,13 @@ describe('UiImage', () => {
183
183
  it('defaults to cover: the frame stays w-full, the media stays h-full w-full object-cover — unchanged', () => {
184
184
  const wrapper = mount(UiImage, { props: { src: '/demo/hero.svg', alt: 'Hero' } });
185
185
  const frame = wrapper.get('[data-part="frame"]');
186
- expect(frame.classes()).toContain('w-full');
186
+ expect(frame.classes()).toContain('eldra:w-full');
187
187
  expect(frame.classes()).not.toContain('w-auto');
188
188
  const media = wrapper.get('[data-part="media"]');
189
- expect(media.classes()).toEqual(expect.arrayContaining(['h-full', 'w-full', 'object-cover']));
190
- expect(media.classes()).not.toContain('object-contain');
189
+ expect(media.classes()).toEqual(
190
+ expect.arrayContaining(['eldra:h-full', 'eldra:w-full', 'eldra:object-cover'])
191
+ );
192
+ expect(media.classes()).not.toContain('eldra:object-contain');
191
193
  });
192
194
 
193
195
  /**
@@ -208,7 +210,6 @@ describe('UiImage', () => {
208
210
  });
209
211
  const frame = wrapper.get('[data-part="frame"]');
210
212
  expect(frame.classes()).toEqual(expect.arrayContaining(['w-auto', 'max-w-full']));
211
- expect(frame.classes()).not.toContain('w-full');
212
213
  const media = wrapper.get('[data-part="media"]');
213
214
  expect(media.classes()).toEqual(
214
215
  expect.arrayContaining([
@@ -219,9 +220,6 @@ describe('UiImage', () => {
219
220
  'max-h-[inherit]',
220
221
  ])
221
222
  );
222
- expect(media.classes()).not.toContain('object-cover');
223
- expect(media.classes()).not.toContain('h-full');
224
- expect(media.classes()).not.toContain('w-full');
225
223
  });
226
224
 
227
225
  it("composes with a caller-supplied classes.frame height cap (the lightbox's max-h-[85vh])", () => {
@@ -254,7 +252,7 @@ describe('UiImage', () => {
254
252
  });
255
253
  const frame = wrapper.get('[data-part="frame"]');
256
254
  expect(frame.classes()).toContain('max-h-[85vh]');
257
- expect(frame.classes()).toContain('rounded-lg');
255
+ expect(frame.classes()).toContain('eldra:rounded-lg');
258
256
  });
259
257
 
260
258
  it("lets the caller's own classes.frame win over fill's forced h-full w-full", () => {
@@ -282,11 +280,22 @@ describe('UiImage', () => {
282
280
  expect(wrapper.get('[data-part="media"]').classes()).toContain('object-cover');
283
281
  });
284
282
 
285
- it('passes classes.root through untouched when fill is not set', () => {
283
+ it('passes class through to the root untouched when fill is not set', () => {
286
284
  const wrapper = mount(UiImage, {
287
- props: { src: '/demo/hero.svg', alt: 'Hero', classes: { root: 'custom-root' } },
285
+ props: { src: '/demo/hero.svg', alt: 'Hero' },
286
+ attrs: { class: 'custom-root' },
288
287
  });
289
288
  expect(wrapper.get('[data-part="root"]').classes()).toContain('custom-root');
290
289
  });
290
+
291
+ it("lets the caller's own class win over fill's root classes", () => {
292
+ const wrapper = mount(UiImage, {
293
+ props: { src: '/demo/hero.svg', alt: 'Hero', fill: true },
294
+ attrs: { class: 'relative' },
295
+ });
296
+ const classes = wrapper.get('[data-part="root"]').classes();
297
+ expect(classes).toContain('relative');
298
+ expect(classes).not.toContain('absolute');
299
+ });
291
300
  });
292
301
  });
@@ -137,7 +137,7 @@ const structure = computed(() =>
137
137
  spacing="lg"
138
138
  labelled-by="not-found-title"
139
139
  data-eldra-not-found
140
- :classes="{ root: 'text-center' }"
140
+ class="text-center"
141
141
  >
142
142
  <Container width="narrow">
143
143
  <p class="text-muted text-sm font-semibold tracking-widest uppercase">
@@ -127,7 +127,7 @@ function moveFocusAfterDismiss(): void {
127
127
  * `Section` marks every ground, `none` included, with `data-section-bg`, which is what its own
128
128
  * adjacent-same-background CSS rule keys off to drop the *next* sibling's top padding — the reason
129
129
  * `breadcrumbs` deliberately avoids it (see that block's own comment). This bar needs `Section`
130
- * anyway: `background` is `primary` or `accent`, and `Section` is what marks `group/section` +
130
+ * anyway: `background` is `primary` or `accent`, and `Section` is what marks
131
131
  * `data-section` so the `Link` inside the bar inverts itself against an inverted ground.
132
132
  * Hand-rolling that marker would be re-implementing `Section`, which the starter's rules forbid
133
133
  * outright.
@@ -165,7 +165,8 @@ function moveFocusAfterDismiss(): void {
165
165
  :as="linkAs"
166
166
  variant="standalone"
167
167
  arrow
168
- :classes="{ root: 'ml-2', label: 'whitespace-nowrap' }"
168
+ class="ml-2"
169
+ :classes="{ label: 'whitespace-nowrap' }"
169
170
  >
170
171
  {{ data.linkLabel }}
171
172
  </Link>
@@ -188,7 +188,7 @@ describe('announcement-bar block', () => {
188
188
  it('the link is identifiable by its underline, not colour alone', () => {
189
189
  const wrapper = mountAnnouncement({ ...mock, linkHref: '/pages/shipping' });
190
190
  const link = wrapper.get('a');
191
- expect(link.classes()).toContain('underline');
191
+ expect(link.classes()).toContain('eldra:underline');
192
192
  });
193
193
 
194
194
  it('renders no editor placeholder (or anything else) for an empty message outside the editor', () => {
@@ -166,7 +166,7 @@ useRichTextScrollRegions(richTextRoot, (caption) => caption ?? t('article.richTe
166
166
  v-if="hasCategory"
167
167
  :href="categoryHref!"
168
168
  :as="categoryLinkAs"
169
- :classes="{ root: 'target-min text-accent inline-flex items-center font-semibold' }"
169
+ class="target-min text-accent inline-flex items-center font-semibold"
170
170
  >
171
171
  {{ categoryLabel }}
172
172
  </Link>
@@ -205,7 +205,7 @@ useRichTextScrollRegions(richTextRoot, (caption) => caption ?? t('article.richTe
205
205
  v-if="hasAuthorLink"
206
206
  :href="authorLinkHref!"
207
207
  :as="authorLinkAs"
208
- :classes="{ root: 'font-semibold' }"
208
+ class="font-semibold"
209
209
  >{{ authorName }}</Link
210
210
  ><template v-else>{{ authorName }}</template
211
211
  >{{ bylineRoleSuffix }}{{ bylineParts.after }}
@@ -233,10 +233,9 @@ useRichTextScrollRegions(richTextRoot, (caption) => caption ?? t('article.richTe
233
233
  <EditorPlaceholder
234
234
  v-else-if="showCoverHint"
235
235
  inline
236
- class="@tablet:mt-12 mt-8"
236
+ class="@tablet:mt-12 @tablet:aspect-[16/9] mt-8 aspect-[4/3] w-full"
237
237
  :label="t('article.coverHintLabel')"
238
238
  :help="t('article.coverHintHelp')"
239
- :classes="{ root: 'aspect-[4/3] w-full @tablet:aspect-[16/9]' }"
240
239
  />
241
240
  </Container>
242
241
 
@@ -212,16 +212,24 @@ const GRID_ROOT_CLASS =
212
212
  const LIST_ROOT_CLASS = 'flex flex-col border-t border-border';
213
213
  const listContainerClass = computed(() => (isList.value ? LIST_ROOT_CLASS : GRID_ROOT_CLASS));
214
214
 
215
+ const FEATURED_CARD_CLASS =
216
+ 'grid gap-6 @tablet:grid-cols-[7fr_5fr] @tablet:items-center @tablet:gap-8 @content:gap-12';
215
217
  const FEATURED_CARD_CLASSES: Partial<Record<ContentCardPart, string>> = {
216
- root: 'grid gap-6 @tablet:grid-cols-[7fr_5fr] @tablet:items-center @tablet:gap-8 @content:gap-12',
217
218
  title: '@content:text-[2rem] @content:leading-[1.15]',
218
219
  body: '@content:gap-4',
219
220
  };
221
+ const LIST_CARD_CLASS =
222
+ 'grid grid-cols-[6.5rem_1fr] items-start gap-4 @tablet:grid-cols-[15rem_1fr] @tablet:items-center @tablet:gap-8';
220
223
  const LIST_CARD_CLASSES: Partial<Record<ContentCardPart, string>> = {
221
- root: 'grid grid-cols-[6.5rem_1fr] items-start gap-4 @tablet:grid-cols-[15rem_1fr] @tablet:items-center @tablet:gap-8',
222
224
  excerpt: '@max-tablet:hidden',
223
225
  };
224
226
 
227
+ function cardClass(card: CardView): string | undefined {
228
+ if (card.featured) return FEATURED_CARD_CLASS;
229
+ if (isList.value) return LIST_CARD_CLASS;
230
+ return undefined;
231
+ }
232
+
225
233
  function cardClasses(card: CardView): Partial<Record<ContentCardPart, string>> | undefined {
226
234
  if (card.featured) return FEATURED_CARD_CLASSES;
227
235
  if (isList.value) return LIST_CARD_CLASSES;
@@ -261,7 +269,7 @@ function itemWrapperClass(card: CardView): string {
261
269
  :as="viewAllLinkAs"
262
270
  variant="standalone"
263
271
  arrow
264
- :classes="{ root: 'text-control' }"
272
+ class="text-control"
265
273
  >
266
274
  {{ viewAllLabel }}
267
275
  </Link>
@@ -275,12 +283,12 @@ function itemWrapperClass(card: CardView): string {
275
283
  :as="filter.linkAs"
276
284
  :underline="false"
277
285
  :aria-current="filter.active ? 'true' : undefined"
278
- :classes="{
279
- root: filter.active
280
- ? 'inline-flex min-h-10 items-center rounded-full border border-primary bg-primary px-4 text-control font-semibold text-primary-contrast'
281
- : 'inline-flex min-h-10 items-center rounded-full border border-border-strong px-4 text-control font-medium text-text hover:border-text',
282
- label: 'inline-flex items-center gap-1',
283
- }"
286
+ :class="
287
+ filter.active
288
+ ? 'border-primary bg-primary text-control text-primary-contrast inline-flex min-h-10 items-center rounded-full border px-4 font-semibold'
289
+ : 'border-border-strong text-control text-text hover:border-text inline-flex min-h-10 items-center rounded-full border px-4 font-medium'
290
+ "
291
+ :classes="{ label: 'inline-flex items-center gap-1' }"
284
292
  >
285
293
  <EldraIcon v-if="filter.active" name="check" size="sm" />
286
294
  {{ filter.label }}
@@ -303,6 +311,7 @@ function itemWrapperClass(card: CardView): string {
303
311
  :meta="card.readingTime"
304
312
  :excerpt="card.dek"
305
313
  :heading-level="3"
314
+ :class="cardClass(card)"
306
315
  :classes="cardClasses(card)"
307
316
  />
308
317
  </li>
@@ -258,7 +258,7 @@ watchEffect(() => {
258
258
 
259
259
  <template>
260
260
  <div v-if="hasTrail" class="bg-background text-text @container">
261
- <Container :width="containerWidth" :classes="{ root: 'py-3' }">
261
+ <Container :width="containerWidth" class="py-3">
262
262
  <div ref="breadcrumbRoot" class="contents">
263
263
  <Breadcrumb
264
264
  :items="items"