@perkyzz/emvb 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +9 -0
  2. package/package.json +2 -2
  3. package/src/admin/bulk-api.ts +67 -0
  4. package/src/admin/content-api.ts +10 -6
  5. package/src/admin/copy-rich-text.ts +119 -0
  6. package/src/admin/dialog-tab-wrap.ts +78 -0
  7. package/src/admin/editor/A11yCopilot.tsx +2 -0
  8. package/src/admin/editor/Editor.tsx +18 -6
  9. package/src/admin/editor/Timeline.tsx +6 -2
  10. package/src/admin/editor/TopBar.tsx +27 -7
  11. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  12. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  13. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  14. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  15. package/src/admin/editor/dnd/new-element.ts +22 -0
  16. package/src/admin/editor/editor-chrome.tsx +7 -5
  17. package/src/admin/editor/editor-commands.ts +10 -4
  18. package/src/admin/editor/editor-css.ts +2 -1
  19. package/src/admin/editor/panels/ElementPanel.tsx +29 -16
  20. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  21. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  22. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  23. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  24. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  25. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  26. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  27. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  28. package/src/admin/editor/panels/style-target.ts +17 -4
  29. package/src/admin/editor/section-templates.ts +26 -4
  30. package/src/admin/editor/store.ts +8 -2
  31. package/src/admin/editor/useEditorCommands.ts +7 -5
  32. package/src/admin/editor/useNodeActions.ts +4 -2
  33. package/src/admin/export-api.ts +221 -0
  34. package/src/admin/index.tsx +6 -1
  35. package/src/admin/pages/ExportDialog.tsx +395 -0
  36. package/src/admin/pages/PageList.tsx +67 -2
  37. package/src/admin/pages/ThemePartList.tsx +37 -1
  38. package/src/admin/pages/bulk.tsx +303 -0
  39. package/src/admin/search.ts +20 -0
  40. package/src/admin/theme-api.ts +4 -0
  41. package/src/admin/ui.ts +11 -2
  42. package/src/admin/widgets/CanvasField.tsx +8 -0
  43. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  44. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  45. package/src/admin/widgets/convert-body.ts +73 -2
  46. package/src/astro/render.ts +6 -6
  47. package/src/astro/resolve-theme.ts +11 -7
  48. package/src/astro/tabs/runtime.ts +16 -6
  49. package/src/constants.ts +1 -1
  50. package/src/core/a11y/audit.ts +2 -1
  51. package/src/core/contract.ts +22 -2
  52. package/src/core/css/generate.ts +83 -21
  53. package/src/core/css/scope.ts +10 -2
  54. package/src/core/css/trace.ts +33 -8
  55. package/src/core/design/classes.ts +25 -5
  56. package/src/core/design/devices.ts +78 -2
  57. package/src/core/design/variables.ts +14 -1
  58. package/src/core/export/runtimes.generated.ts +9 -0
  59. package/src/core/export/site.ts +562 -0
  60. package/src/core/export/zip.ts +95 -0
  61. package/src/core/history/diff.ts +25 -0
  62. package/src/core/import/elementor/atomic.ts +22 -9
  63. package/src/core/import/elementor/index.ts +22 -4
  64. package/src/core/import/elementor/style.ts +21 -1
  65. package/src/core/index.ts +14 -0
  66. package/src/core/json-schema.ts +8 -1
  67. package/src/core/perf/meter.ts +37 -19
  68. package/src/core/portable-text-export.ts +243 -0
  69. package/src/core/public-attributes.ts +30 -0
  70. package/src/core/render/index.ts +88 -9
  71. package/src/core/render/tabs.ts +18 -11
  72. package/src/core/sanitize/css.ts +26 -0
  73. package/src/core/schema/design.ts +2 -2
  74. package/src/core/schema/layout.ts +11 -3
  75. package/src/core/schema/style.ts +47 -0
  76. package/src/core/search-text.ts +70 -0
  77. package/src/core/theme/float.ts +1 -0
  78. package/src/core/theme/popup-rules.ts +16 -0
  79. package/src/mcp/read.ts +2 -3
  80. package/src/server/icon-routes.ts +52 -12
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  defaultElement,
3
+ updateNode,
3
4
  ELEMENTS,
4
5
  isExtensionType,
5
6
  newNodeId,
@@ -8,6 +9,7 @@ import {
8
9
  type LayoutNode,
9
10
  } from "../../../core/index.ts";
10
11
  import type { ThemePartType } from "../../../core/theme/part-types.ts";
12
+ import { indexLayout } from "../../../core/tree-ops.ts";
11
13
  import { isSharedPart } from "../panels/settings/heading-warning.ts";
12
14
 
13
15
  const hasH1 = (node: LayoutNode): boolean =>
@@ -31,6 +33,26 @@ export function withPageHeadingLevel(
31
33
  return { ...node, props: { ...node.props, level: 1 } };
32
34
  }
33
35
 
36
+ /**
37
+ * W-968: a new Post title inside a Loop (or in a loop item part) is an H2. Its default H1 gave a
38
+ * grid of cards one H1 per post. Run on the layout right after the insert; a title whose level was
39
+ * already changed, or one moved in later, is left alone.
40
+ */
41
+ export function withLoopPostTitleLevel(
42
+ layout: Layout,
43
+ id: string,
44
+ partType?: ThemePartType,
45
+ ): Layout {
46
+ const index = indexLayout(layout);
47
+ const node = index.byId.get(id);
48
+ if (node?.type !== "post-title" || (node.props as { level?: number }).level !== 1) return layout;
49
+ let inLoop = partType === "loop_item";
50
+ for (let at = index.parentOf.get(id); !inLoop && at; at = index.parentOf.get(at))
51
+ inLoop = index.byId.get(at)?.type === "loop";
52
+ if (!inLoop) return layout;
53
+ return updateNode(layout, id, (n) => ({ ...n, props: { ...n.props, level: 2 } }) as LayoutNode);
54
+ }
55
+
34
56
  const textNode = (text: string, random?: () => number): LayoutNode => ({
35
57
  ...defaultElement("text", newNodeId(random)),
36
58
  props: { text },
@@ -4,11 +4,11 @@ import type { SavedSectionActions } from "./useSavedSections.ts";
4
4
  import * as React from "react";
5
5
  import {
6
6
  findNode,
7
- toggleHidden,
7
+ toggleHiddenOn,
8
8
  type A11yReport,
9
9
  type ElementType,
10
10
  type LayoutNode,
11
- type Device,
11
+ type EditorDevice,
12
12
  type ThemeDynamicData,
13
13
  } from "../../core/index.ts";
14
14
  import type { Fetcher } from "../api.ts";
@@ -167,19 +167,21 @@ async function revertToPublished({
167
167
  /** Hide or show the selected element on the current device (W-096). */
168
168
  export function hideSelectedOnDevice(
169
169
  state: EditorState,
170
- device: Device,
170
+ device: EditorDevice,
171
171
  dispatch: React.Dispatch<EditorAction>,
172
172
  ): void {
173
173
  const id = state.selectedId;
174
174
  const node = state.page.layout && id ? findNode(state.page.layout, id) : undefined;
175
175
  if (!node) return;
176
- const hiddenOn = toggleHidden(node.hiddenOn, device);
177
176
  dispatch({
178
177
  type: "update-node",
179
178
  id: node.id,
180
179
  update: (current) => {
181
- const next = { ...current, hiddenOn };
180
+ // W-959: Wide screen's hide sits in `style.wide.hidden`; the rest in `hiddenOn`.
181
+ const { hiddenOn, style } = toggleHiddenOn(current, device);
182
+ const next = { ...current, hiddenOn, style };
182
183
  if (!hiddenOn) delete next.hiddenOn;
184
+ if (!style) delete next.style;
183
185
  return next;
184
186
  },
185
187
  });
@@ -1,4 +1,4 @@
1
- import type { PasteMode, Device, WrapType } from "../../core/index.ts";
1
+ import type { PasteMode, EditorDevice, WrapType } from "../../core/index.ts";
2
2
 
3
3
  /** Where an editor command is offered. Shortcuts call `runCommand` for the same ids. */
4
4
  export type CommandSurface = "palette" | "layers" | "overlay" | "device";
@@ -39,7 +39,7 @@ export type CommandRunners = {
39
39
  openTimeline?: () => void;
40
40
  openShare?: () => void;
41
41
  openWeight?: () => void;
42
- setDevice?: (device: Device) => void;
42
+ setDevice?: (device: EditorDevice) => void;
43
43
  openShortcuts?: () => void;
44
44
  rename?: () => void;
45
45
  /** Opens Save as section for an element (W-876). */
@@ -53,7 +53,7 @@ export type CommandInput = {
53
53
  targetId: string | null;
54
54
  isRoot: boolean;
55
55
  isParent: boolean;
56
- device: Device;
56
+ device: EditorDevice;
57
57
  /** Duplicate and wrap. False on the root and when nothing is selected. */
58
58
  canDuplicate: boolean;
59
59
  /** Delete and the sibling moves. False on the root. */
@@ -184,6 +184,7 @@ const SPECS: readonly Spec[] = [
184
184
  keywords: "performance budget size speed",
185
185
  surfaces: ["palette"],
186
186
  },
187
+ { id: "device-wide", labels: { palette: "View on wide screen" }, surfaces: ["palette"] },
187
188
  { id: "device-desktop", labels: { palette: "View on desktop" }, surfaces: ["palette"] },
188
189
  { id: "device-laptop", labels: { palette: "View on laptop" }, surfaces: ["palette"] },
189
190
  { id: "device-tablet", labels: { palette: "View on tablet" }, surfaces: ["palette"] },
@@ -232,6 +233,7 @@ const ORDER: Record<CommandSurface, readonly string[]> = {
232
233
  "timeline",
233
234
  "share",
234
235
  "weight",
236
+ "device-wide",
235
237
  "device-desktop",
236
238
  "device-laptop",
237
239
  "device-tablet",
@@ -267,7 +269,8 @@ function blocked(id: string, input: CommandInput): boolean {
267
269
  }
268
270
 
269
271
  function labelFor(spec: Spec, input: CommandInput): string {
270
- if (spec.id === "hide-on-device") return `Hide on ${input.device}`;
272
+ if (spec.id === "hide-on-device")
273
+ return `Hide on ${input.device === "wide" ? "wide screen" : input.device}`;
271
274
  return spec.labels[input.surface] ?? spec.id;
272
275
  }
273
276
 
@@ -369,6 +372,9 @@ export function runCommand(runners: CommandRunners, id: string, targetId: string
369
372
  case "weight":
370
373
  runners.openWeight?.();
371
374
  return;
375
+ case "device-wide":
376
+ runners.setDevice?.("wide");
377
+ return;
372
378
  case "device-desktop":
373
379
  runners.setDevice?.("desktop");
374
380
  return;
@@ -502,7 +502,8 @@ iframe[data-emvb-canvas-focus="keyboard"] { outline: 2px solid var(--color-kumo-
502
502
  font-family: var(--font-sans); font-size: 12px; line-height: 16px;
503
503
  }
504
504
  .emvb-chip:hover { background: var(--color-kumo-recessed); }
505
- .emvb-chip[data-active="true"] { background: var(--color-kumo-brand); color: #fff; }
505
+ /* W-976: white on the plain brand blue was 4.48:1 (#076eff); a darker mix keeps it over 4.5:1. */
506
+ .emvb-chip[data-active="true"] { background: color-mix(in oklch, var(--color-kumo-brand), black 18%); color: #fff; }
506
507
  .emvb-chip[data-missing] { background: transparent; box-shadow: inset 0 0 0 1px var(--color-kumo-danger); }
507
508
  .emvb-chip[data-missing] .emvb-chip-main { cursor: default; }
508
509
  .emvb-chip-main {
@@ -37,6 +37,7 @@ import {
37
37
  inheritedStyle,
38
38
  type LayoutNode,
39
39
  type Device,
40
+ type EditorDevice,
40
41
  type ResponsiveDevice,
41
42
  classStylesInListOrder,
42
43
  iconHasAdjustableStroke,
@@ -151,6 +152,14 @@ const NORMAL_ONLY_KEYS = new Set<StyleKey>([
151
152
  "scrollMotion",
152
153
  ]);
153
154
 
155
+ /** UX-063: which device is being edited and what it overrides (W-956 Laptop, W-959 Wide screen). */
156
+ const DEVICE_NOTE: Record<Exclude<EditorDevice, "desktop">, string> = {
157
+ wide: "Editing Wide screen (2400 px and up). These styles override Desktop.",
158
+ laptop: "Editing Laptop. These styles override Desktop.",
159
+ tablet: "Editing Tablet. These styles override Laptop and Desktop.",
160
+ mobile: "Editing Mobile. These styles override Tablet, Laptop and Desktop.",
161
+ };
162
+
154
163
  const JUMP_HELP: Record<Exclude<StyleStateChoice, "normal">, string> = {
155
164
  hover: "Changing size or position on hover can make the page jump.",
156
165
  focus: "Changing size or position on focus can make the page jump.",
@@ -220,7 +229,7 @@ type Props = {
220
229
  /** The chosen style state, for the canvas preview (W-089). */
221
230
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
222
231
  /** Tablet and mobile edit overrides. Desktop edits `style` (W-096). */
223
- device?: Device;
232
+ device?: EditorDevice;
224
233
  /** Add, move and delete for Accordion items and Tabs panels (W-130). */
225
234
  items?: ItemActions;
226
235
  /** The theme part being edited, if any, for the H1 warning (W-208). */
@@ -440,14 +449,18 @@ function KnownElementPanel({
440
449
  onStyleState?.(node.id, tab === "style" ? styleState : "normal");
441
450
  }, [node.id, styleState, tab, onStyleState]);
442
451
  // W-925: the rows read the flat motion keys; applyStylePatch nests them again.
443
- const normal = flattenMotion(cls ? cls.style : node.style);
452
+ // W-959: the own style's `wide` record is Wide screen's, not a Desktop value.
453
+ const { wide: storedWide, ...ownDesktop } = (cls ? cls.style : node.style) ?? {};
454
+ const normal = flattenMotion(cls || node.style ? ownDesktop : undefined);
444
455
  const states = cls ? cls.states : node.states;
445
- const responsive: ResponsiveDevice | null = device === "desktop" ? null : device;
456
+ const responsive: ResponsiveDevice | "wide" | null = device === "desktop" ? null : device;
446
457
  const storedDevices = cls ? cls.devices : node.devices;
447
- const ownerDevices = storedDevices && {
448
- laptop: flattenMotion(storedDevices.laptop),
449
- tablet: flattenMotion(storedDevices.tablet),
450
- mobile: flattenMotion(storedDevices.mobile),
458
+ const { hidden: _wideHidden, ...wideValues } = storedWide ?? {};
459
+ const ownerDevices = (storedDevices || storedWide) && {
460
+ wide: flattenMotion(storedWide ? wideValues : undefined),
461
+ laptop: flattenMotion(storedDevices?.laptop),
462
+ tablet: flattenMotion(storedDevices?.tablet),
463
+ mobile: flattenMotion(storedDevices?.mobile),
451
464
  };
452
465
  const style = responsive
453
466
  ? ownerDevices?.[responsive]
@@ -457,8 +470,9 @@ function KnownElementPanel({
457
470
  const ownInherited = responsive
458
471
  ? {
459
472
  ...normal,
460
- // W-956: each device inherits the wider ones: Laptop, then Tablet.
461
- ...(responsive !== "laptop" ? ownerDevices?.laptop : undefined),
473
+ // W-956: each device inherits the wider ones: Laptop, then Tablet. W-959: Wide screen
474
+ // builds on Desktop only.
475
+ ...(responsive !== "laptop" && responsive !== "wide" ? ownerDevices?.laptop : undefined),
462
476
  ...(responsive === "mobile" ? ownerDevices?.tablet : undefined),
463
477
  }
464
478
  : styleState === "normal"
@@ -497,6 +511,8 @@ function KnownElementPanel({
497
511
  !singleColorOffered &&
498
512
  node.props.singleColor !== true &&
499
513
  ownColors;
514
+ // Field values have no laptop or wide screen setting: those devices edit Desktop's.
515
+ const fieldDevice: Device = device === "laptop" || device === "wide" ? "desktop" : device;
500
516
  const patchStyle = (patch: Partial<FlatStyleProps>) => {
501
517
  const written = applyStylePatch({
502
518
  node,
@@ -602,7 +618,7 @@ function KnownElementPanel({
602
618
  </p>
603
619
  ) : (
604
620
  pairFields(
605
- descriptor.fields.filter((field) => fieldShown(field.key, node, device)),
621
+ descriptor.fields.filter((field) => fieldShown(field.key, node, fieldDevice)),
606
622
  ).map((row) => {
607
623
  const controls = row.map((field) => (
608
624
  <React.Fragment key={field.key}>
@@ -615,8 +631,7 @@ function KnownElementPanel({
615
631
  duplicateName={
616
632
  field.key === "field" && layout ? duplicateFieldName(layout, node.id) : false
617
633
  }
618
- // Field values have no laptop setting: Laptop edits the desktop value.
619
- device={device === "laptop" ? "desktop" : device}
634
+ device={fieldDevice}
620
635
  />
621
636
  </React.Fragment>
622
637
  ));
@@ -709,10 +724,8 @@ function KnownElementPanel({
709
724
  ) : (
710
725
  // UX-063: say which device is being edited, as states say "Editing Hover".
711
726
  <p className="emvb-helper" data-emvb-device-note={device}>
712
- {device === "mobile"
713
- ? "Editing Mobile. These styles override Tablet and Desktop."
714
- : "Editing Tablet. These styles override Desktop."}{" "}
715
- Hover, Focus and Active are set on Desktop and apply on every device.
727
+ {DEVICE_NOTE[device]} Hover, Focus and Active are set on Desktop and apply on every
728
+ device.
716
729
  </p>
717
730
  )}
718
731
  {!cls && <StyleSources node={node} design={design} device={device} state={styleState} />}
@@ -1,6 +1,6 @@
1
1
  import type * as React from "react";
2
2
  import type { Deletion } from "../restore-deleted.ts";
3
- import type { DesignSystem, LayoutNode, Device } from "../../../core/index.ts";
3
+ import type { DesignSystem, LayoutNode, EditorDevice } from "../../../core/index.ts";
4
4
  import type { Fetcher } from "../../api.ts";
5
5
  import type { EditorAction, EditorState } from "../store.ts";
6
6
  import { ElementPanel } from "./ElementPanel.tsx";
@@ -54,7 +54,7 @@ export function SettingsPanel({
54
54
  /** The Style tab's chosen state, for the canvas preview (W-089). */
55
55
  onStyleState?: (nodeId: string, state: StyleStateChoice) => void;
56
56
  /** Which device's styles the Style tab edits (W-096). */
57
- device?: Device;
57
+ device?: EditorDevice;
58
58
  /** Accordion and Tabs item actions (W-130). */
59
59
  items?: ItemActions;
60
60
  }) {
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Button, Select } from "@cloudflare/kumo";
3
- import { PlusIcon } from "@phosphor-icons/react";
3
+ import { PencilSimpleIcon, PlusIcon } from "@phosphor-icons/react";
4
4
  import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
5
5
  import { BUTTON, FIELD } from "../../../ui.ts";
6
6
  import { ColorControl } from "../ColorControl.tsx";
@@ -12,6 +12,57 @@ type Transition = NonNullable<FlatStyleProps["transition"]>;
12
12
  type Entrance = NonNullable<FlatStyleProps["entrance"]>;
13
13
 
14
14
  /** DESIGN.md: Add shadow starts at 0 4 12 0, 18 % black. */
15
+ /**
16
+ * W-969: a composite style (shadow, entrance, transition, drop shadow) that is unset here but
17
+ * inherited (from a wider device, the Normal state, a class or the Site styles default) says what
18
+ * it inherits, and Edit here starts from that value instead of the default.
19
+ */
20
+ export function InheritedStart({
21
+ summary,
22
+ label,
23
+ onEdit,
24
+ }: {
25
+ summary: string;
26
+ label: string;
27
+ onEdit: () => void;
28
+ }) {
29
+ return (
30
+ <>
31
+ <p className="emvb-helper" data-emvb-inherited-note="">
32
+ Inherited: {summary}.
33
+ </p>
34
+ <Button
35
+ type="button"
36
+ variant="secondary"
37
+ className={`${BUTTON} emvb-add-shadow`}
38
+ icon={<PencilSimpleIcon aria-hidden="true" />}
39
+ onClick={onEdit}
40
+ aria-label={`Edit ${label} here`}
41
+ >
42
+ Edit here
43
+ </Button>
44
+ </>
45
+ );
46
+ }
47
+
48
+ const hexOf = (color: unknown) =>
49
+ typeof color === "string"
50
+ ? color
51
+ : color && typeof color === "object" && "var" in color
52
+ ? `variable ${String((color as { var: unknown }).var)}`
53
+ : "";
54
+
55
+ export const shadowSummary = (s: {
56
+ x: number;
57
+ y: number;
58
+ blur: number;
59
+ spread?: number;
60
+ color?: unknown;
61
+ }) =>
62
+ [`${s.x} ${s.y} ${s.blur}${s.spread !== undefined ? ` ${s.spread}` : ""} px`, hexOf(s.color)]
63
+ .filter(Boolean)
64
+ .join(", ");
65
+
15
66
  const NEW_SHADOW: Shadow = { x: 0, y: 4, blur: 12, spread: 0, color: "#0000002e" };
16
67
 
17
68
  const OFFSET: NumberSpec = { min: -1000, max: 1000, example: "4" };
@@ -27,12 +78,14 @@ const SHADOW_FIELDS: ReadonlyArray<
27
78
  /** One box shadow: Add shadow when unset; X, Y, blur, spread, colour and inset when set. */
28
79
  export function ShadowControl({
29
80
  value,
81
+ inherited,
30
82
  design,
31
83
  onChange,
32
84
  onDesignChange,
33
85
  reset,
34
86
  }: {
35
87
  value: Shadow | undefined;
88
+ inherited?: Shadow | undefined;
36
89
  design: DesignSystem;
37
90
  onChange: (next: Shadow | undefined) => void;
38
91
  onDesignChange: (design: DesignSystem) => Promise<void>;
@@ -49,6 +102,7 @@ export function ShadowControl({
49
102
  className="emvb-style-row"
50
103
  data-emvb-style="boxShadow"
51
104
  data-set={value ? "true" : undefined}
105
+ data-inherited={!value && inherited ? "true" : undefined}
52
106
  >
53
107
  <div className="emvb-field-group emvb-shadow">
54
108
  <span className="emvb-var-field-label">Box shadow</span>
@@ -88,6 +142,12 @@ export function ShadowControl({
88
142
  ))}
89
143
  </div>
90
144
  </>
145
+ ) : inherited ? (
146
+ <InheritedStart
147
+ summary={shadowSummary(inherited)}
148
+ label="box shadow"
149
+ onEdit={() => onChange({ ...inherited })}
150
+ />
91
151
  ) : (
92
152
  <Button
93
153
  type="button"
@@ -335,10 +395,12 @@ const ENTRANCE_TYPES: { value: Entrance["type"]; label: string }[] = [
335
395
  /** Plays once on load (W-101, Normal only). Add entrance starts at Fade, 400 ms. */
336
396
  export function EntranceControl({
337
397
  value,
398
+ inherited,
338
399
  onChange,
339
400
  reset,
340
401
  }: {
341
402
  value: Entrance | undefined;
403
+ inherited?: Entrance | undefined;
342
404
  onChange: (next: Entrance | undefined) => void;
343
405
  reset: React.ReactNode;
344
406
  }) {
@@ -347,6 +409,7 @@ export function EntranceControl({
347
409
  className="emvb-style-row"
348
410
  data-emvb-style="entrance"
349
411
  data-set={value ? "true" : undefined}
412
+ data-inherited={!value && inherited ? "true" : undefined}
350
413
  >
351
414
  <div className="emvb-field-group emvb-transition">
352
415
  <span className="emvb-var-field-label">Entrance</span>
@@ -385,6 +448,12 @@ export function EntranceControl({
385
448
  }
386
449
  />
387
450
  </>
451
+ ) : inherited ? (
452
+ <InheritedStart
453
+ summary={`${ENTRANCE_TYPES.find((t) => t.value === inherited.type)?.label ?? inherited.type}, ${inherited.duration} ms`}
454
+ label="entrance"
455
+ onEdit={() => onChange({ ...inherited })}
456
+ />
388
457
  ) : (
389
458
  <Button
390
459
  type="button"
@@ -405,10 +474,12 @@ export function EntranceControl({
405
474
  /** One transition (W-089, Normal only): Add transition when unset; duration, delay, easing, property when set. */
406
475
  export function TransitionControl({
407
476
  value,
477
+ inherited,
408
478
  onChange,
409
479
  reset,
410
480
  }: {
411
481
  value: Transition | undefined;
482
+ inherited?: Transition | undefined;
412
483
  onChange: (next: Transition | undefined) => void;
413
484
  reset: React.ReactNode;
414
485
  }) {
@@ -423,6 +494,7 @@ export function TransitionControl({
423
494
  className="emvb-style-row"
424
495
  data-emvb-style="transition"
425
496
  data-set={value ? "true" : undefined}
497
+ data-inherited={!value && inherited ? "true" : undefined}
426
498
  >
427
499
  <div className="emvb-field-group emvb-transition">
428
500
  <span className="emvb-var-field-label">Transition</span>
@@ -457,6 +529,12 @@ export function TransitionControl({
457
529
  onChange={(property) => patch({ property })}
458
530
  />
459
531
  </>
532
+ ) : inherited ? (
533
+ <InheritedStart
534
+ summary={`${inherited.duration} ms, ${EASINGS.find((e) => e.value === inherited.easing)?.label ?? inherited.easing}`}
535
+ label="transition"
536
+ onEdit={() => onChange({ ...inherited })}
537
+ />
460
538
  ) : (
461
539
  <Button
462
540
  type="button"
@@ -10,6 +10,7 @@ import type { DesignSystem, FlatStyleProps } from "../../../../core/index.ts";
10
10
  import { BUTTON, FIELD } from "../../../ui.ts";
11
11
  import { ColorControl } from "../ColorControl.tsx";
12
12
  import { radioGroupKeys } from "./ChoiceGroup.tsx";
13
+ import { InheritedStart, shadowSummary } from "./EffectsControls.tsx";
13
14
  import { NumberField, ResetButton, type NumberSpec } from "./NumberRow.tsx";
14
15
  import { HintedSwitch } from "./HintedSwitch.tsx";
15
16
 
@@ -146,11 +147,14 @@ const ICON_SHADOW_FIELDS: ReadonlyArray<[key: "x" | "y" | "blur", label: string,
146
147
 
147
148
  export function IconShadowControl({
148
149
  value,
150
+ inherited,
149
151
  design,
150
152
  onChange,
151
153
  onDesignChange,
152
154
  }: {
153
155
  value: IconShadow | undefined;
156
+ /** W-969: the drop shadow this device or state inherits, shown and used by Edit here. */
157
+ inherited?: IconShadow | undefined;
154
158
  design: DesignSystem;
155
159
  onChange: (next: IconShadow | undefined) => void;
156
160
  onDesignChange: (design: DesignSystem) => Promise<void>;
@@ -166,6 +170,7 @@ export function IconShadowControl({
166
170
  className="emvb-style-row"
167
171
  data-emvb-style="iconShadow"
168
172
  data-set={value ? "true" : undefined}
173
+ data-inherited={!value && inherited ? "true" : undefined}
169
174
  >
170
175
  <div className="emvb-field-group emvb-shadow">
171
176
  <span className="emvb-var-field-label">Drop shadow</span>
@@ -191,6 +196,12 @@ export function IconShadowControl({
191
196
  ))}
192
197
  </div>
193
198
  </>
199
+ ) : inherited ? (
200
+ <InheritedStart
201
+ summary={shadowSummary(inherited)}
202
+ label="drop shadow"
203
+ onEdit={() => onChange({ ...inherited })}
204
+ />
194
205
  ) : (
195
206
  <Button
196
207
  type="button"
@@ -13,6 +13,7 @@ import {
13
13
  type LengthLiteral,
14
14
  type LengthUnit,
15
15
  type UnitChoice,
16
+ isViewportUnit,
16
17
  } from "./length-units.ts";
17
18
  import type { StyleKey } from "./style-sections.ts";
18
19
  import { bindKind, boundRef, lengthRef, VariableButton, VariableChip } from "./VariableBinding.tsx";
@@ -45,6 +46,7 @@ export function LengthRow({
45
46
  slider = false,
46
47
  onPatch,
47
48
  reset,
49
+ viewportUnits,
48
50
  }: {
49
51
  styleKey: StyleKey;
50
52
  label: string;
@@ -57,14 +59,24 @@ export function LengthRow({
57
59
  slider?: boolean;
58
60
  onPatch: (patch: Partial<FlatStyleProps>) => void;
59
61
  reset: React.ReactNode;
62
+ /** W-974: the record's dvh/svh marks; a marked `vh` length shows as that unit. */
63
+ viewportUnits?: FlatStyleProps["viewportUnits"];
60
64
  }) {
61
65
  const units = unitsFor(styleKey);
62
66
  // W-213: a plain number is a unitless line height, shown with the `x` unit.
63
67
  // W-603: memoized, so a plain number doesn't make a new object each render; the effect below
64
68
  // would reset the draft on every keystroke and nothing typed over a unitless value would stick.
69
+ const marked = viewportUnits?.[styleKey as keyof NonNullable<typeof viewportUnits>];
65
70
  const literal = React.useMemo<{ value: number; unit: NumericUnit } | undefined>(
66
- () => (isLiteral(value) ? value : typeof value === "number" ? { value, unit: "x" } : undefined),
67
- [value],
71
+ () =>
72
+ isLiteral(value)
73
+ ? value.unit === "vh" && marked
74
+ ? { value: value.value, unit: marked }
75
+ : value
76
+ : typeof value === "number"
77
+ ? { value, unit: "x" }
78
+ : undefined,
79
+ [value, marked],
68
80
  );
69
81
  // W-955: a fluid size shows as "32–56" in px.
70
82
  const fluid = isFluid(value) ? value : undefined;
@@ -82,7 +94,28 @@ export function LengthRow({
82
94
  }, [value, literal]);
83
95
 
84
96
  const send = (next: LengthLiteral | FluidLiteral | "auto" | number | undefined) => {
85
- if (!same(next, value)) onPatch({ [styleKey]: next });
97
+ // W-974: dvh and svh are stored as vh plus the record's mark, so 1.0 still draws vh.
98
+ const nextUnit = isLiteral(next) ? next.unit : undefined;
99
+ const stored =
100
+ isLiteral(next) && isViewportUnit(nextUnit)
101
+ ? { value: next.value, unit: "vh" as const }
102
+ : next;
103
+ const marks = { ...viewportUnits } as Record<string, string>;
104
+ if (isViewportUnit(nextUnit)) marks[styleKey] = nextUnit;
105
+ else delete marks[styleKey];
106
+ const marksChanged = (marks[styleKey] ?? null) !== (marked ?? null);
107
+ if (same(stored, value) && !marksChanged) return;
108
+ onPatch({
109
+ [styleKey]: stored,
110
+ ...(marksChanged
111
+ ? {
112
+ viewportUnits:
113
+ Object.keys(marks).length > 0
114
+ ? (marks as FlatStyleProps["viewportUnits"])
115
+ : undefined,
116
+ }
117
+ : {}),
118
+ });
86
119
  };
87
120
 
88
121
  const commit = () => {
@@ -56,6 +56,7 @@ export function LoopItemBindControl({
56
56
 
57
57
  if (parts && parts.length > 0) {
58
58
  const known = parts.some((part) => part.id === value);
59
+ const chosen = parts.find((part) => part.id === value);
59
60
  const selectValue = value === "" ? NONE : known ? value : MANUAL;
60
61
  return (
61
62
  <div {...{ [`data-emvb-${marker}-bind`]: "list" }}>
@@ -98,6 +99,11 @@ export function LoopItemBindControl({
98
99
  Optional published {label} theme part. Leave blank to use nested elements.
99
100
  {adminLinks && <a href="/_emdash/admin/plugins/emvb/theme"> Open Theme Builder</a>}
100
101
  </p>
102
+ {chosen && chosen.status !== "published" && (
103
+ <p className="emvb-helper" role="note" data-emvb-part-draft={chosen.status}>
104
+ {draftNote(chosen.status)}
105
+ </p>
106
+ )}
101
107
  </div>
102
108
  );
103
109
  }
@@ -128,3 +134,15 @@ function labelFor(part: ThemePartSummary): string {
128
134
  const status = part.status === "published" ? "" : ` (${part.status})`;
129
135
  return `${part.title}${status}`;
130
136
  }
137
+
138
+ /**
139
+ * W-970: the canvas draws a part's latest saved version, but visitors only see what is published.
140
+ * Say so when the chosen part has unpublished changes, or was never published.
141
+ */
142
+ function draftNote(status: string): string {
143
+ if (status === "changed")
144
+ return "The canvas shows this part's unpublished changes. Visitors see the published version until you publish it in Theme Builder.";
145
+ if (status === "scheduled")
146
+ return "The canvas shows this part as scheduled. Visitors see it once it goes live.";
147
+ return "This part isn't published yet. The canvas shows its draft, but visitors see nothing here until you publish it in Theme Builder.";
148
+ }
@@ -539,6 +539,7 @@ export function StyleRow({
539
539
  return (
540
540
  <IconShadowControl
541
541
  value={style?.iconShadow}
542
+ inherited={inherited?.iconShadow}
542
543
  design={design}
543
544
  onChange={(iconShadow) => onPatch({ iconShadow })}
544
545
  onDesignChange={onDesignChange}
@@ -559,6 +560,7 @@ export function StyleRow({
559
560
  return (
560
561
  <ShadowControl
561
562
  value={style?.boxShadow}
563
+ inherited={inherited?.boxShadow}
562
564
  design={design}
563
565
  onChange={(boxShadow) => onPatch({ boxShadow })}
564
566
  onDesignChange={onDesignChange}
@@ -571,6 +573,7 @@ export function StyleRow({
571
573
  return (
572
574
  <EntranceControl
573
575
  value={style?.entrance}
576
+ inherited={inherited?.entrance}
574
577
  onChange={(entrance) => onPatch({ entrance })}
575
578
  reset={reset}
576
579
  />
@@ -601,6 +604,7 @@ export function StyleRow({
601
604
  return (
602
605
  <TransitionControl
603
606
  value={style?.transition}
607
+ inherited={inherited?.transition}
604
608
  onChange={(transition) => onPatch({ transition })}
605
609
  reset={reset}
606
610
  />
@@ -651,6 +655,7 @@ export function StyleRow({
651
655
  slider={styleKey === "gap"}
652
656
  onPatch={onPatch}
653
657
  reset={reset}
658
+ viewportUnits={style?.viewportUnits}
654
659
  />
655
660
  );
656
661
  }
@@ -678,6 +683,8 @@ export const IMPLEMENTED_STYLE_KEYS: StyleKey[] = [
678
683
  "entrance",
679
684
  "scrollMotion",
680
685
  "loopMotion",
686
+ // W-974: set by the Height rows' dvh/svh units (LengthRow), never a row of its own.
687
+ "viewportUnits",
681
688
  "transition",
682
689
  "iconRotate",
683
690
  "iconFlip",