@homepages/concrete 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +174 -0
- package/codemods/manifest.json +9 -0
- package/dist/artifact/playground/client/assets/index-BSA1yutg.css +1 -0
- package/dist/artifact/playground/client/assets/index-JloQyj8h.js +1101 -0
- package/dist/artifact/playground/client/index.html +13 -0
- package/dist/artifact/playground/client/island-canvas-host.mjs +1 -0
- package/dist/artifact/playground/host.mjs +127 -0
- package/dist/asset-modules.d.ts +99 -0
- package/dist/base.css +220 -0
- package/dist/browser/site-config.d.ts +18 -0
- package/dist/browser/site-config.js +56 -0
- package/dist/browser/submit-lead.d.ts +98 -0
- package/dist/browser/submit-lead.js +188 -0
- package/dist/browser.d.ts +3 -0
- package/dist/browser.js +4 -0
- package/dist/cli/build/artifact.js +225 -0
- package/dist/cli/build/captures.js +67 -0
- package/dist/cli/build/esbuild.js +127 -0
- package/dist/cli/build/fixtures.js +96 -0
- package/dist/cli/build/icons.js +76 -0
- package/dist/cli/build/index.js +38 -0
- package/dist/cli/build/playground.js +31 -0
- package/dist/cli/build/sections.js +236 -0
- package/dist/cli/build/source.js +62 -0
- package/dist/cli/build/static.js +156 -0
- package/dist/cli/capture/bundle.js +37 -0
- package/dist/cli/capture/capture-browser.js +51 -0
- package/dist/cli/capture/capture.js +121 -0
- package/dist/cli/check/analyze.js +95 -0
- package/dist/cli/check/index.js +19 -0
- package/dist/cli/check/load-workspace.js +119 -0
- package/dist/cli/check/messages.js +16 -0
- package/dist/cli/check/render/class-conflicts.js +39 -0
- package/dist/cli/check/render/html.js +86 -0
- package/dist/cli/check/render/inputs.js +53 -0
- package/dist/cli/check/render/invariants.js +58 -0
- package/dist/cli/check/render/island-frames.js +72 -0
- package/dist/cli/check/render/marker-coverage.js +102 -0
- package/dist/cli/check/render/nav.js +64 -0
- package/dist/cli/check/report.js +73 -0
- package/dist/cli/check/stages/bundles.js +129 -0
- package/dist/cli/check/stages/composition.js +67 -0
- package/dist/cli/check/stages/contracts.js +22 -0
- package/dist/cli/check/stages/dependencies.js +261 -0
- package/dist/cli/check/stages/fixtures.js +74 -0
- package/dist/cli/check/stages/lint.js +41 -0
- package/dist/cli/check/stages/logic.js +63 -0
- package/dist/cli/check/stages/render.js +144 -0
- package/dist/cli/check/stages/sections.js +83 -0
- package/dist/cli/check/stages/stylesheet.js +31 -0
- package/dist/cli/check/stages/typecheck.js +68 -0
- package/dist/cli/check/stages/workspace.js +26 -0
- package/dist/cli/commands.js +342 -0
- package/dist/cli/currency/cache.js +89 -0
- package/dist/cli/currency/decide.js +65 -0
- package/dist/cli/currency/opt-out.js +16 -0
- package/dist/cli/currency/preamble.js +183 -0
- package/dist/cli/currency/prompt.js +28 -0
- package/dist/cli/currency/refresh.js +44 -0
- package/dist/cli/currency/resolve-latest.js +185 -0
- package/dist/cli/currency/version-order.js +38 -0
- package/dist/cli/dev/crop.js +22 -0
- package/dist/cli/dev/hmr.js +26 -0
- package/dist/cli/dev/http.js +129 -0
- package/dist/cli/dev/index.js +70 -0
- package/dist/cli/dev/islands.js +390 -0
- package/dist/cli/dev/load-template.js +46 -0
- package/dist/cli/dev/request-error.js +22 -0
- package/dist/cli/dev/server.js +307 -0
- package/dist/cli/dev/tsconfig-paths.js +95 -0
- package/dist/cli/dev/vite.js +85 -0
- package/dist/cli/dev/workspace-reader.js +274 -0
- package/dist/cli/io.d.ts +14 -0
- package/dist/cli/media/cache.js +125 -0
- package/dist/cli/media/derive.js +252 -0
- package/dist/cli/media/deriver-plugin.js +71 -0
- package/dist/cli/property/index.js +180 -0
- package/dist/cli/property/library.js +137 -0
- package/dist/cli/publish/client.js +119 -0
- package/dist/cli/publish/freshness.js +66 -0
- package/dist/cli/publish/git.js +43 -0
- package/dist/cli/publish/index.js +207 -0
- package/dist/cli/publish/pack.js +78 -0
- package/dist/cli/publish/report.js +98 -0
- package/dist/cli/publish/target.js +87 -0
- package/dist/cli/publish/wire.js +29 -0
- package/dist/cli/tar.js +87 -0
- package/dist/cli/upgrade/codemod.js +56 -0
- package/dist/cli/upgrade/index.js +263 -0
- package/dist/cli/upgrade/manifest.js +72 -0
- package/dist/cli/upgrade/plan.js +68 -0
- package/dist/cli/upgrade/stage.js +71 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.js +15 -0
- package/dist/cli/workspace.js +108 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +94 -0
- package/dist/css/compile.js +77 -0
- package/dist/css/graph.js +109 -0
- package/dist/css/inline.js +132 -0
- package/dist/css/rules.js +65 -0
- package/dist/design-system/format-variants.js +127 -0
- package/dist/eslint/authoring.js +46 -0
- package/dist/eslint/correctness.js +42 -0
- package/dist/eslint/rules/editor-declaration.js +103 -0
- package/dist/eslint/rules/editor-reason.js +135 -0
- package/dist/eslint/rules/island-imports.js +20 -0
- package/dist/eslint/rules/jsx-visitor.js +20 -0
- package/dist/eslint/rules/no-client-runtime.js +88 -0
- package/dist/eslint/rules/no-editor-globals.js +60 -0
- package/dist/eslint/rules/no-hard-coded-color.js +183 -0
- package/dist/eslint/rules/no-inline-style.js +24 -0
- package/dist/eslint/rules/no-marker-literal.js +37 -0
- package/dist/eslint/rules/no-nondeterminism.js +44 -0
- package/dist/eslint/rules/no-px-breakpoint.js +44 -0
- package/dist/eslint/rules/no-raw-values.js +45 -0
- package/dist/eslint/rules/serializable-props.js +95 -0
- package/dist/eslint.d.ts +6 -0
- package/dist/eslint.js +26 -0
- package/dist/fixtures/brand.d.ts +4 -0
- package/dist/fixtures/brand.js +9 -0
- package/dist/fixtures/bundle-rule.js +67 -0
- package/dist/fixtures/canonical.d.ts +149 -0
- package/dist/fixtures/image-dimensions.js +59 -0
- package/dist/fixtures/load.js +154 -0
- package/dist/fixtures/media-plugin.js +141 -0
- package/dist/fixtures/media.js +165 -0
- package/dist/fixtures/property.js +210 -0
- package/dist/fixtures/resolve.js +202 -0
- package/dist/fixtures/rows.js +108 -0
- package/dist/fixtures/synthesize-empties.js +42 -0
- package/dist/fixtures.d.ts +213 -0
- package/dist/fixtures.js +37 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +37 -0
- package/dist/islands/client-module.js +97 -0
- package/dist/islands/marker.d.ts +43 -0
- package/dist/islands/marker.js +44 -0
- package/dist/node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/browser.js +687 -0
- package/dist/packages/external/concrete/package.js +5 -0
- package/dist/packages/internal/fact-interpolation/dist/index.js +22 -0
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +111 -0
- package/dist/packages/internal/fill-bake/dist/display.js +9 -0
- package/dist/packages/internal/fill-bake/dist/index.js +6 -0
- package/dist/packages/internal/fill-bake/dist/reconcile-cross-section.js +170 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.d.ts +32 -0
- package/dist/packages/internal/fill-vocabulary/dist/facts.js +131 -0
- package/dist/packages/internal/fill-vocabulary/dist/row-planners.js +73 -0
- package/dist/packages/internal/format-geometry/dist/capture.js +404 -0
- package/dist/packages/internal/format-geometry/dist/format.d.ts +41 -0
- package/dist/packages/internal/format-geometry/dist/geometry.js +58 -0
- package/dist/packages/internal/format-geometry/dist/index.js +4 -0
- package/dist/packages/internal/image-descriptor/dist/index.d.ts +35 -0
- package/dist/packages/internal/image-ladder/dist/crop.js +82 -0
- package/dist/packages/internal/image-ladder/dist/encode.js +23 -0
- package/dist/packages/internal/image-ladder/dist/index.js +4 -0
- package/dist/packages/internal/image-ladder/dist/policy.js +102 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.d.ts +13 -0
- package/dist/packages/internal/island-runtime/dist/capture-holds.js +45 -0
- package/dist/packages/internal/island-runtime/dist/contract.d.ts +176 -0
- package/dist/packages/internal/island-runtime/dist/contract.js +94 -0
- package/dist/packages/internal/island-runtime/dist/editor-instance-context.js +15 -0
- package/dist/packages/internal/island-runtime/dist/index.d.ts +103 -0
- package/dist/packages/internal/island-runtime/dist/index.js +163 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.d.ts +19 -0
- package/dist/packages/internal/island-runtime/dist/use-capture-ready.js +39 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.d.ts +22 -0
- package/dist/packages/internal/island-runtime/dist/use-editor.js +54 -0
- package/dist/packages/internal/island-runtime/dist/viewport-schedule.js +105 -0
- package/dist/packages/internal/property-facts/dist/derive-facts-view.js +25 -0
- package/dist/packages/internal/property-facts/dist/index.js +3 -0
- package/dist/packages/internal/property-facts/dist/property-facts-CSdkSuD7.js +181 -0
- package/dist/packages/internal/section-contracts/dist/cap-contract.js +59 -0
- package/dist/packages/internal/section-contracts/dist/catalog.js +102 -0
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/count-bounds-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/display-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +17 -0
- package/dist/packages/internal/section-contracts/dist/group-contract.js +21 -0
- package/dist/packages/internal/section-contracts/dist/index.js +26 -0
- package/dist/packages/internal/section-contracts/dist/interpolation-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +53 -0
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +70 -0
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +27 -0
- package/dist/packages/internal/section-contracts/dist/nested-slot-contract.js +12 -0
- package/dist/packages/internal/section-contracts/dist/option-source-contract.js +22 -0
- package/dist/packages/internal/section-contracts/dist/poi-curation-contract.js +18 -0
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +30 -0
- package/dist/packages/internal/section-contracts/dist/record-collection-contract.js +24 -0
- package/dist/packages/internal/section-contracts/dist/row-contract.js +37 -0
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +38 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +181 -0
- package/dist/packages/internal/section-contracts/dist/select-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/source-contract.js +48 -0
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +15 -0
- package/dist/packages/internal/section-contracts/dist/sources-contract.js +28 -0
- package/dist/packages/internal/section-contracts/dist/url-contract.js +20 -0
- package/dist/packages/internal/source-resolution/dist/index.js +222 -0
- package/dist/packages/internal/template-artifact/dist/hash.js +50 -0
- package/dist/packages/internal/template-artifact/dist/index.js +7 -0
- package/dist/packages/internal/template-artifact/dist/layout.js +165 -0
- package/dist/packages/internal/template-artifact/dist/manifest.js +73 -0
- package/dist/packages/internal/template-artifact/dist/sha256.js +138 -0
- package/dist/packages/internal/template-artifact/dist/verify.js +275 -0
- package/dist/packages/internal/template-contracts/dist/collection-editing.js +38 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.d.ts +10 -0
- package/dist/packages/internal/template-contracts/dist/content-categories.js +17 -0
- package/dist/packages/internal/template-contracts/dist/document-value.d.ts +33 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +81 -0
- package/dist/packages/internal/template-contracts/dist/facts-view.js +136 -0
- package/dist/packages/internal/template-contracts/dist/layout.js +17 -0
- package/dist/packages/internal/template-contracts/dist/markers.d.ts +40 -0
- package/dist/packages/internal/template-contracts/dist/markers.js +41 -0
- package/dist/packages/internal/template-contracts/dist/poi-row.d.ts +63 -0
- package/dist/packages/internal/template-contracts/dist/select-key.js +13 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +1112 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +1109 -0
- package/dist/packages/internal/template-contracts/dist/slot-overrides.js +11 -0
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +45 -0
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +63 -0
- package/dist/playground/host/page-state.js +12 -0
- package/dist/playground/host/paths.js +9 -0
- package/dist/playground/layout.js +24 -0
- package/dist/playground/wire.js +36 -0
- package/dist/playground-island-runtime.d.ts +3 -0
- package/dist/playground-island-runtime.js +4 -0
- package/dist/primitives/FrameShell.d.ts +29 -0
- package/dist/primitives/FrameShell.js +34 -0
- package/dist/primitives/Image.d.ts +119 -0
- package/dist/primitives/Image.js +173 -0
- package/dist/primitives/Section.d.ts +22 -0
- package/dist/primitives/Section.js +26 -0
- package/dist/primitives/Tour.d.ts +43 -0
- package/dist/primitives/Tour.js +72 -0
- package/dist/primitives/Video.d.ts +57 -0
- package/dist/primitives/Video.js +116 -0
- package/dist/primitives/embed-playback.js +50 -0
- package/dist/primitives/index.d.ts +11 -0
- package/dist/primitives/marker-attrs.js +44 -0
- package/dist/primitives/object-fit.js +11 -0
- package/dist/primitives/picture-sources.d.ts +24 -0
- package/dist/primitives/picture-sources.js +52 -0
- package/dist/primitives/probe-context.js +24 -0
- package/dist/primitives/slot-bindings.d.ts +96 -0
- package/dist/primitives/slot-bindings.js +226 -0
- package/dist/primitives/slot-document.d.ts +35 -0
- package/dist/primitives/slot-document.js +37 -0
- package/dist/primitives/slot-group.d.ts +40 -0
- package/dist/primitives/slot-group.js +45 -0
- package/dist/primitives/slot-list.d.ts +21 -0
- package/dist/primitives/slot-list.js +23 -0
- package/dist/primitives/slot-media.d.ts +71 -0
- package/dist/primitives/slot-media.js +98 -0
- package/dist/primitives/slot-scalar.d.ts +53 -0
- package/dist/primitives/slot-scalar.js +98 -0
- package/dist/primitives/slot.d.ts +26 -0
- package/dist/primitives/slot.js +28 -0
- package/dist/rules/registry.js +479 -0
- package/dist/schema/compute.d.ts +22 -0
- package/dist/schema/compute.js +30 -0
- package/dist/schema/define-schema.d.ts +27 -0
- package/dist/schema/define-schema.js +73 -0
- package/dist/schema/extract-fill-spec.js +246 -0
- package/dist/schema/extract-used-facts.js +176 -0
- package/dist/schema/fact.d.ts +65 -0
- package/dist/schema/fact.js +33 -0
- package/dist/schema/fill-builders.d.ts +387 -0
- package/dist/schema/fill-builders.js +263 -0
- package/dist/schema/fill-declaration.d.ts +76 -0
- package/dist/schema/fill-declaration.js +43 -0
- package/dist/schema/fill-spec.d.ts +18 -0
- package/dist/schema/fill-spec.js +170 -0
- package/dist/schema/format-presets.d.ts +27 -0
- package/dist/schema/format-presets.js +76 -0
- package/dist/schema/format.d.ts +22 -0
- package/dist/schema/format.js +40 -0
- package/dist/schema/formats.d.ts +6 -0
- package/dist/schema/formats.js +7 -0
- package/dist/schema/layout.d.ts +32 -0
- package/dist/schema/layout.js +30 -0
- package/dist/schema/manifest.js +300 -0
- package/dist/schema/property-facts.d.ts +83 -0
- package/dist/schema/runtime-values.d.ts +88 -0
- package/dist/schema/section-nav.d.ts +38 -0
- package/dist/schema/section-nav.js +29 -0
- package/dist/schema/section-props.d.ts +98 -0
- package/dist/schema/section-schema.d.ts +53 -0
- package/dist/schema/section-schema.js +54 -0
- package/dist/schema/slot-builders.d.ts +497 -0
- package/dist/schema/slot-builders.js +331 -0
- package/dist/schema/slot-types.d.ts +110 -0
- package/dist/schema/slot-types.js +187 -0
- package/dist/section/declare.d.ts +44 -0
- package/dist/section/declare.js +27 -0
- package/dist/section/discovery.js +76 -0
- package/dist/section/groups.js +74 -0
- package/dist/section/materialize.js +28 -0
- package/dist/section/placements.js +28 -0
- package/dist/section/section.d.ts +69 -0
- package/dist/section/section.js +101 -0
- package/dist/site-analytics.d.ts +1 -0
- package/dist/site-analytics.js +15 -0
- package/dist/site-runtime/analytics.js +97 -0
- package/dist/site-runtime/site-integrations.js +97 -0
- package/dist/styles.css +60 -0
- package/dist/template/define-template.d.ts +139 -0
- package/dist/template/define-template.js +98 -0
- package/dist/template/logic-build.js +191 -0
- package/dist/template/logic-shim.d.ts +43 -0
- package/dist/template/logic-shim.js +52 -0
- package/dist/template/logic-transform.js +92 -0
- package/dist/template/materialize.js +107 -0
- package/dist/template/reconcile.d.ts +67 -0
- package/dist/template/reconcile.js +25 -0
- package/dist/template/running-copy.js +58 -0
- package/guide/reference/cli/INDEX.md +79 -0
- package/guide/reference/cli/build.md +48 -0
- package/guide/reference/cli/check.md +49 -0
- package/guide/reference/cli/dev.md +46 -0
- package/guide/reference/cli/property-add.md +53 -0
- package/guide/reference/cli/property-list.md +46 -0
- package/guide/reference/cli/publish.md +54 -0
- package/guide/reference/cli/upgrade.md +48 -0
- package/guide/reference/rules/INDEX.md +190 -0
- package/package.json +137 -0
- package/tsconfig.base.json +16 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region ../../internal/template-contracts/dist/slot-overrides.js
|
|
2
|
+
/**
|
|
3
|
+
* Whether the user owns this slot's whole value — the one read every unbidden
|
|
4
|
+
* rewriter gates on.
|
|
5
|
+
*/
|
|
6
|
+
function isSlotOverridden(overrides, slotId) {
|
|
7
|
+
return overrides?.scalar?.[slotId] === true;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { isSlotOverridden };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ResponsiveImage } from "../../image-descriptor/dist/index.js";
|
|
2
|
+
//#region ../../internal/template-contracts/dist/tour-value.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* A 3D-tour slot's runtime value after resolution. Always a provider embed —
|
|
5
|
+
* there is no hosted branch — so it carries no `source` discriminant and no
|
|
6
|
+
* intrinsic dimensions; the section's own classes size the render box.
|
|
7
|
+
*/
|
|
8
|
+
type TourValue = {
|
|
9
|
+
/**
|
|
10
|
+
* The `intake.upload.id` of the `type='link'` row this tour was selected from —
|
|
11
|
+
* the same id `facts.tours[].id` carries. `''` is the empty value.
|
|
12
|
+
*/
|
|
13
|
+
tour_id: string;
|
|
14
|
+
/**
|
|
15
|
+
* The FINISHED EMBED SRC, not the URL as pasted: the facts row keeps the pasted
|
|
16
|
+
* form because that is the durable value, and `tourEmbedUrl` applies the rewrite
|
|
17
|
+
* once, at resolve, so `<Tour>` stays a pure read. Same split as `VideoValue.url`
|
|
18
|
+
* on its link branch.
|
|
19
|
+
*/
|
|
20
|
+
url: string;
|
|
21
|
+
/**
|
|
22
|
+
* Poster frame URL — a freshly presigned `preview_s3_key`, or `''` when the
|
|
23
|
+
* provider published no thumbnail (Biganto) or none has been downloaded yet.
|
|
24
|
+
* Unlike a video's, a tour's poster is routinely absent: `''` is an ordinary
|
|
25
|
+
* state that renders the empty rect, not a transient one.
|
|
26
|
+
*/
|
|
27
|
+
poster: string;
|
|
28
|
+
/**
|
|
29
|
+
* Responsive descriptor for the POSTER, when `image_ladder` has run over the
|
|
30
|
+
* same `preview_s3_key`. Additive and optional, exactly as `VideoValue` carries
|
|
31
|
+
* it: `<Slot.Image>` over a tour slot renders the poster AS an image
|
|
32
|
+
* (`docs/superpowers/specs/2026-08-26-tour-and-video-thumbnails-design.md` D2),
|
|
33
|
+
* and an image the kit renders deserves the `<picture>`/`srcset` treatment a
|
|
34
|
+
* photo gets. `<Tour>` itself never reads it.
|
|
35
|
+
*/
|
|
36
|
+
poster_responsive?: ResponsiveImage;
|
|
37
|
+
/** The link's `image_caption` — the provider title `link_extract` wrote — or `''`. */
|
|
38
|
+
alt: string;
|
|
39
|
+
/** Link-provider id (`matterport`, `biganto`). Drives the editor's provider badge. */
|
|
40
|
+
provider?: string;
|
|
41
|
+
};
|
|
42
|
+
/** A tour list slot's runtime value: an ordered array of `TourValue`, possibly empty. */
|
|
43
|
+
type TourCollectionValue = TourValue[];
|
|
44
|
+
//#endregion
|
|
45
|
+
export { TourCollectionValue, TourValue };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { VideoSource } from "./slot-catalog.js";
|
|
2
|
+
import { ResponsiveImage } from "../../image-descriptor/dist/index.js";
|
|
3
|
+
//#region ../../internal/template-contracts/dist/video-value.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A video slot's runtime value after resolution. Has no cropping or
|
|
6
|
+
* responsive-ladder fields: there is exactly one progressive rendition per
|
|
7
|
+
* video, and a video is selected rather than edited.
|
|
8
|
+
*/
|
|
9
|
+
type VideoValue = {
|
|
10
|
+
video_id: string;
|
|
11
|
+
/**
|
|
12
|
+
* Playable source — MEANS DIFFERENT THINGS PER BRANCH, deliberately. For a
|
|
13
|
+
* hosted upload it is the transcoded rendition; the original master is never
|
|
14
|
+
* served. For a link it is the FINISHED EMBED SRC: the facts row keeps the URL
|
|
15
|
+
* as the user pasted it, because that is the durable value, and the embed
|
|
16
|
+
* rewrite is applied once, at resolve, on the boundary between the two — so
|
|
17
|
+
* `<Video>` stays a pure read.
|
|
18
|
+
*/
|
|
19
|
+
url: string;
|
|
20
|
+
/**
|
|
21
|
+
* Poster frame URL — always present: the transcode derives one, and a link
|
|
22
|
+
* gets the provider thumbnail downloaded to the same key. `''` only while the
|
|
23
|
+
* poster is still being derived.
|
|
24
|
+
*/
|
|
25
|
+
poster: string;
|
|
26
|
+
/**
|
|
27
|
+
* Responsive descriptor for the POSTER, when `image_ladder` has run over the
|
|
28
|
+
* same `preview_s3_key` the poster is presigned from. Additive and optional:
|
|
29
|
+
* `poster` stays the single URL `<video poster>` needs, and a poster with no
|
|
30
|
+
* ladder rows simply omits this — the renderer falls back to `poster`.
|
|
31
|
+
*
|
|
32
|
+
* Exists because `<Slot.Image>` over a video slot renders the poster AS an
|
|
33
|
+
* image (`docs/superpowers/specs/2026-08-26-tour-and-video-thumbnails-design.md`
|
|
34
|
+
* D2), and an image the kit renders deserves the same `<picture>`/`srcset`
|
|
35
|
+
* treatment a photo gets. `<Video>` itself never reads it.
|
|
36
|
+
*/
|
|
37
|
+
poster_responsive?: ResponsiveImage;
|
|
38
|
+
alt: string;
|
|
39
|
+
/**
|
|
40
|
+
* Intrinsic rendition dimensions, so a bare `<video>` (rendered unframed, with
|
|
41
|
+
* no box of the section's own) can reserve its layout before metadata loads
|
|
42
|
+
* instead of collapsing then jumping. Omitted until a rendition exists, and
|
|
43
|
+
* ALWAYS omitted for a link — oEmbed publishes the player's DEFAULT box
|
|
44
|
+
* (200×113 for YouTube), not intrinsic dimensions, so carrying it would
|
|
45
|
+
* reserve a wrong box; the section's own classes size an embed.
|
|
46
|
+
*/
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Where the bytes live. Absent ⇒ `"upload"`: every value written before hosted
|
|
51
|
+
* and linked video merged is a hosted video, and `<Video>` must never flip one
|
|
52
|
+
* into an iframe. A resolver therefore OMITS this rather than setting
|
|
53
|
+
* `"upload"`, so a hosted video resolved before or after that merge is
|
|
54
|
+
* byte-identical.
|
|
55
|
+
*/
|
|
56
|
+
source?: VideoSource;
|
|
57
|
+
/** Link-provider id; link branch only. Drives the editor's provider badge. */
|
|
58
|
+
provider?: string;
|
|
59
|
+
};
|
|
60
|
+
/** A video list slot's runtime value: an ordered array of `VideoValue`, possibly empty. */
|
|
61
|
+
type VideoCollectionValue = VideoValue[];
|
|
62
|
+
//#endregion
|
|
63
|
+
export { VideoCollectionValue, VideoValue };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/playground/host/page-state.ts
|
|
2
|
+
/** Whether the fixture leaves the page on. A page its page state does not name is. */
|
|
3
|
+
function pageEnabled(fixture, pageId) {
|
|
4
|
+
return fixture.pages?.[pageId]?.enabled !== false;
|
|
5
|
+
}
|
|
6
|
+
/** The pages the fixture leaves on, in the order given. */
|
|
7
|
+
function enabledPages(fixture, pages) {
|
|
8
|
+
return pages.filter((page) => pageEnabled(fixture, page.id));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { enabledPages, pageEnabled };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/playground/host/paths.ts
|
|
2
|
+
/** The frames' two stylesheets, in cascade order, as a reader names them. */
|
|
3
|
+
const STYLESHEET_PATHS = {
|
|
4
|
+
base: "stylesheets/base.css",
|
|
5
|
+
template: "stylesheets/template.css"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { STYLESHEET_PATHS };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PLAYGROUND_CLIENT_DIR, PLAYGROUND_DIR, PLAYGROUND_FILES } from "../packages/internal/template-artifact/dist/layout.js";
|
|
2
|
+
import "../packages/internal/template-artifact/dist/index.js";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/playground/layout.ts
|
|
6
|
+
/**
|
|
7
|
+
* The built playground inside the package. Under `dist/artifact/`, never `dist/playground/`:
|
|
8
|
+
* tsdown emits the playground's own library modules there, and this directory must hold
|
|
9
|
+
* exactly what an artifact carries.
|
|
10
|
+
*/
|
|
11
|
+
function playgroundDistDir(packageRoot) {
|
|
12
|
+
return resolve(packageRoot, "dist", "artifact", PLAYGROUND_DIR);
|
|
13
|
+
}
|
|
14
|
+
/** The built client, which `concrete dev` serves. */
|
|
15
|
+
function playgroundClientOutDir(packageRoot) {
|
|
16
|
+
return resolve(playgroundDistDir(packageRoot), PLAYGROUND_CLIENT_DIR);
|
|
17
|
+
}
|
|
18
|
+
/** The built host module, which `concrete dev` loads. */
|
|
19
|
+
function playgroundHostFile(packageRoot) {
|
|
20
|
+
return resolve(playgroundDistDir(packageRoot), PLAYGROUND_FILES.host);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
export { playgroundClientOutDir, playgroundDistDir, playgroundHostFile };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/playground/wire.ts
|
|
2
|
+
function query(params) {
|
|
3
|
+
const search = new URLSearchParams();
|
|
4
|
+
for (const [key, value] of Object.entries(params)) if (value !== null && value !== void 0 && value !== "") search.set(key, value);
|
|
5
|
+
const text = search.toString();
|
|
6
|
+
return text === "" ? "" : `?${text}`;
|
|
7
|
+
}
|
|
8
|
+
/** Every route of the wire, relative to the playground's base. */
|
|
9
|
+
const ROUTES = {
|
|
10
|
+
catalog: "api/catalog",
|
|
11
|
+
render: "api/render",
|
|
12
|
+
media: (fixture) => `api/media${query({ fixture })}`,
|
|
13
|
+
/** An attachment over the fixture as authored: a PNG, a zip of a canvas's pages, or a PDF. */
|
|
14
|
+
capture: (kind, target) => `api/capture/${kind}${query({
|
|
15
|
+
fixture: target.fixture,
|
|
16
|
+
format: target.format,
|
|
17
|
+
page: target.page,
|
|
18
|
+
canvas: target.canvas
|
|
19
|
+
})}`,
|
|
20
|
+
/** A website page as it would publish, over the fixture as authored. `pagePath` is the declared path. */
|
|
21
|
+
live: (fixture, pagePath) => `fixtures/${encodeURIComponent(fixture)}/live${pagePath === "/" ? "/" : `${pagePath}/`}`,
|
|
22
|
+
/** The change channel (server-sent events), present only with `capabilities.hmr`. */
|
|
23
|
+
hmr: "__hmr"
|
|
24
|
+
};
|
|
25
|
+
/** The change events the channel carries. */
|
|
26
|
+
const HMR_EVENTS = {
|
|
27
|
+
/** A section or template module changed: re-render what is on screen. */
|
|
28
|
+
source: "source:changed",
|
|
29
|
+
/** The stylesheet recompiled: re-link it. */
|
|
30
|
+
stylesheet: "stylesheet:changed",
|
|
31
|
+
/** A fixture module changed: reload the catalog. */
|
|
32
|
+
fixtures: "fixtures:changed"
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { HMR_EVENTS, ROUTES };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DocumentFormat, ImageFormat } from "../packages/internal/format-geometry/dist/format.js";
|
|
2
|
+
import "../schema/format.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
//#region src/primitives/FrameShell.d.ts
|
|
5
|
+
type Props = {
|
|
6
|
+
format: ImageFormat | DocumentFormat;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* The frame shell — the rendered-class page root, the frame analog of the
|
|
11
|
+
* website page shell. The frame is a viewport: every host owes a frame
|
|
12
|
+
* document a window that is exactly the format's bleed box, and the static
|
|
13
|
+
* half of the contract (`.tr-frame`, from the kit's base stylesheet) fills
|
|
14
|
+
* that window, clips at the shell's own edge, and lays sections out as a
|
|
15
|
+
* rigid flex column (`flex-shrink: 0` on every direct child, so an
|
|
16
|
+
* overflowing stack overflows measurably instead of being silently
|
|
17
|
+
* compressed). The shell sets the three geometry tokens
|
|
18
|
+
* (`--frame-w`/`--frame-h`/`--frame-bleed`) — the declared geometry, for
|
|
19
|
+
* hosts and diagnostics to read — and stamps `data-format`, which the derived
|
|
20
|
+
* per-format variants (destination identity, never size) select on.
|
|
21
|
+
*
|
|
22
|
+
* Children must be the page's sections, direct — a wrapper element between
|
|
23
|
+
* shell and section would become the flex child instead of the section. The
|
|
24
|
+
* shell draws nothing: trim and bleed guides are host chrome, never markup, so
|
|
25
|
+
* rendered bytes are identical in every host.
|
|
26
|
+
*/
|
|
27
|
+
declare function FrameShell({ format, children }: Props): import("react").JSX.Element;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FrameShell };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FRAME_ROOT_CLASS, frameTokens } from "../packages/internal/format-geometry/dist/capture.js";
|
|
2
|
+
import "../packages/internal/format-geometry/dist/index.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/FrameShell.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The frame shell — the rendered-class page root, the frame analog of the
|
|
8
|
+
* website page shell. The frame is a viewport: every host owes a frame
|
|
9
|
+
* document a window that is exactly the format's bleed box, and the static
|
|
10
|
+
* half of the contract (`.tr-frame`, from the kit's base stylesheet) fills
|
|
11
|
+
* that window, clips at the shell's own edge, and lays sections out as a
|
|
12
|
+
* rigid flex column (`flex-shrink: 0` on every direct child, so an
|
|
13
|
+
* overflowing stack overflows measurably instead of being silently
|
|
14
|
+
* compressed). The shell sets the three geometry tokens
|
|
15
|
+
* (`--frame-w`/`--frame-h`/`--frame-bleed`) — the declared geometry, for
|
|
16
|
+
* hosts and diagnostics to read — and stamps `data-format`, which the derived
|
|
17
|
+
* per-format variants (destination identity, never size) select on.
|
|
18
|
+
*
|
|
19
|
+
* Children must be the page's sections, direct — a wrapper element between
|
|
20
|
+
* shell and section would become the flex child instead of the section. The
|
|
21
|
+
* shell draws nothing: trim and bleed guides are host chrome, never markup, so
|
|
22
|
+
* rendered bytes are identical in every host.
|
|
23
|
+
*/
|
|
24
|
+
function FrameShell({ format, children }) {
|
|
25
|
+
return /* @__PURE__ */ jsx("div", {
|
|
26
|
+
className: FRAME_ROOT_CLASS,
|
|
27
|
+
"data-format": format.id,
|
|
28
|
+
style: frameTokens(format),
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { FrameShell };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { AuthorImage, ImageValue } from "../schema/runtime-values.js";
|
|
2
|
+
import { ImgHTMLAttributes, ReactNode } from "react";
|
|
3
|
+
//#region src/primitives/Image.d.ts
|
|
4
|
+
/** The committed crop `<Image>` renders when `rendition` picks ONE of a value's
|
|
5
|
+
* renditions as this element's whole source, with no `<picture>` device-switching.
|
|
6
|
+
* Only `"mobile"` exists today; the union stays closed so a future rendition is a
|
|
7
|
+
* compile-time addition to this type, never a widened string. */
|
|
8
|
+
type ImageRendition = "mobile";
|
|
9
|
+
/** Every `<Image>` prop except the `value`/`alt` pair, whose typing depends on which
|
|
10
|
+
* kind of image is being rendered. Named so `Slot.Image` can derive its own passthrough
|
|
11
|
+
* from the same source rather than restating it. */
|
|
12
|
+
type ImageOptions = Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt" | "width" | "height"> & {
|
|
13
|
+
/** Render inside the kit's frame — a clipped, relatively positioned wrapper the image
|
|
14
|
+
* fills edge to edge, tinted when the value is absent. The frame has NO geometry of
|
|
15
|
+
* its own: `className` lands on it, and your classes are its whole box. `false`
|
|
16
|
+
* renders the bare `<img>` instead, so the layout box is the parent's; an absent
|
|
17
|
+
* value still renders a marked placeholder box either way. Default `true`. */
|
|
18
|
+
frame?: boolean;
|
|
19
|
+
/** Object-fit for the rendered image. Framed mode defaults to `cover`. */
|
|
20
|
+
fit?: "cover" | "contain";
|
|
21
|
+
/** Slot `sizes` (e.g. "(min-width:1024px) 1200px, 100vw"); applied to every candidate. */
|
|
22
|
+
sizes?: string;
|
|
23
|
+
/** Per-section srcset ceiling (px). Rungs wider than this are dropped (≥1 always kept). */
|
|
24
|
+
maxRungWidth?: number;
|
|
25
|
+
/** The viewport width below which a value's mobile crop is served, as a media-gated
|
|
26
|
+
* `<picture>` `<source>` — the slot's `crop.mobile.breakpoint`, which `Slot.Image`
|
|
27
|
+
* reads off the slot for you. Supplying a breakpoint is necessary for a mobile-crop
|
|
28
|
+
* `<source>`, not sufficient — see the note on the component itself. */
|
|
29
|
+
mobileBreakpoint?: number;
|
|
30
|
+
/** Commit to ONE rendition of `value` as this element's whole source, resolved before
|
|
31
|
+
* any `<picture>` logic runs — for two SEPARATE elements at different DOM positions
|
|
32
|
+
* (a mobile card and a desktop aside) rendering the same slot, each keyed to its own
|
|
33
|
+
* position rather than switching via media query. Wins over `mobileBreakpoint`,
|
|
34
|
+
* because resolving the value clears its OWN `.mobile`, so no device-switching
|
|
35
|
+
* `<source>` is ever considered once a rendition is picked. A value with no `.mobile`
|
|
36
|
+
* falls back to its desktop rendition, never a degenerate `<source>`. */
|
|
37
|
+
rendition?: ImageRendition;
|
|
38
|
+
};
|
|
39
|
+
type Props = (ImageOptions & {
|
|
40
|
+
/** The whole resolved slot value — `slots.hero_image`, a collection element, or a
|
|
41
|
+
* nested asset inside a record list row. `null` renders the empty state. */
|
|
42
|
+
value: ImageValue | null | undefined;
|
|
43
|
+
/** Overrides the value's own alt. Pass `""` for a decorative image. */
|
|
44
|
+
alt?: string;
|
|
45
|
+
}) | (ImageOptions & {
|
|
46
|
+
/** A raster image the template itself ships, from `import photo from "./x.jpg"`. */
|
|
47
|
+
value: AuthorImage;
|
|
48
|
+
/** Required here: an AuthorImage has no alt of its own. `""` for decorative. */
|
|
49
|
+
alt: string;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Image — the responsive-image primitive.
|
|
53
|
+
*
|
|
54
|
+
* Takes the whole slot value; `url`, `alt`, `mobile` and `responsive` are read off it,
|
|
55
|
+
* so a call site cannot unpack four fields and forget the fifth. A raw `<img>` is legal
|
|
56
|
+
* where you do not want this machinery — the component is worth using, not mandatory.
|
|
57
|
+
*
|
|
58
|
+
* **Two kinds of image.** `value` takes either a resolved slot value (the user's own
|
|
59
|
+
* photo) or an `AuthorImage` — a raster the template ships, from
|
|
60
|
+
* `import photo from "./assets/photo.jpg"`. Both get the same `<picture>`/`srcset`
|
|
61
|
+
* treatment; the only difference at the call site is that an `AuthorImage` REQUIRES the
|
|
62
|
+
* `alt` prop, having no alt of its own to fall back on.
|
|
63
|
+
*
|
|
64
|
+
* **The box is always yours.** Cropping is baked upstream — the platform delivers a
|
|
65
|
+
* pre-cropped asset — and the kit paints no geometry: no aspect, no size, no position.
|
|
66
|
+
* Whatever box your classes establish is the box, and `object-position` on the `<img>`
|
|
67
|
+
* is yours to set where a design wants the cover nudged.
|
|
68
|
+
*
|
|
69
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame`
|
|
70
|
+
* when the value is absent — that your `className` lands on and the `<img>` absolutely
|
|
71
|
+
* fills as an `object-cover`. Size the wrapper with your own classes (an aspect utility,
|
|
72
|
+
* a height, an absolute inset) and the image covers it. `className` is the ONLY prop that
|
|
73
|
+
* lands there: every other prop you pass — a `data-*` state flag, an `id`, an ARIA
|
|
74
|
+
* attribute — rides the inner `<img>` one element below it, `style` is applied unframed
|
|
75
|
+
* only (so framed it reaches neither), and the empty-state box spreads no passthrough at
|
|
76
|
+
* all. An element that must carry a styled class and a selector-addressed attribute
|
|
77
|
+
* together therefore takes `frame={false}`, with a wrapping element owning the box.
|
|
78
|
+
*
|
|
79
|
+
* **Unframed** (`frame={false}`): no wrapper — the `<img>` itself takes your `className`,
|
|
80
|
+
* for a logo, a slide whose parent already establishes the box, or an image that needs
|
|
81
|
+
* its own `object-position`. Pair with `fit="contain"` where the whole asset must stay
|
|
82
|
+
* visible. An absent value renders a placeholder box here too — never an `<img>` with
|
|
83
|
+
* an empty `src`.
|
|
84
|
+
*
|
|
85
|
+
* **Do not write markup or browser-side code against a particular rendered root.** Framed,
|
|
86
|
+
* the root is always the wrapper. Unframed, it is the `<img>` itself, the placeholder box
|
|
87
|
+
* for a blank value, or a generated `<picture>` — which is emitted only when the source
|
|
88
|
+
* plan produced a `<source>` to put in it.
|
|
89
|
+
*
|
|
90
|
+
* **The `<picture>` is `display: contents`.** It exists for `<source>` selection and
|
|
91
|
+
* nothing else: it generates no box of its own, so the `<img>` is always your layout
|
|
92
|
+
* child — a flex or grid cell, a percentage `max-height` against your fixed-height well —
|
|
93
|
+
* whether or not the value's ladder produced a `<picture>` to wrap it. Size the `<img>`
|
|
94
|
+
* (or, framed, the wrapper) and never the picture. Taking the picture out of layout
|
|
95
|
+
* would otherwise hand its `<source>` elements to YOUR box as items of their own, so
|
|
96
|
+
* base.css resets them (`source { display: none }`) — which is what makes "the `<img>`
|
|
97
|
+
* is your layout child" mean the `<img>` and nothing else.
|
|
98
|
+
*
|
|
99
|
+
* **The mobile crop.** A value carrying a distinct mobile crop is served it below
|
|
100
|
+
* `mobileBreakpoint` through a media-gated `<picture>` `<source>`; the number is the
|
|
101
|
+
* slot's `crop.mobile.breakpoint`, which `Slot.Image` reads off the slot and a raw
|
|
102
|
+
* `<Image>` (a list item, which has no def) is handed explicitly. No breakpoint, no
|
|
103
|
+
* device switch.
|
|
104
|
+
*
|
|
105
|
+
* **Committing to a rendition.** Two elements at different DOM positions rendering the
|
|
106
|
+
* SAME slot value (a mobile card and a desktop aside) cannot share one `<picture>` —
|
|
107
|
+
* `rendition="mobile"` on the one that must render the mobile crop resolves the value to
|
|
108
|
+
* it before anything else runs, so that element's whole output is that one rendition.
|
|
109
|
+
*
|
|
110
|
+
* **The marker is never dropped.** `{...slot.x}` arrives through the prop bag and every
|
|
111
|
+
* branch applies it — the framed wrapper, the unframed `<img>`, or the empty-state
|
|
112
|
+
* placeholder box that renders no `<img>` at all. It does NOT always ride the branch's
|
|
113
|
+
* outermost element: an unframed value that generates a `<picture>` keeps the marker on
|
|
114
|
+
* the `<img>` inside it. Find it by querying the rendered markup for the attribute
|
|
115
|
+
* rather than by reading any one element's attributes.
|
|
116
|
+
*/
|
|
117
|
+
declare function Image({ value, alt, frame, fit, sizes, maxRungWidth, mobileBreakpoint, rendition, className, loading, style, ...rest }: Props): ReactNode;
|
|
118
|
+
//#endregion
|
|
119
|
+
export { Image, ImageRendition };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { objectFitClass } from "./object-fit.js";
|
|
2
|
+
import { buildPictureSources } from "./picture-sources.js";
|
|
3
|
+
import { splitMarkerAttrs } from "./marker-attrs.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/Image.tsx
|
|
7
|
+
function resolveRendition(value, rendition) {
|
|
8
|
+
if (rendition !== "mobile" || !value?.mobile) return value;
|
|
9
|
+
const mobile = value.mobile;
|
|
10
|
+
return {
|
|
11
|
+
...value,
|
|
12
|
+
url: mobile.url,
|
|
13
|
+
responsive: mobile.responsive ?? null,
|
|
14
|
+
mobile: null
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Image — the responsive-image primitive.
|
|
19
|
+
*
|
|
20
|
+
* Takes the whole slot value; `url`, `alt`, `mobile` and `responsive` are read off it,
|
|
21
|
+
* so a call site cannot unpack four fields and forget the fifth. A raw `<img>` is legal
|
|
22
|
+
* where you do not want this machinery — the component is worth using, not mandatory.
|
|
23
|
+
*
|
|
24
|
+
* **Two kinds of image.** `value` takes either a resolved slot value (the user's own
|
|
25
|
+
* photo) or an `AuthorImage` — a raster the template ships, from
|
|
26
|
+
* `import photo from "./assets/photo.jpg"`. Both get the same `<picture>`/`srcset`
|
|
27
|
+
* treatment; the only difference at the call site is that an `AuthorImage` REQUIRES the
|
|
28
|
+
* `alt` prop, having no alt of its own to fall back on.
|
|
29
|
+
*
|
|
30
|
+
* **The box is always yours.** Cropping is baked upstream — the platform delivers a
|
|
31
|
+
* pre-cropped asset — and the kit paints no geometry: no aspect, no size, no position.
|
|
32
|
+
* Whatever box your classes establish is the box, and `object-position` on the `<img>`
|
|
33
|
+
* is yours to set where a design wants the cover nudged.
|
|
34
|
+
*
|
|
35
|
+
* **Framed** (default): a wrapper — `relative`, clipped, tinted via `.tr-image-frame`
|
|
36
|
+
* when the value is absent — that your `className` lands on and the `<img>` absolutely
|
|
37
|
+
* fills as an `object-cover`. Size the wrapper with your own classes (an aspect utility,
|
|
38
|
+
* a height, an absolute inset) and the image covers it. `className` is the ONLY prop that
|
|
39
|
+
* lands there: every other prop you pass — a `data-*` state flag, an `id`, an ARIA
|
|
40
|
+
* attribute — rides the inner `<img>` one element below it, `style` is applied unframed
|
|
41
|
+
* only (so framed it reaches neither), and the empty-state box spreads no passthrough at
|
|
42
|
+
* all. An element that must carry a styled class and a selector-addressed attribute
|
|
43
|
+
* together therefore takes `frame={false}`, with a wrapping element owning the box.
|
|
44
|
+
*
|
|
45
|
+
* **Unframed** (`frame={false}`): no wrapper — the `<img>` itself takes your `className`,
|
|
46
|
+
* for a logo, a slide whose parent already establishes the box, or an image that needs
|
|
47
|
+
* its own `object-position`. Pair with `fit="contain"` where the whole asset must stay
|
|
48
|
+
* visible. An absent value renders a placeholder box here too — never an `<img>` with
|
|
49
|
+
* an empty `src`.
|
|
50
|
+
*
|
|
51
|
+
* **Do not write markup or browser-side code against a particular rendered root.** Framed,
|
|
52
|
+
* the root is always the wrapper. Unframed, it is the `<img>` itself, the placeholder box
|
|
53
|
+
* for a blank value, or a generated `<picture>` — which is emitted only when the source
|
|
54
|
+
* plan produced a `<source>` to put in it.
|
|
55
|
+
*
|
|
56
|
+
* **The `<picture>` is `display: contents`.** It exists for `<source>` selection and
|
|
57
|
+
* nothing else: it generates no box of its own, so the `<img>` is always your layout
|
|
58
|
+
* child — a flex or grid cell, a percentage `max-height` against your fixed-height well —
|
|
59
|
+
* whether or not the value's ladder produced a `<picture>` to wrap it. Size the `<img>`
|
|
60
|
+
* (or, framed, the wrapper) and never the picture. Taking the picture out of layout
|
|
61
|
+
* would otherwise hand its `<source>` elements to YOUR box as items of their own, so
|
|
62
|
+
* base.css resets them (`source { display: none }`) — which is what makes "the `<img>`
|
|
63
|
+
* is your layout child" mean the `<img>` and nothing else.
|
|
64
|
+
*
|
|
65
|
+
* **The mobile crop.** A value carrying a distinct mobile crop is served it below
|
|
66
|
+
* `mobileBreakpoint` through a media-gated `<picture>` `<source>`; the number is the
|
|
67
|
+
* slot's `crop.mobile.breakpoint`, which `Slot.Image` reads off the slot and a raw
|
|
68
|
+
* `<Image>` (a list item, which has no def) is handed explicitly. No breakpoint, no
|
|
69
|
+
* device switch.
|
|
70
|
+
*
|
|
71
|
+
* **Committing to a rendition.** Two elements at different DOM positions rendering the
|
|
72
|
+
* SAME slot value (a mobile card and a desktop aside) cannot share one `<picture>` —
|
|
73
|
+
* `rendition="mobile"` on the one that must render the mobile crop resolves the value to
|
|
74
|
+
* it before anything else runs, so that element's whole output is that one rendition.
|
|
75
|
+
*
|
|
76
|
+
* **The marker is never dropped.** `{...slot.x}` arrives through the prop bag and every
|
|
77
|
+
* branch applies it — the framed wrapper, the unframed `<img>`, or the empty-state
|
|
78
|
+
* placeholder box that renders no `<img>` at all. It does NOT always ride the branch's
|
|
79
|
+
* outermost element: an unframed value that generates a `<picture>` keeps the marker on
|
|
80
|
+
* the `<img>` inside it. Find it by querying the rendered markup for the attribute
|
|
81
|
+
* rather than by reading any one element's attributes.
|
|
82
|
+
*/
|
|
83
|
+
function Image({ value, alt, frame, fit, sizes, maxRungWidth, mobileBreakpoint, rendition, className, loading, style, ...rest }) {
|
|
84
|
+
const { markerAttrs, rest: imgAttrs } = splitMarkerAttrs(rest);
|
|
85
|
+
const resolved = resolveRendition(value, rendition);
|
|
86
|
+
const src = resolved?.url ?? null;
|
|
87
|
+
const altText = alt ?? resolved?.alt ?? "";
|
|
88
|
+
const responsive = resolved?.responsive ?? null;
|
|
89
|
+
const responsiveMobile = resolved?.mobile?.responsive ?? null;
|
|
90
|
+
const srcMobile = resolved?.mobile?.url ?? null;
|
|
91
|
+
const plan = responsive ? buildPictureSources({
|
|
92
|
+
responsive,
|
|
93
|
+
responsiveMobile,
|
|
94
|
+
sizes,
|
|
95
|
+
maxRungWidth,
|
|
96
|
+
mobileBreakpoint
|
|
97
|
+
}) : null;
|
|
98
|
+
const hasResponsive = Boolean(plan && (plan.imgSrcSet || plan.sources.length > 0));
|
|
99
|
+
const usePicture = Boolean(src && srcMobile && mobileBreakpoint) && !hasResponsive;
|
|
100
|
+
const mobileMedia = mobileBreakpoint ? `(max-width: ${mobileBreakpoint - 1}px)` : void 0;
|
|
101
|
+
const responsiveImgAttrs = hasResponsive ? {
|
|
102
|
+
srcSet: plan.imgSrcSet,
|
|
103
|
+
sizes: plan.imgSizes,
|
|
104
|
+
width: plan.width,
|
|
105
|
+
height: plan.height
|
|
106
|
+
} : {};
|
|
107
|
+
function wrap(imgEl) {
|
|
108
|
+
if (hasResponsive && plan.sources.length > 0) return /* @__PURE__ */ jsxs("picture", {
|
|
109
|
+
className: "contents",
|
|
110
|
+
children: [plan.sources.map((s, i) => /* @__PURE__ */ jsx("source", {
|
|
111
|
+
type: s.type,
|
|
112
|
+
media: s.media,
|
|
113
|
+
srcSet: s.srcSet,
|
|
114
|
+
sizes: s.sizes
|
|
115
|
+
}, i)), imgEl]
|
|
116
|
+
});
|
|
117
|
+
if (usePicture) return /* @__PURE__ */ jsxs("picture", {
|
|
118
|
+
className: "contents",
|
|
119
|
+
children: [/* @__PURE__ */ jsx("source", {
|
|
120
|
+
media: mobileMedia,
|
|
121
|
+
srcSet: srcMobile ?? void 0
|
|
122
|
+
}), imgEl]
|
|
123
|
+
});
|
|
124
|
+
return imgEl;
|
|
125
|
+
}
|
|
126
|
+
if (frame === false) {
|
|
127
|
+
const cls = [
|
|
128
|
+
"tr-image-block",
|
|
129
|
+
fit ? objectFitClass(fit) : null,
|
|
130
|
+
className
|
|
131
|
+
].filter(Boolean).join(" ");
|
|
132
|
+
if (!src) return /* @__PURE__ */ jsx("div", {
|
|
133
|
+
className: cls,
|
|
134
|
+
role: "img",
|
|
135
|
+
"aria-label": altText || void 0,
|
|
136
|
+
...markerAttrs
|
|
137
|
+
});
|
|
138
|
+
return wrap(/* @__PURE__ */ jsx("img", {
|
|
139
|
+
src,
|
|
140
|
+
alt: altText,
|
|
141
|
+
loading: loading ?? "lazy",
|
|
142
|
+
decoding: "async",
|
|
143
|
+
className: cls,
|
|
144
|
+
style,
|
|
145
|
+
...markerAttrs,
|
|
146
|
+
...imgAttrs,
|
|
147
|
+
...responsiveImgAttrs
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
const containerCls = ["tr-image-frame tr-image-block relative overflow-hidden", className].filter(Boolean).join(" ");
|
|
151
|
+
if (!src) return /* @__PURE__ */ jsx("div", {
|
|
152
|
+
className: containerCls,
|
|
153
|
+
role: "img",
|
|
154
|
+
"aria-label": altText || void 0,
|
|
155
|
+
...markerAttrs
|
|
156
|
+
});
|
|
157
|
+
return /* @__PURE__ */ jsx("div", {
|
|
158
|
+
className: containerCls,
|
|
159
|
+
...markerAttrs,
|
|
160
|
+
children: wrap(/* @__PURE__ */ jsx("img", {
|
|
161
|
+
src,
|
|
162
|
+
alt: altText,
|
|
163
|
+
loading: loading ?? "lazy",
|
|
164
|
+
decoding: "async",
|
|
165
|
+
className: `absolute inset-0 h-full w-full ${objectFitClass(fit ?? "cover")}`,
|
|
166
|
+
...imgAttrs,
|
|
167
|
+
...responsiveImgAttrs
|
|
168
|
+
}))
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
export { Image };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
//#region src/primitives/Section.d.ts
|
|
3
|
+
type Props = HTMLAttributes<HTMLElement> & {
|
|
4
|
+
as?: "section" | "div" | "article" | "header" | "footer" | "aside";
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The section root. Every section renderer roots at exactly one `<Section>`.
|
|
9
|
+
*
|
|
10
|
+
* Full-bleed by contract: 100% width with zero margin (`.tr-section`, from the kit's
|
|
11
|
+
* base stylesheet), so consecutive sections butt edge-to-edge and a page composes as
|
|
12
|
+
* a vertical stack with no framework-injected whitespace. A margin utility on this
|
|
13
|
+
* root would re-open those gaps — `concrete check` reports it
|
|
14
|
+
* (section-root-margin). Padding is yours: on this root or on a child, the section's
|
|
15
|
+
* background still paints edge-to-edge under it.
|
|
16
|
+
*
|
|
17
|
+
* When content needs a centered, max-width well, write it as JSX on a child:
|
|
18
|
+
* `w-full max-w-[var(--tr-container-max)] mx-auto px-[var(--tr-container-pad)]`.
|
|
19
|
+
*/
|
|
20
|
+
declare function Section({ as, children, className, ...rest }: Props): import("react").JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Section };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/Section.tsx
|
|
4
|
+
/**
|
|
5
|
+
* The section root. Every section renderer roots at exactly one `<Section>`.
|
|
6
|
+
*
|
|
7
|
+
* Full-bleed by contract: 100% width with zero margin (`.tr-section`, from the kit's
|
|
8
|
+
* base stylesheet), so consecutive sections butt edge-to-edge and a page composes as
|
|
9
|
+
* a vertical stack with no framework-injected whitespace. A margin utility on this
|
|
10
|
+
* root would re-open those gaps — `concrete check` reports it
|
|
11
|
+
* (section-root-margin). Padding is yours: on this root or on a child, the section's
|
|
12
|
+
* background still paints edge-to-edge under it.
|
|
13
|
+
*
|
|
14
|
+
* When content needs a centered, max-width well, write it as JSX on a child:
|
|
15
|
+
* `w-full max-w-[var(--tr-container-max)] mx-auto px-[var(--tr-container-pad)]`.
|
|
16
|
+
*/
|
|
17
|
+
function Section({ as = "section", children, className, ...rest }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(as, {
|
|
19
|
+
className: ["tr-section", className].filter(Boolean).join(" "),
|
|
20
|
+
...rest,
|
|
21
|
+
children
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Section };
|