@eldrajs/theme-cli 0.2.3 → 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 +9 -4
- package/dist/index.d.ts +6 -12
- package/dist/index.js +1 -1
- package/dist/{validate-DprFpjV7.js → validate-CC6Mp5i_.js} +11 -19
- 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/app/storefront/gateway.ts +0 -3
- package/template/app/storefront/structuredData.ts +2 -2
- package/template/app/storefront/types.ts +0 -5
- package/template/app/utils/seoInput.ts +0 -1
- package/template/blocks/announcement-bar/Block.vue +3 -2
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +3 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +18 -9
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +1 -1
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
- package/template/blocks/breadcrumbs/preview.png +0 -0
- 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/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +11 -14
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +12 -14
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +5 -5
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +1 -1
- package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +16 -18
- package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +3 -13
- package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +1 -1
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +14 -11
- package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/Block.vue +1 -1
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +8 -11
- package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +4 -4
- package/template/blocks/image/__tests__/Block.spec.ts +5 -6
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +16 -26
- package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +8 -9
- package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +6 -6
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
- package/template/blocks/product-carousel/preview.png +0 -0
- 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/product-detail/preview.png +0 -0
- package/template/blocks/quote/Block.vue +1 -1
- package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +2 -2
- package/template/blocks/search/PopularChips.vue +1 -1
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +2 -3
- package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +4 -5
- package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +10 -9
- package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +1 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +3 -3
- package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +1 -1
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/nuxt.config.ts +5 -4
- package/template/package.json +2 -1
- 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 +51 -1
- package/template/test/seoInput.spec.ts +5 -4
- package/template/test/storefront/structuredData.spec.ts +3 -6
- package/template/test/structuredData.generate.spec.ts +1 -1
- package/template/test/support/mockGateway.ts +8 -3
- 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,8 +1,8 @@
|
|
|
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
|
|
6
6
|
const gatewayArgs = {
|
|
7
7
|
"gateway-url": {
|
|
8
8
|
type: "string",
|
|
@@ -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) {
|
|
@@ -199,5 +205,4 @@ const main = defineCommand({
|
|
|
199
205
|
}
|
|
200
206
|
});
|
|
201
207
|
await runMain(main);
|
|
202
|
-
//#endregion
|
|
203
208
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DeclaredThemeCodePage } from "@eldrajs/vite-plugin-theme";
|
|
2
2
|
import { scanTheme } from "@eldrajs/vite-plugin-theme/scan";
|
|
3
|
-
//#region src/deployReport.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* What a deploy did to existing content, in the words an author needs.
|
|
6
5
|
*
|
|
@@ -78,8 +77,6 @@ interface FieldMigrationReport {
|
|
|
78
77
|
* deploy command only forwards these to its logger.
|
|
79
78
|
*/
|
|
80
79
|
export declare function fieldMigrationLines(report: FieldMigrationReport | undefined | null): string[];
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/commands/deploy.d.ts
|
|
83
80
|
export declare class DeployError extends Error {
|
|
84
81
|
readonly code: string | null;
|
|
85
82
|
constructor(message: string, code?: string | null);
|
|
@@ -119,11 +116,7 @@ export declare function detectCommitSha(env: {
|
|
|
119
116
|
BITBUCKET_COMMIT?: string;
|
|
120
117
|
}): string | null;
|
|
121
118
|
export declare function deployTheme(opts: DeployOptions): Promise<DeployResult>;
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/commands/init.d.ts
|
|
124
119
|
export declare function initTheme(targetDir: string): void;
|
|
125
|
-
//#endregion
|
|
126
|
-
//#region src/commands/scaffold.d.ts
|
|
127
120
|
interface ScaffoldBlockOptions {
|
|
128
121
|
themeDir: string;
|
|
129
122
|
apiId: string;
|
|
@@ -134,14 +127,18 @@ interface ScaffoldBlockOptions {
|
|
|
134
127
|
export declare function scaffoldBlock(opts: ScaffoldBlockOptions): {
|
|
135
128
|
created: string[];
|
|
136
129
|
};
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/commands/types.d.ts
|
|
139
130
|
export declare function generateTypes(opts: {
|
|
140
131
|
themeDir: string;
|
|
141
132
|
gatewayUrl: string;
|
|
142
133
|
orgId: string;
|
|
143
134
|
out: string;
|
|
144
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;
|
|
145
142
|
fetch?: typeof globalThis.fetch;
|
|
146
143
|
}): Promise<string>;
|
|
147
144
|
/**
|
|
@@ -154,8 +151,6 @@ export declare function generateTypes(opts: {
|
|
|
154
151
|
export declare function generateBlockTypesFile(opts: {
|
|
155
152
|
themeDir: string;
|
|
156
153
|
}): string;
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/commands/validate.d.ts
|
|
159
154
|
interface ValidateOptions {
|
|
160
155
|
themeDir: string;
|
|
161
156
|
remote: boolean;
|
|
@@ -170,5 +165,4 @@ interface ValidateResult {
|
|
|
170
165
|
blockCount: number;
|
|
171
166
|
}
|
|
172
167
|
export declare function validateTheme(opts: ValidateOptions): Promise<ValidateResult>;
|
|
173
|
-
//#endregion
|
|
174
168
|
export { type ConvertedFieldMigration, type DeployOptions, type DeployResult, type DeploySyncResult, type DroppedLinkRows, type FieldMigrationReport, type RetiredFieldMigration, type ScaffoldBlockOptions, type ValidateOptions, type ValidateResult, scanTheme };
|
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 };
|
|
@@ -7,7 +7,7 @@ import * as tar from "tar";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
import { generateBlockTypes } from "@eldrajs/vite-plugin-theme";
|
|
9
9
|
import { readPreviousManifest, scanTheme } from "@eldrajs/vite-plugin-theme/scan";
|
|
10
|
-
|
|
10
|
+
// src/deployReport.ts
|
|
11
11
|
/** The drop reasons this version can say in words. Anything else prints as the
|
|
12
12
|
* code the gateway sent, so a reason added later is still reported. */
|
|
13
13
|
const DROP_REASONS = { "kind-not-offered": "the field does not offer that kind" };
|
|
@@ -88,8 +88,7 @@ function nameOf(value) {
|
|
|
88
88
|
function asArray(value) {
|
|
89
89
|
return Array.isArray(value) ? value : [];
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
//#region src/urls.ts
|
|
91
|
+
// src/urls.ts
|
|
93
92
|
/**
|
|
94
93
|
* Strips every trailing `/` from a URL (`https://x///` → `https://x`). A
|
|
95
94
|
* regex equivalent (`/\/+$/`) backtracks polynomially on a long run of
|
|
@@ -105,8 +104,7 @@ function stripTrailingSlashes(value) {
|
|
|
105
104
|
while (end > 0 && value.charCodeAt(end - 1) === 47) end--;
|
|
106
105
|
return value.slice(0, end);
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
//#region src/commands/deploy.ts
|
|
107
|
+
// src/commands/deploy.ts
|
|
110
108
|
const MAX_FILES = 2e4;
|
|
111
109
|
const MAX_FILE_BYTES = 26214400;
|
|
112
110
|
const MAX_DESIGN_TOKEN_MAPPING_BYTES = 16384;
|
|
@@ -286,8 +284,7 @@ async function toDeployError(res) {
|
|
|
286
284
|
if (res.status === 413 && bodyUnparseable) return new DeployError("deploy: gateway responded 413 (payload too large) with no error body — a proxy/CDN in front of it may have a smaller limit than the app's own (≤ 20,000 files, ≤ 25 MiB/file, ≤ 500 MiB unpacked, ≤ 200 MiB compressed), or the request exceeds one of those; check the artifact size, and if it is within them ask infra about the proxy limit");
|
|
287
285
|
return new DeployError(`deploy: ${messages[detail ?? ""] ?? `gateway responded ${res.status}${detail ? ` (${detail})` : ""}`}`, detail);
|
|
288
286
|
}
|
|
289
|
-
|
|
290
|
-
//#region src/templateExclude.mjs
|
|
287
|
+
// src/templateExclude.mjs
|
|
291
288
|
/** A directory with this name, at any depth, is never copied. */
|
|
292
289
|
const EXCLUDE_DIR_NAMES = [
|
|
293
290
|
"node_modules",
|
|
@@ -321,8 +318,7 @@ function shouldCopyTemplatePath(path) {
|
|
|
321
318
|
if (parts.some((part) => EXCLUDE_DIR_NAMES.includes(part))) return false;
|
|
322
319
|
return !parts.some((part, index) => EXCLUDE_NESTED_DIRS.some((nested) => part === nested.parent && parts[index + 1] === nested.name));
|
|
323
320
|
}
|
|
324
|
-
|
|
325
|
-
//#region src/commands/init.ts
|
|
321
|
+
// src/commands/init.ts
|
|
326
322
|
function initTheme(targetDir) {
|
|
327
323
|
if (existsSync(targetDir) && readdirSync(targetDir).length > 0) throw new Error(`init: target directory ${targetDir} is not empty`);
|
|
328
324
|
const source = templateSource();
|
|
@@ -350,8 +346,7 @@ function templateSource() {
|
|
|
350
346
|
if (source === void 0) throw new Error("starter template not found (package built without template/)");
|
|
351
347
|
return source;
|
|
352
348
|
}
|
|
353
|
-
|
|
354
|
-
//#region src/commands/scaffold.ts
|
|
349
|
+
// src/commands/scaffold.ts
|
|
355
350
|
const API_ID_RE = /^[a-z][a-z0-9-]{1,48}$/;
|
|
356
351
|
function scaffoldBlock(opts) {
|
|
357
352
|
if (!API_ID_RE.test(opts.apiId)) throw new Error(`scaffoldBlock: apiId "${opts.apiId}" must match ${API_ID_RE.source}`);
|
|
@@ -404,8 +399,7 @@ function scaffoldBlock(opts) {
|
|
|
404
399
|
function titleCase(apiId) {
|
|
405
400
|
return apiId.split("-").map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join(" ");
|
|
406
401
|
}
|
|
407
|
-
|
|
408
|
-
//#region src/commands/types.ts
|
|
402
|
+
// src/commands/types.ts
|
|
409
403
|
async function generateTypes(opts) {
|
|
410
404
|
const definitions = await createEldraClient({
|
|
411
405
|
gatewayUrl: opts.gatewayUrl,
|
|
@@ -413,7 +407,8 @@ async function generateTypes(opts) {
|
|
|
413
407
|
fetch: opts.fetch
|
|
414
408
|
}).getTypeScriptDefinitions({
|
|
415
409
|
schemas: opts.schemas,
|
|
416
|
-
moduleName: "Eldra"
|
|
410
|
+
moduleName: "Eldra",
|
|
411
|
+
sdkAugmentation: opts.sdkAugmentation ?? true
|
|
417
412
|
});
|
|
418
413
|
const target = resolve(opts.themeDir, opts.out);
|
|
419
414
|
mkdirSync(dirname(target), { recursive: true });
|
|
@@ -436,8 +431,7 @@ function generateBlockTypesFile(opts) {
|
|
|
436
431
|
writeFileSync(target, content);
|
|
437
432
|
return target;
|
|
438
433
|
}
|
|
439
|
-
|
|
440
|
-
//#region src/knownFieldTypes.ts
|
|
434
|
+
// src/knownFieldTypes.ts
|
|
441
435
|
const KNOWN_FIELD_TYPES = [
|
|
442
436
|
"bool",
|
|
443
437
|
"color",
|
|
@@ -463,8 +457,7 @@ const KNOWN_FIELD_TYPES = [
|
|
|
463
457
|
"text",
|
|
464
458
|
"uuid"
|
|
465
459
|
];
|
|
466
|
-
|
|
467
|
-
//#region src/commands/validate.ts
|
|
460
|
+
// src/commands/validate.ts
|
|
468
461
|
const DEFAULT_CAPABLE_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
469
462
|
"string",
|
|
470
463
|
"text",
|
|
@@ -531,5 +524,4 @@ function validateFields(apiId, fields, validTypes, errors, path) {
|
|
|
531
524
|
if (typeof nested.item === "object" && nested.item !== null) validateFields(apiId, [nested.item], validTypes, errors, `${fieldPath}.metadata.item`);
|
|
532
525
|
});
|
|
533
526
|
}
|
|
534
|
-
//#endregion
|
|
535
527
|
export { initTheme as a, detectCommitSha as c, scaffoldBlock as i, fieldMigrationLines as l, generateBlockTypesFile as n, DeployError as o, generateTypes as r, deployTheme as s, validateTheme as t };
|
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">
|
|
@@ -239,8 +239,6 @@ interface RawProductDetails {
|
|
|
239
239
|
* knows the response carries it rather than inferring the catalogue only ever assigns one.
|
|
240
240
|
*/
|
|
241
241
|
categoryIds?: string[] | null;
|
|
242
|
-
/** Per-product brand, for `Product.brand` in the structured data. */
|
|
243
|
-
brand?: string | null;
|
|
244
242
|
description?: Record<string, unknown>;
|
|
245
243
|
mediaLinks?: RawMediaItem[] | null;
|
|
246
244
|
options?: RawProductOption[] | null;
|
|
@@ -602,7 +600,6 @@ function mapProductDetails(
|
|
|
602
600
|
? (stock?.get(countableVariant.id)?.availableQuantity ?? null)
|
|
603
601
|
: null,
|
|
604
602
|
stock: variantStock(firstAvailable, stock),
|
|
605
|
-
brand: raw.brand?.trim() || null,
|
|
606
603
|
// Each variant's own price and stock state, for the page's structured data: the same
|
|
607
604
|
// `variantStock` rule the buy box's line uses, so the markup and the page cannot disagree.
|
|
608
605
|
variants: variants.map((variant) => ({
|
|
@@ -159,8 +159,8 @@ export function pageStructuredData(parts: PageLdParts): StructuredDataEntry[] {
|
|
|
159
159
|
name: product.title,
|
|
160
160
|
description: ldPlainText(product.description),
|
|
161
161
|
images: product.images.map((image) => image.src),
|
|
162
|
-
//
|
|
163
|
-
brand:
|
|
162
|
+
// Products carry no brand of their own: they are sold under the shop's name.
|
|
163
|
+
brand: parts.profile.name,
|
|
164
164
|
variants: variantsOf(product, parts.currentUrl),
|
|
165
165
|
currency: parts.currency,
|
|
166
166
|
ratings: product.rating,
|