@perkyzz/emvb 0.2.1 → 0.4.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/README.md +4 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/package.json +3 -1
- package/src/admin/access/role.ts +9 -3
- package/src/admin/api.ts +17 -7
- package/src/admin/content-api.ts +7 -51
- package/src/admin/content-item.ts +22 -0
- package/src/admin/design-api.ts +30 -0
- package/src/admin/editor/A11yCopilot.tsx +126 -0
- package/src/admin/editor/CommandPalette.tsx +118 -0
- package/src/admin/editor/Editor.tsx +188 -152
- package/src/admin/editor/EditorOverlay.tsx +9 -1
- package/src/admin/editor/PerfMeter.tsx +121 -0
- package/src/admin/editor/ShareLink.tsx +164 -0
- package/src/admin/editor/ShortcutsDialog.tsx +4 -1
- package/src/admin/editor/Timeline.tsx +287 -0
- package/src/admin/editor/TopBar.tsx +4 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +62 -370
- package/src/admin/editor/canvas/DeviceBar.tsx +4 -1
- package/src/admin/editor/canvas/SelectionOverlay.tsx +87 -47
- package/src/admin/editor/canvas/canvas-scale.ts +20 -0
- package/src/admin/editor/canvas/drop-line.ts +24 -0
- package/src/admin/editor/canvas/use-canvas-dnd.ts +207 -0
- package/src/admin/editor/canvas/use-canvas-session.ts +216 -0
- package/src/admin/editor/collection-previews.ts +114 -0
- package/src/admin/editor/editor-chrome.tsx +346 -0
- package/src/admin/editor/editor-commands.ts +360 -0
- package/src/admin/editor/editor-css.ts +5 -3
- package/src/admin/editor/element-chrome.ts +89 -0
- package/src/admin/editor/feature-css.ts +105 -0
- package/src/admin/editor/host.ts +35 -0
- package/src/admin/editor/icons/IconLibraryDialog.tsx +64 -218
- package/src/admin/editor/icons/library.ts +29 -19
- package/src/admin/editor/icons/use-icon-library.ts +315 -0
- package/src/admin/editor/live-data.tsx +71 -0
- package/src/admin/editor/palette-items.ts +136 -0
- package/src/admin/editor/palette.ts +68 -0
- package/src/admin/editor/panels/AddPanel.tsx +48 -68
- package/src/admin/editor/panels/ClassesSection.tsx +5 -1
- package/src/admin/editor/panels/ColorControl.tsx +2 -10
- package/src/admin/editor/panels/ElementPanel.tsx +74 -102
- package/src/admin/editor/panels/LayersPanel.tsx +72 -63
- package/src/admin/editor/panels/LeftPanel.tsx +4 -1
- package/src/admin/editor/panels/SettingsPanel.tsx +13 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +18 -10
- package/src/admin/editor/panels/TokenScales.tsx +168 -0
- package/src/admin/editor/panels/VariableSection.tsx +10 -14
- package/src/admin/editor/panels/inline-error.tsx +11 -0
- package/src/admin/editor/panels/settings/AdvancedFields.tsx +87 -1
- package/src/admin/editor/panels/settings/AudienceEditor.tsx +285 -0
- package/src/admin/editor/panels/settings/BindingsEditor.tsx +221 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +1 -1
- package/src/admin/editor/panels/settings/DraftTextField.tsx +4 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +2 -2
- package/src/admin/editor/panels/settings/FormBindControl.tsx +8 -4
- package/src/admin/editor/panels/settings/ItemList.tsx +34 -1
- package/src/admin/editor/panels/settings/MotionControl.tsx +252 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +1 -1
- package/src/admin/editor/panels/settings/StyleRow.tsx +26 -2
- package/src/admin/editor/panels/settings/StyleSources.tsx +94 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +1 -1
- package/src/admin/editor/panels/settings/VariantEditor.tsx +83 -0
- package/src/admin/editor/panels/settings/form-names.ts +7 -11
- package/src/admin/editor/panels/settings/length-units.ts +16 -5
- package/src/admin/editor/panels/settings/style-sections.ts +7 -2
- package/src/admin/editor/panels/style-target.ts +105 -0
- package/src/admin/editor/section-templates.ts +43 -21
- package/src/admin/editor/shortcuts.ts +6 -1
- package/src/admin/editor/store.ts +10 -1
- package/src/admin/editor/useClipboardActions.ts +1 -1
- package/src/admin/editor/useEditorCommands.ts +61 -13
- package/src/admin/editor/useEditorData.ts +7 -1
- package/src/admin/editor/useEditorShortcuts.ts +30 -14
- package/src/admin/editor/useNodeActions.ts +44 -16
- package/src/admin/forms-api.ts +17 -6
- package/src/admin/icon-uploads-api.ts +18 -0
- package/src/admin/theme-api.ts +5 -18
- package/src/admin/ui.ts +4 -4
- package/src/astro/content-port.ts +24 -0
- package/src/astro/forms/EmVBFormsClient.astro +11 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +6 -7
- package/src/astro/forms/client.ts +1 -0
- package/src/astro/forms-definitions.ts +24 -11
- package/src/astro/index.ts +1 -0
- package/src/astro/render-session.ts +85 -0
- package/src/astro/request-data.ts +109 -0
- package/src/astro/resolve-theme.ts +184 -64
- package/src/astro/resolve.ts +63 -16
- package/src/astro/theme-posts.ts +48 -5
- package/src/astro/visitor.ts +204 -0
- package/src/constants.ts +1 -1
- package/src/core/a11y/audit.ts +282 -0
- package/src/core/arrange.ts +150 -34
- package/src/core/audience/rules.ts +124 -0
- package/src/core/audience/variants.ts +51 -0
- package/src/core/canvas-styles.ts +24 -0
- package/src/core/clipboard.ts +11 -32
- package/src/core/css/generate.ts +29 -2
- package/src/core/css/print.ts +12 -0
- package/src/core/css/scope.ts +3 -3
- package/src/core/css/trace.ts +169 -0
- package/src/core/css-keywords.ts +83 -0
- package/src/core/data/bindings.ts +255 -0
- package/src/core/design/classes.ts +13 -15
- package/src/core/design/diff.ts +55 -0
- package/src/core/design/merge.ts +127 -0
- package/src/core/design/tokens.ts +127 -0
- package/src/core/design/variables.ts +25 -21
- package/src/core/elements/dynamic-elements.ts +117 -2
- package/src/core/elements/form-elements.ts +1 -0
- package/src/core/elements/index.ts +185 -7
- package/src/core/forms/binding.ts +4 -13
- package/src/core/history/diff.ts +152 -0
- package/src/core/index.ts +121 -0
- package/src/core/local-style.ts +27 -0
- package/src/core/migrate/index.ts +12 -4
- package/src/core/nesting.ts +4 -22
- package/src/core/perf/meter.ts +160 -0
- package/src/core/perf/scripts.ts +61 -0
- package/src/core/recipes/index.ts +433 -0
- package/src/core/record.ts +3 -0
- package/src/core/render/context.ts +2 -0
- package/src/core/render/dynamic-post.ts +1 -2
- package/src/core/render/form.ts +133 -10
- package/src/core/render/index.ts +206 -17
- package/src/core/render/loop.ts +54 -7
- package/src/core/render/pagination.ts +9 -1
- package/src/core/render/vnode.ts +12 -2
- package/src/core/sanitize/css.ts +129 -80
- package/src/core/sanitize/motion.ts +129 -0
- package/src/core/sanitize/svg.ts +8 -3
- package/src/core/sanitize/url.ts +10 -1
- package/src/core/schema/design.ts +29 -8
- package/src/core/schema/layout.ts +291 -169
- package/src/core/schema/motion.ts +14 -0
- package/src/core/schema/style.ts +101 -66
- package/src/core/share/link.ts +187 -0
- package/src/core/tabs/presence.ts +7 -17
- package/src/core/theme/dynamic.ts +242 -32
- package/src/core/theme/float.ts +1 -1
- package/src/core/theme/pagination.ts +56 -0
- package/src/core/tree-ops.ts +57 -0
- package/src/index.ts +14 -2
- package/src/server/design-routes.ts +4 -1
- package/src/server/icon-routes.ts +68 -16
- package/src/server/plugin.ts +8 -2
- package/src/admin/editor/icons/sets/fontawesome.json +0 -1
- package/src/admin/editor/icons/sets/lucide.json +0 -1
- package/src/admin/editor/icons/sets/remix.json +0 -1
- package/src/admin/editor/icons/sets/tabler.json +0 -1
|
@@ -3,23 +3,13 @@ import type { Fetcher } from "../../api.ts";
|
|
|
3
3
|
import {
|
|
4
4
|
CaretDownIcon,
|
|
5
5
|
CaretRightIcon,
|
|
6
|
-
CheckSquareIcon,
|
|
7
|
-
ClipboardTextIcon,
|
|
8
|
-
ImageIcon,
|
|
9
|
-
NotePencilIcon,
|
|
10
6
|
PaintBrushIcon,
|
|
11
|
-
PaperPlaneTiltIcon,
|
|
12
7
|
PencilSimpleIcon,
|
|
13
|
-
RadioButtonIcon,
|
|
14
|
-
RowsIcon,
|
|
15
|
-
SquaresFourIcon,
|
|
16
|
-
StarIcon,
|
|
17
|
-
TextHIcon,
|
|
18
|
-
TextboxIcon,
|
|
19
8
|
WarningCircleIcon,
|
|
20
|
-
YoutubeLogoIcon,
|
|
21
9
|
} from "@phosphor-icons/react";
|
|
22
10
|
import * as React from "react";
|
|
11
|
+
import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
|
|
12
|
+
import { indexLayout } from "../../../core/tree-ops.ts";
|
|
23
13
|
import type { ThemePartType } from "../../../core/theme/part-types.ts";
|
|
24
14
|
import { sharedPartH1 } from "./settings/heading-warning.ts";
|
|
25
15
|
import { UNNAMED_BOX_LINK_NOTE, unnamedBoxLink } from "./settings/box-link-name.ts";
|
|
@@ -31,38 +21,43 @@ import { duplicateFieldName } from "./settings/form-names.ts";
|
|
|
31
21
|
import { hasItemList, ItemList, type ItemActions } from "./settings/ItemList.tsx";
|
|
32
22
|
import {
|
|
33
23
|
ELEMENT_DESCRIPTORS,
|
|
34
|
-
findNode,
|
|
35
24
|
hasLocalStyles,
|
|
36
25
|
localStylesToClass,
|
|
37
26
|
localToClassRefusal,
|
|
38
27
|
isFormNode,
|
|
39
|
-
parentOf,
|
|
40
28
|
type DesignSystem,
|
|
41
29
|
type ElementDescriptor,
|
|
42
30
|
type Layout,
|
|
31
|
+
type Arranged,
|
|
32
|
+
inheritedStyle,
|
|
43
33
|
type LayoutNode,
|
|
44
|
-
patchClassDevices,
|
|
45
|
-
patchClassState,
|
|
46
|
-
patchClassStyle,
|
|
47
|
-
patchDeviceStyle,
|
|
48
|
-
patchStates,
|
|
49
|
-
type DeviceStyles,
|
|
50
34
|
type PopupDevice,
|
|
51
35
|
type ResponsiveDevice,
|
|
52
36
|
classStylesInListOrder,
|
|
53
37
|
iconHasAdjustableStroke,
|
|
54
38
|
iconHasOwnColors,
|
|
55
39
|
resolveCascade,
|
|
40
|
+
SAMPLE_POST,
|
|
56
41
|
STYLE_STATES,
|
|
57
42
|
type StyleProps,
|
|
58
43
|
type StyleStates,
|
|
59
44
|
} from "../../../core/index.ts";
|
|
45
|
+
import { applyStylePatch } from "./style-target.ts";
|
|
60
46
|
import { FieldControl } from "./settings/FieldControl.tsx";
|
|
47
|
+
import { BindingsEditor } from "./settings/BindingsEditor.tsx";
|
|
48
|
+
import { VariantEditor } from "./settings/VariantEditor.tsx";
|
|
49
|
+
import { AudienceEditor } from "./settings/AudienceEditor.tsx";
|
|
50
|
+
import { StyleSources } from "./settings/StyleSources.tsx";
|
|
61
51
|
import { BoxControl } from "./settings/BoxControl.tsx";
|
|
62
52
|
import { boxGroupOf } from "./settings/box-sides.ts";
|
|
63
53
|
import { IconShapeRow, IconSingleColorRow } from "./settings/IconControls.tsx";
|
|
64
54
|
import { StyleRow } from "./settings/StyleRow.tsx";
|
|
65
|
-
import {
|
|
55
|
+
import {
|
|
56
|
+
AttributesEditor,
|
|
57
|
+
ContainerQueryFields,
|
|
58
|
+
DirectionField,
|
|
59
|
+
HtmlIdField,
|
|
60
|
+
} from "./settings/AdvancedFields.tsx";
|
|
66
61
|
import { ClassChipInput } from "./settings/ClassChipInput.tsx";
|
|
67
62
|
import { StateDot, StateSwitcher, type StyleStateChoice } from "./settings/StateSwitcher.tsx";
|
|
68
63
|
import {
|
|
@@ -76,60 +71,17 @@ import {
|
|
|
76
71
|
type StyleSectionId,
|
|
77
72
|
} from "./settings/style-sections.ts";
|
|
78
73
|
|
|
79
|
-
export const ELEMENT_NAMES: Record<string, string> = Object.fromEntries(
|
|
80
|
-
ELEMENT_DESCRIPTORS.map((d) => [d.type, d.name]),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
74
|
const enclosingFormId = (layout: Layout, nodeId: string): string | undefined => {
|
|
84
|
-
|
|
75
|
+
const index = indexLayout(layout);
|
|
76
|
+
let current = index.parentOf.get(nodeId);
|
|
85
77
|
while (current) {
|
|
86
|
-
const node =
|
|
78
|
+
const node = index.byId.get(current);
|
|
87
79
|
if (node && isFormNode(node)) return node.props.formId || undefined;
|
|
88
|
-
current = parentOf(
|
|
80
|
+
current = index.parentOf.get(current);
|
|
89
81
|
}
|
|
90
82
|
return undefined;
|
|
91
83
|
};
|
|
92
84
|
|
|
93
|
-
const ICONS: Record<string, typeof TextHIcon> = {
|
|
94
|
-
heading: TextHIcon,
|
|
95
|
-
container: SquaresFourIcon,
|
|
96
|
-
"div-block": SquaresFourIcon,
|
|
97
|
-
"layout-section": RowsIcon,
|
|
98
|
-
flexbox: SquaresFourIcon,
|
|
99
|
-
image: ImageIcon,
|
|
100
|
-
icon: StarIcon,
|
|
101
|
-
svg: StarIcon,
|
|
102
|
-
tabs: SquaresFourIcon,
|
|
103
|
-
"tab-panel": SquaresFourIcon,
|
|
104
|
-
video: YoutubeLogoIcon,
|
|
105
|
-
form: ClipboardTextIcon,
|
|
106
|
-
"text-input": TextboxIcon,
|
|
107
|
-
textarea: NotePencilIcon,
|
|
108
|
-
select: TextboxIcon,
|
|
109
|
-
checkbox: CheckSquareIcon,
|
|
110
|
-
radio: RadioButtonIcon,
|
|
111
|
-
submit: PaperPlaneTiltIcon,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const withStyle = (node: LayoutNode, patch: Partial<StyleProps>): LayoutNode => {
|
|
115
|
-
const style: Record<string, unknown> = { ...node.style, ...patch };
|
|
116
|
-
for (const key of Object.keys(style)) if (style[key] === undefined) delete style[key];
|
|
117
|
-
return {
|
|
118
|
-
...node,
|
|
119
|
-
style: Object.keys(style).length > 0 ? (style as StyleProps) : undefined,
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const withDevices = (node: LayoutNode, devices: DeviceStyles | undefined): LayoutNode => {
|
|
124
|
-
const { devices: _old, ...rest } = node;
|
|
125
|
-
return (devices ? { ...rest, devices } : rest) as LayoutNode;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const withStates = (node: LayoutNode, states: StyleStates | undefined): LayoutNode => {
|
|
129
|
-
const { states: _old, ...rest } = node;
|
|
130
|
-
return (states ? { ...rest, states } : rest) as LayoutNode;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
85
|
const sectionKey = (type: string) => `emvb-style-sections:${type}`;
|
|
134
86
|
|
|
135
87
|
/**
|
|
@@ -164,11 +116,16 @@ const countSet = (type: string, style: StyleProps | undefined, section: StyleSec
|
|
|
164
116
|
const sectionHasStates = (type: string, states: StyleStates | undefined, section: StyleSectionId) =>
|
|
165
117
|
STYLE_STATES.some((state) => countSet(type, states?.[state], section) > 0);
|
|
166
118
|
|
|
167
|
-
/** Sections where a state change moves things around. */
|
|
119
|
+
/** Sections where a state change moves things around (DESIGN.md § State styles). */
|
|
168
120
|
const JUMPY = new Set<StyleSectionId>(["layout", "size", "position"]);
|
|
169
121
|
|
|
170
122
|
/** Set on Normal only (W-089, W-101, W-237); a state's Style tab leaves them out. */
|
|
171
|
-
const NORMAL_ONLY_KEYS = new Set<StyleKey>([
|
|
123
|
+
const NORMAL_ONLY_KEYS = new Set<StyleKey>([
|
|
124
|
+
"transition",
|
|
125
|
+
"entrance",
|
|
126
|
+
"iconAnimation",
|
|
127
|
+
"scrollMotion",
|
|
128
|
+
]);
|
|
172
129
|
|
|
173
130
|
const JUMP_HELP: Record<Exclude<StyleStateChoice, "normal">, string> = {
|
|
174
131
|
hover: "Changing size or position on hover can make the page jump.",
|
|
@@ -244,6 +201,8 @@ type Props = {
|
|
|
244
201
|
items?: ItemActions;
|
|
245
202
|
/** The theme part being edited, if any, for the H1 warning (W-208). */
|
|
246
203
|
partType?: ThemePartType;
|
|
204
|
+
/** Layout-wide changes from the panel, e.g. creating an A/B variant (W-312). */
|
|
205
|
+
onArrange?: (run: (layout: Layout) => Arranged) => void;
|
|
247
206
|
};
|
|
248
207
|
|
|
249
208
|
/** What an item's content is, since it has no content field of its own (W-130). */
|
|
@@ -364,6 +323,7 @@ function KnownElementPanel({
|
|
|
364
323
|
items,
|
|
365
324
|
partType,
|
|
366
325
|
descriptor,
|
|
326
|
+
onArrange,
|
|
367
327
|
}: Props & { descriptor: ElementDescriptor }) {
|
|
368
328
|
const ui = STYLE_UI[node.type] ?? DEFAULT_UI;
|
|
369
329
|
const [tab, setTab] = React.useState(descriptor.defaultTab);
|
|
@@ -384,7 +344,7 @@ function KnownElementPanel({
|
|
|
384
344
|
: styleState === "normal"
|
|
385
345
|
? normal
|
|
386
346
|
: states?.[styleState];
|
|
387
|
-
const
|
|
347
|
+
const ownInherited = responsive
|
|
388
348
|
? {
|
|
389
349
|
...normal,
|
|
390
350
|
...(responsive === "mobile" ? ownerDevices?.tablet : undefined),
|
|
@@ -392,16 +352,30 @@ function KnownElementPanel({
|
|
|
392
352
|
: styleState === "normal"
|
|
393
353
|
? undefined
|
|
394
354
|
: normal;
|
|
355
|
+
// W-318: an element's own styles sit on its classes and its tag's Site styles default, so the
|
|
356
|
+
// controls show what those give as the inherited value.
|
|
357
|
+
const fromBelow = cls ? undefined : inheritedStyle(node, design, device, styleState);
|
|
358
|
+
const inherited =
|
|
359
|
+
fromBelow && Object.keys(fromBelow).length > 0
|
|
360
|
+
? { ...fromBelow, ...ownInherited }
|
|
361
|
+
: ownInherited;
|
|
395
362
|
const position = positionInEffect(node, design, cls);
|
|
396
363
|
const iconSvg =
|
|
397
364
|
node.type === "icon" && typeof node.props.iconSvg === "string" ? node.props.iconSvg : undefined;
|
|
398
|
-
const strokeAdjustable =
|
|
365
|
+
const strokeAdjustable = React.useMemo(
|
|
366
|
+
() => (node.type === "icon" && !cls ? iconHasAdjustableStroke(iconSvg) : true),
|
|
367
|
+
[node.type, cls, iconSvg],
|
|
368
|
+
);
|
|
369
|
+
const ownColors = React.useMemo(
|
|
370
|
+
() => node.type === "icon" && iconHasOwnColors(iconSvg),
|
|
371
|
+
[node.type, iconSvg],
|
|
372
|
+
);
|
|
399
373
|
const singleColorOffered =
|
|
400
374
|
node.type === "icon" &&
|
|
401
375
|
!cls &&
|
|
402
376
|
!responsive &&
|
|
403
377
|
styleState === "normal" &&
|
|
404
|
-
(node.props.singleColor === true ||
|
|
378
|
+
(node.props.singleColor === true || ownColors);
|
|
405
379
|
// W-296: elsewhere (Hover, Focus, a device) Colour does nothing on such an SVG until Force single
|
|
406
380
|
// colour is on, and that switch only lives in Normal on Desktop, so say so there.
|
|
407
381
|
const colorIgnoredHere =
|
|
@@ -409,36 +383,22 @@ function KnownElementPanel({
|
|
|
409
383
|
!cls &&
|
|
410
384
|
!singleColorOffered &&
|
|
411
385
|
node.props.singleColor !== true &&
|
|
412
|
-
|
|
386
|
+
ownColors;
|
|
413
387
|
const patchStyle = (patch: Partial<StyleProps>) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
);
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
const state = styleState;
|
|
428
|
-
if (!cls) {
|
|
429
|
-
onChange(
|
|
430
|
-
state === "normal"
|
|
431
|
-
? withStyle(node, patch)
|
|
432
|
-
: withStates(node, patchStates(node.states, state, patch)),
|
|
433
|
-
);
|
|
388
|
+
const written = applyStylePatch({
|
|
389
|
+
node,
|
|
390
|
+
design,
|
|
391
|
+
classId: cls ? cls.id : null,
|
|
392
|
+
device,
|
|
393
|
+
state: styleState,
|
|
394
|
+
patch,
|
|
395
|
+
});
|
|
396
|
+
if (written.kind === "node") {
|
|
397
|
+
onChange(written.node);
|
|
434
398
|
return;
|
|
435
399
|
}
|
|
436
400
|
setDesignError(null);
|
|
437
|
-
|
|
438
|
-
state === "normal"
|
|
439
|
-
? patchClassStyle(design, cls.id, patch)
|
|
440
|
-
: patchClassState(design, cls.id, state, patch);
|
|
441
|
-
onDesignChange(next).catch((error: unknown) =>
|
|
401
|
+
onDesignChange(written.design).catch((error: unknown) =>
|
|
442
402
|
setDesignError(
|
|
443
403
|
error instanceof Error ? error.message : "Couldn't save the class. Try again.",
|
|
444
404
|
),
|
|
@@ -450,7 +410,7 @@ function KnownElementPanel({
|
|
|
450
410
|
const bodyRef = React.useRef<HTMLDivElement>(null);
|
|
451
411
|
useTabScroll(bodyRef, tab, node.id);
|
|
452
412
|
|
|
453
|
-
const Icon =
|
|
413
|
+
const Icon = elementIcon(node.type);
|
|
454
414
|
const crumbs = breadcrumb(layout, node.id);
|
|
455
415
|
const section = (
|
|
456
416
|
id: StyleSectionId,
|
|
@@ -536,6 +496,14 @@ function KnownElementPanel({
|
|
|
536
496
|
/>
|
|
537
497
|
))
|
|
538
498
|
)}
|
|
499
|
+
<BindingsEditor node={node} onChange={onChange} post={SAMPLE_POST} />
|
|
500
|
+
<AudienceEditor node={node} isRoot={layout?.root.id === node.id} onChange={onChange} />
|
|
501
|
+
<VariantEditor
|
|
502
|
+
node={node}
|
|
503
|
+
isRoot={layout?.root.id === node.id}
|
|
504
|
+
onChange={onChange}
|
|
505
|
+
onArrange={onArrange}
|
|
506
|
+
/>
|
|
539
507
|
{ITEM_NOTES[node.type] && <p className="emvb-helper">{ITEM_NOTES[node.type]}</p>}
|
|
540
508
|
{svgImagesLeftOut(node) > 0 && (
|
|
541
509
|
<p className="emvb-helper" data-emvb-svg-images>
|
|
@@ -604,6 +572,7 @@ function KnownElementPanel({
|
|
|
604
572
|
These override Desktop. State styles apply on every device.
|
|
605
573
|
</p>
|
|
606
574
|
)}
|
|
575
|
+
{!cls && <StyleSources node={node} design={design} device={device} state={styleState} />}
|
|
607
576
|
{designError && <Alert>{designError}</Alert>}
|
|
608
577
|
{!cls && styleState === "normal" && node.type === "spacer" && (
|
|
609
578
|
<FieldControl field={SPACER_HEIGHT} node={node} onChange={onChange} fetcher={fetcher} />
|
|
@@ -616,6 +585,8 @@ function KnownElementPanel({
|
|
|
616
585
|
(node.htmlId ? 1 : 0) + (node.attributes?.length ?? 0),
|
|
617
586
|
<>
|
|
618
587
|
<HtmlIdField node={node} layout={layout} onChange={onChange} />
|
|
588
|
+
<DirectionField node={node} onChange={onChange} />
|
|
589
|
+
{"children" in node && <ContainerQueryFields node={node} onChange={onChange} />}
|
|
619
590
|
<AttributesEditor
|
|
620
591
|
attributes={node.attributes}
|
|
621
592
|
onChange={(attributes) => onChange({ ...node, attributes })}
|
|
@@ -758,16 +729,17 @@ function breadcrumb(
|
|
|
758
729
|
id: string,
|
|
759
730
|
): Array<{ id: string | null; label: string }> {
|
|
760
731
|
if (!layout) return [];
|
|
732
|
+
const index = indexLayout(layout);
|
|
761
733
|
const chain: Array<{ id: string; label: string }> = [];
|
|
762
734
|
let current: string | undefined = id;
|
|
763
735
|
while (current) {
|
|
764
|
-
const node =
|
|
736
|
+
const node = index.byId.get(current);
|
|
765
737
|
if (!node) break;
|
|
766
738
|
chain.unshift({
|
|
767
739
|
id: node.id,
|
|
768
740
|
label: ELEMENT_NAMES[node.type] ?? node.type,
|
|
769
741
|
});
|
|
770
|
-
current = parentOf(
|
|
742
|
+
current = index.parentOf.get(current);
|
|
771
743
|
}
|
|
772
744
|
return [{ id: null, label: "Page" }, ...chain];
|
|
773
745
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CaretDownIcon,
|
|
3
|
-
CaretRightIcon,
|
|
4
|
-
RowsIcon,
|
|
5
|
-
SquaresFourIcon,
|
|
6
|
-
TextHIcon,
|
|
7
|
-
} from "@phosphor-icons/react";
|
|
1
|
+
import { CaretDownIcon, CaretRightIcon } from "@phosphor-icons/react";
|
|
8
2
|
import * as React from "react";
|
|
9
3
|
import {
|
|
10
4
|
firstChild,
|
|
@@ -15,24 +9,19 @@ import {
|
|
|
15
9
|
previousInOrder,
|
|
16
10
|
type Layout,
|
|
17
11
|
type LayoutNode,
|
|
12
|
+
nodeScript,
|
|
13
|
+
audienceSummary,
|
|
14
|
+
SCRIPT_LABELS,
|
|
15
|
+
type PageScript,
|
|
18
16
|
} from "../../../core/index.ts";
|
|
17
|
+
import { indexLayout } from "../../../core/tree-ops.ts";
|
|
19
18
|
import { EXISTING_ELEMENT_MIME } from "../dnd/drop-target.ts";
|
|
20
|
-
import { ELEMENT_NAMES } from "
|
|
19
|
+
import { ELEMENT_NAMES, elementIcon } from "../element-chrome.ts";
|
|
20
|
+
import { editorCommands } from "../editor-commands.ts";
|
|
21
21
|
import { dragStash } from "../dnd/drag-stash.ts";
|
|
22
22
|
import { StateDot } from "./settings/StateSwitcher.tsx";
|
|
23
23
|
import type { ClipboardActions } from "../useClipboardActions.ts";
|
|
24
24
|
|
|
25
|
-
const ICONS: Record<string, typeof TextHIcon> = {
|
|
26
|
-
heading: TextHIcon,
|
|
27
|
-
container: SquaresFourIcon,
|
|
28
|
-
svg: SquaresFourIcon,
|
|
29
|
-
tabs: SquaresFourIcon,
|
|
30
|
-
"tab-panel": SquaresFourIcon,
|
|
31
|
-
"div-block": SquaresFourIcon,
|
|
32
|
-
"layout-section": RowsIcon,
|
|
33
|
-
flexbox: SquaresFourIcon,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
25
|
const rows = (
|
|
37
26
|
node: LayoutNode,
|
|
38
27
|
depth: number,
|
|
@@ -67,6 +56,20 @@ const pasteHint = (clip: ClipboardActions | undefined) =>
|
|
|
67
56
|
clip ? (clip.pasteStyleBlocked ?? clip.pasteBlocked) : null;
|
|
68
57
|
|
|
69
58
|
/** The ··· menu: clipboard items, then Duplicate and the moves; the root row gets what applies to it. */
|
|
59
|
+
/** W-311: an element that makes the page load a script says so; everything else is zero-JS. */
|
|
60
|
+
function JsBadge({ script }: { script: PageScript | undefined }) {
|
|
61
|
+
if (!script) return null;
|
|
62
|
+
return (
|
|
63
|
+
<span
|
|
64
|
+
className="emvb-js-badge"
|
|
65
|
+
title={`Adds a script: ${SCRIPT_LABELS[script]}`}
|
|
66
|
+
aria-hidden="true"
|
|
67
|
+
>
|
|
68
|
+
JS
|
|
69
|
+
</span>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
70
73
|
function menuItems(
|
|
71
74
|
node: LayoutNode,
|
|
72
75
|
isRoot: boolean,
|
|
@@ -74,47 +77,33 @@ function menuItems(
|
|
|
74
77
|
clip: ClipboardActions | undefined,
|
|
75
78
|
rename: () => void,
|
|
76
79
|
): MenuItem[] {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{ label: "Copy style", run: clip.copyStyle },
|
|
105
|
-
{ label: "Paste style", run: clip.pasteStyle, disabled: !!clip.pasteStyleBlocked },
|
|
106
|
-
]
|
|
107
|
-
: [];
|
|
108
|
-
if (isRoot) return [...naming, ...clipboard, ...style];
|
|
109
|
-
return [
|
|
110
|
-
...naming,
|
|
111
|
-
...clipboard,
|
|
112
|
-
{ label: "Duplicate", run: actions.onDuplicate },
|
|
113
|
-
...style,
|
|
114
|
-
{ label: "Move up", run: actions.onMoveUp },
|
|
115
|
-
{ label: "Move down", run: actions.onMoveDown },
|
|
116
|
-
{ label: "Delete", run: actions.onDelete, className: "emvb-danger-text" },
|
|
117
|
-
];
|
|
80
|
+
return editorCommands({
|
|
81
|
+
surface: "layers",
|
|
82
|
+
targetId: node.id,
|
|
83
|
+
isRoot,
|
|
84
|
+
isParent: isParentNode(node),
|
|
85
|
+
device: "desktop",
|
|
86
|
+
canDuplicate: !isRoot,
|
|
87
|
+
canDelete: !isRoot,
|
|
88
|
+
runners: {
|
|
89
|
+
rename: actions.onRename ? rename : undefined,
|
|
90
|
+
duplicate: actions.onDuplicate,
|
|
91
|
+
remove: actions.onDelete,
|
|
92
|
+
moveUp: actions.onMoveUp,
|
|
93
|
+
moveDown: actions.onMoveDown,
|
|
94
|
+
copy: clip?.copy,
|
|
95
|
+
paste: clip?.paste,
|
|
96
|
+
copyStyle: clip?.copyStyle,
|
|
97
|
+
pasteStyle: clip?.pasteStyle,
|
|
98
|
+
pasteBlocked: clip?.pasteBlocked,
|
|
99
|
+
pasteStyleBlocked: clip?.pasteStyleBlocked,
|
|
100
|
+
},
|
|
101
|
+
}).map((command) => ({
|
|
102
|
+
label: command.label,
|
|
103
|
+
run: () => command.run(),
|
|
104
|
+
disabled: command.disabled,
|
|
105
|
+
className: command.danger ? "emvb-danger-text" : undefined,
|
|
106
|
+
}));
|
|
118
107
|
}
|
|
119
108
|
|
|
120
109
|
/** What a key does in the tree: select another row, toggle the selected one, or nothing. */
|
|
@@ -162,7 +151,7 @@ function focusSelectedRow(tree: Element | null): void {
|
|
|
162
151
|
|
|
163
152
|
/** Layers list (IA / W-018): tree with collapse, keyboard navigation, auto-expand to selection. */
|
|
164
153
|
|
|
165
|
-
/** Props whose text tells same-type elements apart in Layers (
|
|
154
|
+
/** Props whose text tells same-type elements apart in Layers (DESIGN.md, layer-row preview; W-143). */
|
|
166
155
|
const PREVIEW_PROP: Partial<Record<string, string>> = {
|
|
167
156
|
heading: "text",
|
|
168
157
|
text: "text",
|
|
@@ -224,10 +213,11 @@ export function LayersPanel({
|
|
|
224
213
|
if (!layout || !selectedId) return;
|
|
225
214
|
setCollapsed((current) => {
|
|
226
215
|
const next = new Set(current);
|
|
216
|
+
const parents = indexLayout(layout).parentOf;
|
|
227
217
|
let id: string | undefined = selectedId;
|
|
228
218
|
while (id) {
|
|
229
219
|
next.delete(id);
|
|
230
|
-
id =
|
|
220
|
+
id = parents.get(id);
|
|
231
221
|
}
|
|
232
222
|
return next;
|
|
233
223
|
});
|
|
@@ -327,7 +317,7 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
327
317
|
}) {
|
|
328
318
|
const onToggle = () => toggleRow(node.id);
|
|
329
319
|
const onMenu = (open: boolean) => menuRow(node.id, open);
|
|
330
|
-
const Icon =
|
|
320
|
+
const Icon = elementIcon(node.type);
|
|
331
321
|
const preview = layerPreview(node);
|
|
332
322
|
const typeName = ELEMENT_NAMES[node.type] ?? node.type;
|
|
333
323
|
// A label names the row in place of the type (W-157); the type stays in the tooltip.
|
|
@@ -476,6 +466,25 @@ const LayerRow = React.memo(function LayerRow({
|
|
|
476
466
|
<span className="emvb-layer-name">{name}</span>
|
|
477
467
|
{preview ? <span className="emvb-layer-preview">{preview}</span> : null}
|
|
478
468
|
{hasStateStyles(node) && <StateDot />}
|
|
469
|
+
<JsBadge script={nodeScript(node)} />
|
|
470
|
+
{node.audience && (
|
|
471
|
+
<span
|
|
472
|
+
className="emvb-js-badge emvb-ab-badge"
|
|
473
|
+
title={audienceSummary(node.audience)}
|
|
474
|
+
aria-hidden="true"
|
|
475
|
+
>
|
|
476
|
+
◎
|
|
477
|
+
</span>
|
|
478
|
+
)}
|
|
479
|
+
{node.variant && (
|
|
480
|
+
<span
|
|
481
|
+
className="emvb-js-badge emvb-ab-badge"
|
|
482
|
+
title={`A/B test ${node.variant.test}, variant ${node.variant.arm.toUpperCase()}`}
|
|
483
|
+
aria-hidden="true"
|
|
484
|
+
>
|
|
485
|
+
{node.variant.arm.toUpperCase()}
|
|
486
|
+
</span>
|
|
487
|
+
)}
|
|
479
488
|
</button>
|
|
480
489
|
)}
|
|
481
490
|
{(!isRoot || hasClipboard) && (
|
|
@@ -13,6 +13,7 @@ export function LeftPanel({
|
|
|
13
13
|
selectedId,
|
|
14
14
|
onSelect,
|
|
15
15
|
onAdd,
|
|
16
|
+
onRecipe,
|
|
16
17
|
onDuplicate,
|
|
17
18
|
onMoveUp,
|
|
18
19
|
onMoveDown,
|
|
@@ -25,6 +26,8 @@ export function LeftPanel({
|
|
|
25
26
|
selectedId: string | null;
|
|
26
27
|
onSelect: (id: string) => void;
|
|
27
28
|
onAdd: (type: ElementType) => void;
|
|
29
|
+
/** Adds a section recipe (W-320). */
|
|
30
|
+
onRecipe?: (id: string) => void;
|
|
28
31
|
onDuplicate: (id: string) => void;
|
|
29
32
|
onMoveUp: (id: string) => void;
|
|
30
33
|
onMoveDown: (id: string) => void;
|
|
@@ -62,7 +65,7 @@ export function LeftPanel({
|
|
|
62
65
|
onValueChange={changeTab}
|
|
63
66
|
/>
|
|
64
67
|
{tab === "add" ? (
|
|
65
|
-
<AddPanel onAdd={onAdd} formsAvailable={formsAvailable} />
|
|
68
|
+
<AddPanel onAdd={onAdd} onRecipe={onRecipe} formsAvailable={formsAvailable} />
|
|
66
69
|
) : (
|
|
67
70
|
<LayersPanel
|
|
68
71
|
layout={layout}
|
|
@@ -66,6 +66,7 @@ export function SettingsPanel({
|
|
|
66
66
|
layout={state.page.layout}
|
|
67
67
|
onDesignChange={onDesignChange}
|
|
68
68
|
unpublished={state.designUnpublished === true}
|
|
69
|
+
published={state.publishedDesign}
|
|
69
70
|
onPublishStyles={onPublishStyles}
|
|
70
71
|
{...(onDesignItemDeleted ? { onDeleted: onDesignItemDeleted } : {})}
|
|
71
72
|
onLayoutChange={(layout) =>
|
|
@@ -95,6 +96,18 @@ export function SettingsPanel({
|
|
|
95
96
|
device={device}
|
|
96
97
|
items={items}
|
|
97
98
|
partType={state.page.partType}
|
|
99
|
+
onArrange={(run) => {
|
|
100
|
+
const layout = state.page.layout;
|
|
101
|
+
if (!layout) return;
|
|
102
|
+
const result = run(layout);
|
|
103
|
+
if (result.ok) {
|
|
104
|
+
dispatch({
|
|
105
|
+
type: "apply-arranged",
|
|
106
|
+
layout: result.layout,
|
|
107
|
+
selected: result.selected,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}}
|
|
98
111
|
/>
|
|
99
112
|
) : (
|
|
100
113
|
<PageSettings
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Button, Select, Tabs } from "@cloudflare/kumo";
|
|
2
2
|
import { deletionOf, type Deletion } from "../restore-deleted.ts";
|
|
3
|
-
import {
|
|
3
|
+
import { XIcon } from "@phosphor-icons/react";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import {
|
|
6
6
|
clearClassRefs,
|
|
7
7
|
deleteVariable,
|
|
8
|
+
designChangeLabel,
|
|
9
|
+
designChanges,
|
|
8
10
|
designFromJson,
|
|
9
11
|
designToJson,
|
|
10
12
|
findClassUsages,
|
|
@@ -26,6 +28,8 @@ import { ClassesSection } from "./ClassesSection.tsx";
|
|
|
26
28
|
import { stopEditorShortcuts } from "./settings/ClassChip.tsx";
|
|
27
29
|
import { StyleRow } from "./settings/StyleRow.tsx";
|
|
28
30
|
import { FIELD } from "../../ui.ts";
|
|
31
|
+
import { TokenScales } from "./TokenScales.tsx";
|
|
32
|
+
import { InlineError } from "./inline-error.tsx";
|
|
29
33
|
import { VariableSection } from "./VariableSection.tsx";
|
|
30
34
|
|
|
31
35
|
const STYLE_NOTE = "Style changes stay unpublished until you publish styles.";
|
|
@@ -35,6 +39,8 @@ type Props = {
|
|
|
35
39
|
layout: Layout | null;
|
|
36
40
|
onDesignChange: (design: DesignSystem) => Promise<void>;
|
|
37
41
|
unpublished?: boolean;
|
|
42
|
+
/** Published design. With `unpublished`, the drawer lists what Publish styles will change. */
|
|
43
|
+
published?: DesignSystem;
|
|
38
44
|
onPublishStyles?: () => Promise<void>;
|
|
39
45
|
onLayoutChange: (layout: Layout) => void;
|
|
40
46
|
/** W-252: called with what a delete removes, before the page loses its uses. */
|
|
@@ -42,15 +48,6 @@ type Props = {
|
|
|
42
48
|
onClose: () => void;
|
|
43
49
|
};
|
|
44
50
|
|
|
45
|
-
function InlineError({ children }: { children: string }) {
|
|
46
|
-
return (
|
|
47
|
-
<p className="emvb-inline-error" role="alert">
|
|
48
|
-
<WarningCircleIcon size={16} aria-hidden="true" />
|
|
49
|
-
{children}
|
|
50
|
-
</p>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
51
|
function exportDesign(design: DesignSystem) {
|
|
55
52
|
const blob = new Blob([designToJson(design)], { type: "application/json" });
|
|
56
53
|
const url = URL.createObjectURL(blob);
|
|
@@ -70,6 +67,7 @@ export function SiteStylesDrawer({
|
|
|
70
67
|
layout,
|
|
71
68
|
onDesignChange,
|
|
72
69
|
unpublished = false,
|
|
70
|
+
published,
|
|
73
71
|
onPublishStyles,
|
|
74
72
|
onLayoutChange,
|
|
75
73
|
onDeleted,
|
|
@@ -159,6 +157,15 @@ export function SiteStylesDrawer({
|
|
|
159
157
|
aria-label="Site styles actions"
|
|
160
158
|
data-emvb-site-styles-actions=""
|
|
161
159
|
>
|
|
160
|
+
{unpublished && published && (
|
|
161
|
+
<ul className="emvb-helper" data-emvb-style-diff="">
|
|
162
|
+
{designChanges(published, design).map((change) => (
|
|
163
|
+
<li key={`${change.kind}:${change.what}:${change.name}`}>
|
|
164
|
+
{designChangeLabel(change)}
|
|
165
|
+
</li>
|
|
166
|
+
))}
|
|
167
|
+
</ul>
|
|
168
|
+
)}
|
|
162
169
|
{unpublished && (
|
|
163
170
|
<Button type="button" variant="primary" size="sm" onClick={() => void publish()}>
|
|
164
171
|
Publish styles
|
|
@@ -244,6 +251,7 @@ export function SiteStylesDrawer({
|
|
|
244
251
|
setConfirm({ kind: "variable", variableKind: "spacing", id, name })
|
|
245
252
|
}
|
|
246
253
|
/>
|
|
254
|
+
<TokenScales design={design} onSave={save} />
|
|
247
255
|
</div>
|
|
248
256
|
)}
|
|
249
257
|
{tab === "classes" && (
|