@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.
- package/CHANGELOG.md +4 -0
- package/README.md +6 -0
- package/dist/cli.js +8 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/{validate-FjQ-5_ne.js → validate-CC6Mp5i_.js} +2 -1
- package/package.json +3 -3
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +3 -1
- package/template/app/app.vue +1 -3
- package/template/app/assets/main.css +13 -15
- package/template/app/components/ui/UiImage.vue +29 -17
- package/template/app/components/ui/__tests__/UiImage.spec.ts +24 -15
- package/template/app/pages/[...slug].vue +1 -1
- package/template/blocks/announcement-bar/Block.vue +3 -2
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
- package/template/blocks/article/Block.vue +3 -4
- package/template/blocks/article-list/Block.vue +18 -9
- package/template/blocks/breadcrumbs/Block.vue +1 -1
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
- package/template/blocks/cart/Block.vue +1 -1
- package/template/blocks/cart/parts/CartLines.vue +3 -2
- package/template/blocks/cart/parts/ShippingBar.vue +1 -1
- package/template/blocks/cart/parts/Summary.vue +5 -9
- package/template/blocks/collection-grid/Block.vue +11 -14
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +12 -14
- package/template/blocks/collection-header/Block.vue +5 -5
- package/template/blocks/contact/Block.vue +1 -1
- package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
- package/template/blocks/cta/Block.vue +16 -18
- package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
- package/template/blocks/faq/Block.vue +3 -13
- package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
- package/template/blocks/feature-grid/Block.vue +1 -1
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
- package/template/blocks/footer/Block.vue +14 -11
- package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
- package/template/blocks/form/Block.vue +1 -1
- package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
- package/template/blocks/hero/Block.vue +8 -11
- package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
- package/template/blocks/image/Block.vue +4 -4
- package/template/blocks/image/__tests__/Block.spec.ts +5 -6
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
- package/template/blocks/navigation/Block.vue +16 -26
- package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
- package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
- package/template/blocks/order-status/Block.vue +8 -9
- package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
- package/template/blocks/product-carousel/Block.vue +6 -6
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
- package/template/blocks/product-detail/Block.vue +8 -8
- package/template/blocks/product-detail/__tests__/Block.spec.ts +1 -1
- package/template/blocks/product-detail/parts/Gallery.vue +1 -1
- package/template/blocks/quote/Block.vue +1 -1
- package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
- package/template/blocks/search/Block.vue +2 -2
- package/template/blocks/search/PopularChips.vue +1 -1
- package/template/blocks/split-content/Block.vue +2 -3
- package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
- package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
- package/template/blocks/tabs/Block.vue +4 -5
- package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
- package/template/blocks/testimonials/Block.vue +10 -9
- package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
- package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
- package/template/blocks/trust-strip/Block.vue +1 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
- package/template/blocks/video-embed/Block.vue +3 -3
- package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
- package/template/blocks/wishlist/Block.vue +1 -1
- package/template/nuxt.config.ts +5 -4
- package/template/package.json +1 -0
- package/template/stories/pages/article.stories.ts +2 -3
- package/template/stories/pages/cart.stories.ts +2 -3
- package/template/stories/pages/category.stories.ts +2 -3
- package/template/stories/pages/collection.stories.ts +2 -3
- package/template/stories/pages/home.stories.ts +2 -3
- package/template/stories/pages/product.stories.ts +3 -4
- package/template/stories/pages/products.stories.ts +2 -3
- package/template/stories/pages/search.stories.ts +2 -3
- package/template/stories/pages/wishlist.stories.ts +2 -3
- package/template/test/carouselKeyboard.spec.ts +2 -2
- package/template/test/carouselRing.browser.spec.ts +2 -2
- package/template/test/carouselSlideWidth.browser.spec.ts +9 -9
- package/template/test/eldraIcon.spec.ts +1 -1
- package/template/test/mainCss.spec.ts +7 -0
- package/template/test/pages/article.spec.ts +5 -5
- package/template/test/pages/collection.spec.ts +5 -5
- package/template/test/pages/hydration.spec.ts +10 -10
- package/template/test/prerenderRefresh.browser.spec.ts +1 -1
- 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-
|
|
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-
|
|
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.
|
|
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.
|
|
46
|
-
"@eldrajs/vite-plugin-theme": "^0.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": "
|
|
3
|
-
"article": "
|
|
4
|
-
"article-list": "
|
|
5
|
-
"breadcrumbs": "
|
|
6
|
-
"cart": "
|
|
7
|
-
"collection-grid": "
|
|
8
|
-
"collection-header": "
|
|
9
|
-
"contact": "
|
|
10
|
-
"cta": "
|
|
11
|
-
"faq": "
|
|
12
|
-
"feature-grid": "
|
|
13
|
-
"footer": "
|
|
14
|
-
"form": "
|
|
15
|
-
"gallery": "
|
|
16
|
-
"hero": "
|
|
17
|
-
"image": "
|
|
18
|
-
"logo-cloud": "
|
|
19
|
-
"navigation": "
|
|
20
|
-
"newsletter": "
|
|
21
|
-
"order-status": "
|
|
22
|
-
"pricing-table": "
|
|
23
|
-
"product-carousel": "
|
|
24
|
-
"product-detail": "
|
|
25
|
-
"quote": "
|
|
26
|
-
"rich-text": "
|
|
27
|
-
"search": "
|
|
28
|
-
"split-content": "
|
|
29
|
-
"stats": "
|
|
30
|
-
"tabs": "
|
|
31
|
-
"team": "
|
|
32
|
-
"testimonials": "
|
|
33
|
-
"timeline": "
|
|
34
|
-
"trust-strip": "
|
|
35
|
-
"video-embed": "
|
|
36
|
-
"wishlist": "
|
|
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
|
}
|
package/template/README.md
CHANGED
|
@@ -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
|
|
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).
|
package/template/app/app.vue
CHANGED
|
@@ -114,9 +114,7 @@ const drawerEntry = computed(
|
|
|
114
114
|
href="#main"
|
|
115
115
|
:as="EldraRouterLink"
|
|
116
116
|
variant="standalone"
|
|
117
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
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
|
|
57
|
-
*
|
|
58
|
-
* wins
|
|
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 {
|
|
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 `
|
|
102
|
-
*
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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.
|
|
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 =
|
|
171
|
-
result.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(
|
|
190
|
-
|
|
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
|
|
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'
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
:
|
|
279
|
-
|
|
280
|
-
? 'inline-flex min-h-10 items-center rounded-full border
|
|
281
|
-
: 'inline-flex min-h-10 items-center rounded-full border
|
|
282
|
-
|
|
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"
|
|
261
|
+
<Container :width="containerWidth" class="py-3">
|
|
262
262
|
<div ref="breadcrumbRoot" class="contents">
|
|
263
263
|
<Breadcrumb
|
|
264
264
|
:items="items"
|