@perkyzz/emvb 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +57 -2
- package/package.json +72 -4
- package/src/admin/access/RequireEditor.tsx +39 -0
- package/src/admin/access/role.ts +36 -0
- package/src/admin/access/sidebar-shim.ts +108 -0
- package/src/admin/api.ts +48 -0
- package/src/admin/content-api.ts +147 -0
- package/src/admin/editor/Editor.tsx +457 -0
- package/src/admin/editor/EditorOverlay.tsx +54 -0
- package/src/admin/editor/ShortcutsDialog.tsx +30 -0
- package/src/admin/editor/SmallScreenNotice.tsx +20 -0
- package/src/admin/editor/TopBar.tsx +179 -0
- package/src/admin/editor/canvas/CanvasFrame.tsx +355 -0
- package/src/admin/editor/canvas/CanvasTextEdit.tsx +87 -0
- package/src/admin/editor/canvas/DeviceBar.tsx +50 -0
- package/src/admin/editor/canvas/EmptyCanvas.tsx +49 -0
- package/src/admin/editor/canvas/SelectionOverlay.tsx +185 -0
- package/src/admin/editor/canvas/canvas-events.ts +232 -0
- package/src/admin/editor/canvas/state-preview.ts +19 -0
- package/src/admin/editor/canvas/tab-reveal.ts +35 -0
- package/src/admin/editor/canvas/vnode-react.tsx +49 -0
- package/src/admin/editor/clipboard-store.ts +44 -0
- package/src/admin/editor/dialogs.tsx +125 -0
- package/src/admin/editor/dnd/drag-stash.ts +27 -0
- package/src/admin/editor/dnd/drop-target.ts +101 -0
- package/src/admin/editor/dnd/new-element.ts +32 -0
- package/src/admin/editor/editor-css.ts +539 -0
- package/src/admin/editor/exit.ts +27 -0
- package/src/admin/editor/panels/AddPanel.tsx +142 -0
- package/src/admin/editor/panels/ClassesSection.tsx +334 -0
- package/src/admin/editor/panels/ColorControl.tsx +230 -0
- package/src/admin/editor/panels/ConditionsEditor.tsx +201 -0
- package/src/admin/editor/panels/ElementPanel.tsx +629 -0
- package/src/admin/editor/panels/LayersPanel.tsx +336 -0
- package/src/admin/editor/panels/LeftPanel.tsx +77 -0
- package/src/admin/editor/panels/PageSettings.tsx +126 -0
- package/src/admin/editor/panels/SettingsPanel.tsx +101 -0
- package/src/admin/editor/panels/SiteStylesDrawer.tsx +392 -0
- package/src/admin/editor/panels/TriggerSettings.tsx +132 -0
- package/src/admin/editor/panels/TriggersEditor.tsx +197 -0
- package/src/admin/editor/panels/VariableSection.tsx +492 -0
- package/src/admin/editor/panels/settings/BackgroundControls.tsx +320 -0
- package/src/admin/editor/panels/settings/ClassChip.tsx +167 -0
- package/src/admin/editor/panels/settings/ClassChipInput.tsx +349 -0
- package/src/admin/editor/panels/settings/DraftTextField.tsx +201 -0
- package/src/admin/editor/panels/settings/EffectsControls.tsx +347 -0
- package/src/admin/editor/panels/settings/FieldBindControl.tsx +83 -0
- package/src/admin/editor/panels/settings/FieldControl.tsx +150 -0
- package/src/admin/editor/panels/settings/FormBindControl.tsx +97 -0
- package/src/admin/editor/panels/settings/IconPicker.tsx +109 -0
- package/src/admin/editor/panels/settings/LengthRow.tsx +181 -0
- package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +124 -0
- package/src/admin/editor/panels/settings/MediaPicker.tsx +218 -0
- package/src/admin/editor/panels/settings/NumberRow.tsx +154 -0
- package/src/admin/editor/panels/settings/StateSwitcher.tsx +87 -0
- package/src/admin/editor/panels/settings/StyleRow.tsx +480 -0
- package/src/admin/editor/panels/settings/VariableBinding.tsx +167 -0
- package/src/admin/editor/panels/settings/class-suggest.ts +51 -0
- package/src/admin/editor/panels/settings/length-units.ts +83 -0
- package/src/admin/editor/panels/settings/node-props.ts +11 -0
- package/src/admin/editor/panels/settings/style-sections.ts +291 -0
- package/src/admin/editor/panels/site-list.tsx +206 -0
- package/src/admin/editor/panels/variable-values.ts +73 -0
- package/src/admin/editor/section-templates.ts +50 -0
- package/src/admin/editor/shortcuts.ts +20 -0
- package/src/admin/editor/store.ts +212 -0
- package/src/admin/editor/useClipboardActions.ts +136 -0
- package/src/admin/editor/useEditorCommands.ts +142 -0
- package/src/admin/editor/useEditorData.ts +167 -0
- package/src/admin/editor/useEditorShortcuts.ts +148 -0
- package/src/admin/editor/useMediaQuery.ts +20 -0
- package/src/admin/editor/useNodeActions.ts +122 -0
- package/src/admin/editor/useSave.ts +185 -0
- package/src/admin/forms-api.ts +73 -0
- package/src/admin/index.tsx +20 -0
- package/src/admin/media-api.ts +68 -0
- package/src/admin/pages/CreateDialog.tsx +150 -0
- package/src/admin/pages/EditorPage.tsx +57 -0
- package/src/admin/pages/NewPageDialog.tsx +83 -0
- package/src/admin/pages/NewThemePartDialog.tsx +61 -0
- package/src/admin/pages/PageList.tsx +71 -0
- package/src/admin/pages/PagesPage.tsx +25 -0
- package/src/admin/pages/SetupShell.tsx +90 -0
- package/src/admin/pages/ThemeBuilderPage.tsx +25 -0
- package/src/admin/pages/ThemePartList.tsx +202 -0
- package/src/admin/pages/list-kit.tsx +75 -0
- package/src/admin/setup/plan.ts +150 -0
- package/src/admin/setup/run.ts +61 -0
- package/src/admin/setup/spec.ts +100 -0
- package/src/admin/setup/useSetupStatus.ts +62 -0
- package/src/admin/theme-api.ts +186 -0
- package/src/admin/ui.ts +231 -0
- package/src/admin/widgets/LayoutField.tsx +67 -0
- package/src/astro/EmVBPage.astro +37 -0
- package/src/astro/env.d.ts +5 -0
- package/src/astro/forms/EmVBFormsRuntime.astro +9 -0
- package/src/astro/forms/index.ts +1 -0
- package/src/astro/forms-definitions.ts +104 -0
- package/src/astro/index.ts +15 -0
- package/src/astro/popups/EmVBPopupsRuntime.astro +9 -0
- package/src/astro/popups/index.ts +1 -0
- package/src/astro/popups/runtime.ts +246 -0
- package/src/astro/render.ts +74 -0
- package/src/astro/resolve-theme.ts +371 -0
- package/src/astro/resolve.ts +65 -0
- package/src/astro/tabs/EmVBTabsRuntime.astro +10 -0
- package/src/astro/tabs/index.ts +1 -0
- package/src/astro/tabs/runtime.ts +111 -0
- package/src/astro/theme-context.ts +81 -0
- package/src/astro/theme-posts.ts +84 -0
- package/src/constants.ts +12 -0
- package/src/core/arrange.ts +360 -0
- package/src/core/clipboard.ts +422 -0
- package/src/core/css/generate.ts +219 -0
- package/src/core/css/scope.ts +88 -0
- package/src/core/design/cascade.ts +28 -0
- package/src/core/design/classes.ts +138 -0
- package/src/core/design/devices.ts +56 -0
- package/src/core/design/states.ts +49 -0
- package/src/core/design/transfer.ts +33 -0
- package/src/core/design/variables.ts +319 -0
- package/src/core/elements/definition.ts +12 -0
- package/src/core/elements/dynamic-elements.ts +173 -0
- package/src/core/elements/form-elements.ts +204 -0
- package/src/core/elements/index.ts +742 -0
- package/src/core/elements/plain-text.ts +32 -0
- package/src/core/forms/binding.ts +61 -0
- package/src/core/forms/definition.ts +34 -0
- package/src/core/forms/success-layout.ts +63 -0
- package/src/core/icons/catalog.ts +273 -0
- package/src/core/index.ts +316 -0
- package/src/core/limits.ts +7 -0
- package/src/core/migrate/index.ts +76 -0
- package/src/core/render/context.ts +14 -0
- package/src/core/render/dynamic-post.ts +147 -0
- package/src/core/render/extras.ts +79 -0
- package/src/core/render/form.ts +137 -0
- package/src/core/render/index.ts +274 -0
- package/src/core/render/loop.ts +36 -0
- package/src/core/render/section.ts +33 -0
- package/src/core/render/tabs.ts +72 -0
- package/src/core/render/vnode.ts +87 -0
- package/src/core/sanitize/css.ts +591 -0
- package/src/core/sanitize/embed-url.ts +103 -0
- package/src/core/sanitize/escape.ts +10 -0
- package/src/core/sanitize/href.ts +6 -0
- package/src/core/sanitize/media-url.ts +7 -0
- package/src/core/sanitize/svg.ts +293 -0
- package/src/core/sanitize/url.ts +31 -0
- package/src/core/schema/descriptors.ts +33 -0
- package/src/core/schema/design.ts +88 -0
- package/src/core/schema/layout.ts +817 -0
- package/src/core/schema/state-names.ts +4 -0
- package/src/core/schema/style.ts +257 -0
- package/src/core/stats.ts +18 -0
- package/src/core/tabs/presence.ts +16 -0
- package/src/core/theme/conditions.ts +321 -0
- package/src/core/theme/dynamic.ts +133 -0
- package/src/core/theme/parse-doc.ts +36 -0
- package/src/core/theme/part-types.ts +79 -0
- package/src/core/theme/popup-markup.ts +39 -0
- package/src/core/theme/popup-rules.ts +61 -0
- package/src/core/theme/triggers.ts +104 -0
- package/src/core/tree-ops.ts +139 -0
- package/src/core/validate.ts +185 -0
- package/src/index.ts +18 -0
- package/src/server/design-routes.ts +125 -0
- package/src/server/hooks.ts +98 -0
- package/src/server/plugin.ts +39 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PAGES_COLLECTION, PLUGIN_ID, THEME_PARTS_COLLECTION } from "../../constants.ts";
|
|
2
|
+
import { THEME_PART_TYPES } from "../../core/index.ts";
|
|
3
|
+
|
|
4
|
+
export const LAYOUT_WIDGET = `${PLUGIN_ID}:layout`;
|
|
5
|
+
const CANVAS_MODES = ["site-layout", "blank"] as const;
|
|
6
|
+
const PART_TYPES = THEME_PART_TYPES;
|
|
7
|
+
|
|
8
|
+
/** The `emvb_pages` collection EmVB owns (D-012, D-019). Setup converges the site to exactly this. */
|
|
9
|
+
export const COLLECTION_SPEC = {
|
|
10
|
+
slug: PAGES_COLLECTION,
|
|
11
|
+
label: "Visual pages",
|
|
12
|
+
labelSingular: "Visual page",
|
|
13
|
+
hidden: true,
|
|
14
|
+
supports: ["drafts", "revisions", "preview"],
|
|
15
|
+
hasSeo: true,
|
|
16
|
+
/** Where published pages live. Set on creation only, so a host's own pattern is kept on upgrade. */
|
|
17
|
+
urlPattern: "/{slug}",
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Theme parts (headers/footers + content templates + popups). Hidden, no SEO, no public
|
|
22
|
+
* urlPattern so they never become pages (D-TB-03).
|
|
23
|
+
*/
|
|
24
|
+
export const THEME_PARTS_COLLECTION_SPEC = {
|
|
25
|
+
slug: THEME_PARTS_COLLECTION,
|
|
26
|
+
label: "Theme parts",
|
|
27
|
+
labelSingular: "Theme part",
|
|
28
|
+
hidden: true,
|
|
29
|
+
supports: ["drafts", "revisions", "preview"],
|
|
30
|
+
hasSeo: false,
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
export type FieldSpec = {
|
|
34
|
+
slug: string;
|
|
35
|
+
label: string;
|
|
36
|
+
type: "string" | "json" | "select";
|
|
37
|
+
required?: boolean;
|
|
38
|
+
widget?: string;
|
|
39
|
+
validation: { options?: string[] } | null;
|
|
40
|
+
defaultValue?: unknown;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const FIELD_SPECS: readonly FieldSpec[] = [
|
|
44
|
+
{ slug: "title", label: "Title", type: "string", required: true, validation: null },
|
|
45
|
+
{ slug: "layout", label: "Layout", type: "json", widget: LAYOUT_WIDGET, validation: null },
|
|
46
|
+
{
|
|
47
|
+
slug: "canvas_mode",
|
|
48
|
+
label: "Canvas mode",
|
|
49
|
+
type: "select",
|
|
50
|
+
validation: { options: [...CANVAS_MODES] },
|
|
51
|
+
defaultValue: "site-layout",
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** Default conditions: Include → Entire Site (Elementor-like). */
|
|
56
|
+
const DEFAULT_THEME_CONDITIONS = {
|
|
57
|
+
schemaVersion: 1,
|
|
58
|
+
rules: [
|
|
59
|
+
{
|
|
60
|
+
id: "default-entire-site",
|
|
61
|
+
op: "include",
|
|
62
|
+
group: "general",
|
|
63
|
+
name: "entire_site",
|
|
64
|
+
args: {},
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
} as const;
|
|
68
|
+
|
|
69
|
+
/** Default popup triggers: open on page load (Elementor-like). */
|
|
70
|
+
const DEFAULT_THEME_TRIGGERS = {
|
|
71
|
+
schemaVersion: 1,
|
|
72
|
+
open: [{ type: "page_load" }],
|
|
73
|
+
advanced: {},
|
|
74
|
+
} as const;
|
|
75
|
+
|
|
76
|
+
export const THEME_PARTS_FIELD_SPECS: readonly FieldSpec[] = [
|
|
77
|
+
{ slug: "title", label: "Title", type: "string", required: true, validation: null },
|
|
78
|
+
{ slug: "layout", label: "Layout", type: "json", widget: LAYOUT_WIDGET, validation: null },
|
|
79
|
+
{
|
|
80
|
+
slug: "part_type",
|
|
81
|
+
label: "Part type",
|
|
82
|
+
type: "select",
|
|
83
|
+
required: true,
|
|
84
|
+
validation: { options: [...PART_TYPES] },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
slug: "conditions",
|
|
88
|
+
label: "Conditions",
|
|
89
|
+
type: "json",
|
|
90
|
+
validation: null,
|
|
91
|
+
defaultValue: DEFAULT_THEME_CONDITIONS,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
slug: "triggers",
|
|
95
|
+
label: "Triggers",
|
|
96
|
+
type: "json",
|
|
97
|
+
validation: null,
|
|
98
|
+
defaultValue: DEFAULT_THEME_TRIGGERS,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PAGES_COLLECTION, THEME_PARTS_COLLECTION } from "../../constants.ts";
|
|
3
|
+
import type { Fetcher } from "../api.ts";
|
|
4
|
+
import { planSetup } from "./plan.ts";
|
|
5
|
+
import { readCollection, runSetup } from "./run.ts";
|
|
6
|
+
|
|
7
|
+
/** EmDash's ADMIN role; only admins hold `schema:manage`. */
|
|
8
|
+
const ADMIN_ROLE = 50;
|
|
9
|
+
|
|
10
|
+
type SetupStatus =
|
|
11
|
+
| { state: "loading" }
|
|
12
|
+
| { state: "missing" | "outdated" | "ready"; isAdmin: boolean; conflicts: string[] }
|
|
13
|
+
| { state: "error"; message: string };
|
|
14
|
+
|
|
15
|
+
export function useSetupStatus(fetcher: Fetcher, role: number) {
|
|
16
|
+
const [status, setStatus] = React.useState<SetupStatus>({ state: "loading" });
|
|
17
|
+
const [running, setRunning] = React.useState(false);
|
|
18
|
+
|
|
19
|
+
const refresh = React.useCallback(async () => {
|
|
20
|
+
try {
|
|
21
|
+
const [pages, themeParts] = await Promise.all([
|
|
22
|
+
readCollection(fetcher, PAGES_COLLECTION),
|
|
23
|
+
readCollection(fetcher, THEME_PARTS_COLLECTION),
|
|
24
|
+
]);
|
|
25
|
+
const { steps, conflicts } = planSetup(pages, themeParts);
|
|
26
|
+
const state =
|
|
27
|
+
!pages || !themeParts
|
|
28
|
+
? "missing"
|
|
29
|
+
: steps.length > 0 || conflicts.length > 0
|
|
30
|
+
? "outdated"
|
|
31
|
+
: "ready";
|
|
32
|
+
setStatus({ state, isAdmin: role >= ADMIN_ROLE, conflicts });
|
|
33
|
+
} catch (error) {
|
|
34
|
+
setStatus({
|
|
35
|
+
state: "error",
|
|
36
|
+
message: error instanceof Error ? error.message : String(error),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, [fetcher, role]);
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
void refresh();
|
|
43
|
+
}, [refresh]);
|
|
44
|
+
|
|
45
|
+
const setup = React.useCallback(async () => {
|
|
46
|
+
setRunning(true);
|
|
47
|
+
try {
|
|
48
|
+
await runSetup(fetcher);
|
|
49
|
+
} catch (error) {
|
|
50
|
+
setStatus({
|
|
51
|
+
state: "error",
|
|
52
|
+
message: error instanceof Error ? error.message : String(error),
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
} finally {
|
|
56
|
+
setRunning(false);
|
|
57
|
+
}
|
|
58
|
+
await refresh();
|
|
59
|
+
}, [fetcher, refresh]);
|
|
60
|
+
|
|
61
|
+
return { status, running, setup };
|
|
62
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defaultConditionsFor,
|
|
3
|
+
defaultTriggers,
|
|
4
|
+
parseThemePartType,
|
|
5
|
+
starterLayout,
|
|
6
|
+
THEME_PART_TYPE_LABELS,
|
|
7
|
+
validateLayout,
|
|
8
|
+
type ConditionsDoc,
|
|
9
|
+
type Layout,
|
|
10
|
+
type ThemePartType,
|
|
11
|
+
type TriggersDoc,
|
|
12
|
+
} from "../core/index.ts";
|
|
13
|
+
import { THEME_PARTS_COLLECTION } from "../constants.ts";
|
|
14
|
+
import { requestJson, type Fetcher } from "./api.ts";
|
|
15
|
+
import { publishEntry } from "./content-api.ts";
|
|
16
|
+
|
|
17
|
+
const CONTENT = `/_emdash/api/content/${THEME_PARTS_COLLECTION}`;
|
|
18
|
+
|
|
19
|
+
type RawItem = {
|
|
20
|
+
id: string;
|
|
21
|
+
slug?: string | null;
|
|
22
|
+
status?: string;
|
|
23
|
+
updatedAt?: string;
|
|
24
|
+
data?: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type ThemePartSummary = {
|
|
28
|
+
id: string;
|
|
29
|
+
title: string;
|
|
30
|
+
partType: ThemePartType;
|
|
31
|
+
status: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
conditionsSummary: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ThemePartDraft = {
|
|
37
|
+
title: string;
|
|
38
|
+
slug: string;
|
|
39
|
+
partType: ThemePartType;
|
|
40
|
+
conditions: ConditionsDoc;
|
|
41
|
+
triggers: TriggersDoc;
|
|
42
|
+
layout: Layout | null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const titleOf = (item: RawItem) =>
|
|
46
|
+
typeof item.data?.["title"] === "string" && item.data["title"]
|
|
47
|
+
? item.data["title"]
|
|
48
|
+
: "Untitled theme part";
|
|
49
|
+
|
|
50
|
+
function partTypeOf(item: RawItem): ThemePartType {
|
|
51
|
+
return parseThemePartType(item.data?.["part_type"]) ?? "header";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function partTypeLabel(type: ThemePartType): string {
|
|
55
|
+
return THEME_PART_TYPE_LABELS[type];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type RuleArgs = Record<string, unknown> | undefined;
|
|
59
|
+
|
|
60
|
+
const arg = (args: RuleArgs, key: string) => String(args?.[key] ?? "?");
|
|
61
|
+
|
|
62
|
+
/** Short labels for the Theme Builder list, keyed by `group/name`. */
|
|
63
|
+
const RULE_LABELS: Record<string, (args: RuleArgs) => string> = {
|
|
64
|
+
"general/entire_site": () => "Entire site",
|
|
65
|
+
"singular/front": () => "Front page",
|
|
66
|
+
"singular/not_found": () => "404",
|
|
67
|
+
"singular/collection": (args) => `Singular: ${arg(args, "collection")}`,
|
|
68
|
+
"singular/entry": (args) => `Entry in ${arg(args, "collection")}`,
|
|
69
|
+
"singular/all": () => "All singular",
|
|
70
|
+
"archive/collection": (args) => `Archive: ${arg(args, "collection")}`,
|
|
71
|
+
"archive/search": () => "Search results",
|
|
72
|
+
"archive/taxonomy": (args) =>
|
|
73
|
+
args?.["slug"] ? `${arg(args, "taxonomy")}:${args["slug"]}` : `All ${arg(args, "taxonomy")}`,
|
|
74
|
+
"archive/all": () => "All archives",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function conditionRuleLabel(r: unknown): string {
|
|
78
|
+
const rule = r as { group?: string; name?: string; args?: RuleArgs };
|
|
79
|
+
const key = `${rule.group ?? "?"}/${rule.name ?? "?"}`;
|
|
80
|
+
const label = Object.hasOwn(RULE_LABELS, key) ? RULE_LABELS[key] : undefined;
|
|
81
|
+
return label ? label(rule.args) : key;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function summarizeConditions(raw: unknown): string {
|
|
85
|
+
let value = raw;
|
|
86
|
+
if (typeof raw === "string") {
|
|
87
|
+
try {
|
|
88
|
+
value = JSON.parse(raw) as unknown;
|
|
89
|
+
} catch {
|
|
90
|
+
return "Invalid conditions";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const rules = (value as { rules?: unknown } | null)?.rules;
|
|
94
|
+
if (!Array.isArray(rules) || rules.length === 0) return "No conditions";
|
|
95
|
+
const includes = rules.filter((r) => (r as { op?: string }).op === "include");
|
|
96
|
+
const excludes = rules.filter((r) => (r as { op?: string }).op === "exclude");
|
|
97
|
+
const parts: string[] = [];
|
|
98
|
+
if (includes.length) parts.push(includes.map(conditionRuleLabel).join(" · "));
|
|
99
|
+
if (excludes.length) parts.push(`Exclude: ${excludes.map(conditionRuleLabel).join(" · ")}`);
|
|
100
|
+
return parts.join(" · ") || "No conditions";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function listThemeParts(fetcher: Fetcher): Promise<ThemePartSummary[]> {
|
|
104
|
+
const body = await requestJson<{ items?: RawItem[] }>(
|
|
105
|
+
fetcher,
|
|
106
|
+
`${CONTENT}?limit=50&orderBy=updatedAt&order=desc`,
|
|
107
|
+
);
|
|
108
|
+
return (body?.items ?? []).map((item) => ({
|
|
109
|
+
id: item.id,
|
|
110
|
+
title: titleOf(item),
|
|
111
|
+
partType: partTypeOf(item),
|
|
112
|
+
status: item.status ?? "draft",
|
|
113
|
+
updatedAt: item.updatedAt ?? "",
|
|
114
|
+
conditionsSummary: summarizeConditions(item.data?.["conditions"]),
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export async function createThemePart(
|
|
119
|
+
fetcher: Fetcher,
|
|
120
|
+
input: { title: string; slug: string; partType: ThemePartType },
|
|
121
|
+
): Promise<string> {
|
|
122
|
+
const body = await requestJson<{ item: RawItem }>(fetcher, CONTENT, {
|
|
123
|
+
method: "POST",
|
|
124
|
+
body: {
|
|
125
|
+
data: {
|
|
126
|
+
title: input.title,
|
|
127
|
+
layout: starterLayout(input.title),
|
|
128
|
+
part_type: input.partType,
|
|
129
|
+
conditions: defaultConditionsFor(input.partType),
|
|
130
|
+
triggers: defaultTriggers(),
|
|
131
|
+
},
|
|
132
|
+
slug: input.slug,
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
return body.item.id;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export async function saveThemePart(
|
|
139
|
+
fetcher: Fetcher,
|
|
140
|
+
id: string,
|
|
141
|
+
draft: ThemePartDraft,
|
|
142
|
+
rev: string | null,
|
|
143
|
+
): Promise<string> {
|
|
144
|
+
const body = await requestJson<{ _rev: string }>(
|
|
145
|
+
fetcher,
|
|
146
|
+
`${CONTENT}/${encodeURIComponent(id)}`,
|
|
147
|
+
{
|
|
148
|
+
method: "PUT",
|
|
149
|
+
body: {
|
|
150
|
+
data: {
|
|
151
|
+
title: draft.title,
|
|
152
|
+
layout: draft.layout,
|
|
153
|
+
part_type: draft.partType,
|
|
154
|
+
conditions: draft.conditions,
|
|
155
|
+
triggers: draft.triggers,
|
|
156
|
+
},
|
|
157
|
+
slug: draft.slug,
|
|
158
|
+
...(rev ? { _rev: rev } : {}),
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
return body["_rev"];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const publishThemePart = (fetcher: Fetcher, id: string, rev: string | null) =>
|
|
166
|
+
publishEntry(fetcher, CONTENT, id, rev);
|
|
167
|
+
|
|
168
|
+
/** The part's layout when it is the expected type. Null when missing or unreadable. */
|
|
169
|
+
export async function themePartLayout(
|
|
170
|
+
fetcher: Fetcher,
|
|
171
|
+
id: string,
|
|
172
|
+
partType: ThemePartType,
|
|
173
|
+
): Promise<Layout | null> {
|
|
174
|
+
try {
|
|
175
|
+
const body = await requestJson<{ item?: { data?: Record<string, unknown> } }>(
|
|
176
|
+
fetcher,
|
|
177
|
+
`${CONTENT}/${encodeURIComponent(id)}`,
|
|
178
|
+
);
|
|
179
|
+
const data = body?.item?.data;
|
|
180
|
+
if (!data || data["part_type"] !== partType) return null;
|
|
181
|
+
const result = validateLayout(data["layout"]);
|
|
182
|
+
return result.ok ? result.layout : null;
|
|
183
|
+
} catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
package/src/admin/ui.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
const solid = (color: string) =>
|
|
4
|
+
({
|
|
5
|
+
"--kumo-button-emphasis-bg": color,
|
|
6
|
+
"--kumo-button-emphasis-gradient-start": color,
|
|
7
|
+
"--kumo-button-emphasis-gradient-end": color,
|
|
8
|
+
}) as React.CSSProperties;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Kumo paints emphasis buttons with a light gradient that leaves white text below AA. EmVB
|
|
12
|
+
* flattens it to the solid fill (DESIGN.md, contrast override). Kumo lets `style` win.
|
|
13
|
+
*/
|
|
14
|
+
export const SOLID_PRIMARY = solid("var(--color-kumo-brand)");
|
|
15
|
+
export const SOLID_DESTRUCTIVE = solid("var(--text-color-kumo-danger)");
|
|
16
|
+
|
|
17
|
+
/** EmVB's compact control size: 28 px and a 6 px radius (DESIGN.md). Doubled to beat utilities. */
|
|
18
|
+
export const BUTTON = "emvb-btn";
|
|
19
|
+
export const FIELD = "emvb-field";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Shared EmVB admin chrome (list pages, dialogs, setup states, conditions) plus compact
|
|
23
|
+
* control sizing used inside the editor. Glass / elevation tokens match DESIGN.md and the
|
|
24
|
+
* editor's mockup1 denser elevated look.
|
|
25
|
+
*/
|
|
26
|
+
export const UI_CSS = `
|
|
27
|
+
[data-emvb-page],
|
|
28
|
+
[data-emvb-dialog],
|
|
29
|
+
[data-emvb-panel="conditions"] {
|
|
30
|
+
--emvb-control: 28px;
|
|
31
|
+
--emvb-glass-blur: 6px;
|
|
32
|
+
--emvb-glass: color-mix(in oklab, var(--color-kumo-base) 97%, transparent);
|
|
33
|
+
--emvb-glass-strong: var(--color-kumo-base);
|
|
34
|
+
--emvb-glass-elevated: color-mix(in oklab, var(--color-kumo-elevated) 98%, transparent);
|
|
35
|
+
--emvb-elevation-s: 0 0 0 1px var(--color-kumo-hairline), 0 1px 2px var(--color-kumo-shadow-edge), 0 1px 3px var(--color-kumo-shadow-drop);
|
|
36
|
+
--emvb-elevation-m: 0 0 0 1px var(--color-kumo-line), 0 2px 4px var(--color-kumo-shadow-edge), 0 8px 20px var(--color-kumo-shadow-drop);
|
|
37
|
+
}
|
|
38
|
+
.emvb-btn.emvb-btn { height: 28px; border-radius: 6px; }
|
|
39
|
+
.emvb-icon-btn.emvb-icon-btn { width: 28px; height: 28px; border-radius: 6px; }
|
|
40
|
+
.emvb-field.emvb-field { height: 28px; border-radius: 6px; }
|
|
41
|
+
.emvb-field.emvb-field input,
|
|
42
|
+
.emvb-field.emvb-field select,
|
|
43
|
+
.emvb-field.emvb-field textarea,
|
|
44
|
+
.emvb-field.emvb-field [data-slot="control"] {
|
|
45
|
+
border-radius: 6px;
|
|
46
|
+
}
|
|
47
|
+
.emvb-mono { font-family: var(--font-mono); }
|
|
48
|
+
.emvb-helper { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); }
|
|
49
|
+
.emvb-inline-error { display: flex; gap: 4px; align-items: flex-start; margin: 0; font-size: 12px; line-height: 16px; color: var(--text-color-kumo-danger); }
|
|
50
|
+
.emvb-status {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 4px;
|
|
54
|
+
height: 20px;
|
|
55
|
+
padding: 0 8px;
|
|
56
|
+
border-radius: 9999px;
|
|
57
|
+
font-size: 12px;
|
|
58
|
+
line-height: 16px;
|
|
59
|
+
background: var(--emvb-glass-strong, var(--color-kumo-base));
|
|
60
|
+
box-shadow: inset 0 0 0 1px var(--color-kumo-hairline);
|
|
61
|
+
white-space: nowrap;
|
|
62
|
+
}
|
|
63
|
+
.emvb-status-dot { width: 8px; height: 8px; border-radius: 9999px; background: var(--text-color-kumo-subtle); }
|
|
64
|
+
.emvb-status[data-status="published"] .emvb-status-dot { background: var(--color-kumo-success); }
|
|
65
|
+
|
|
66
|
+
/* List / setup pages */
|
|
67
|
+
.emvb-pages { display: flex; flex-direction: column; gap: 16px; }
|
|
68
|
+
.emvb-list-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
69
|
+
.emvb-page-title { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 600; color: var(--text-color-kumo-default); }
|
|
70
|
+
.emvb-row-title { color: var(--text-color-kumo-default); font-size: 14px; line-height: 20px; font-weight: 600; text-decoration: none; }
|
|
71
|
+
.emvb-row-title:hover { text-decoration: underline; text-underline-offset: 2px; }
|
|
72
|
+
.emvb-row-title:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; border-radius: 4px; }
|
|
73
|
+
.emvb-row-slug { font-family: var(--font-mono); font-size: 12px; line-height: 16px; color: var(--text-color-kumo-subtle); }
|
|
74
|
+
.emvb-tabular { font-variant-numeric: tabular-nums; color: var(--text-color-kumo-subtle); font-size: 13px; }
|
|
75
|
+
|
|
76
|
+
/* Elevated EmVB-owned card chrome (lists, empty/setup shells) — not host sidebar/header */
|
|
77
|
+
.emvb-surface-card {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: 12px;
|
|
81
|
+
padding: 16px;
|
|
82
|
+
border-radius: 6px;
|
|
83
|
+
background: var(--emvb-glass-strong, var(--color-kumo-base));
|
|
84
|
+
-webkit-backdrop-filter: blur(var(--emvb-glass-blur, 6px));
|
|
85
|
+
backdrop-filter: blur(var(--emvb-glass-blur, 6px));
|
|
86
|
+
box-shadow: var(--emvb-elevation-s);
|
|
87
|
+
}
|
|
88
|
+
.emvb-surface-card[data-emvb-list] { gap: 0; padding: 0; overflow: hidden; }
|
|
89
|
+
.emvb-surface-card[data-emvb-list] table { width: 100%; }
|
|
90
|
+
.emvb-surface-card .emvb-empty-shell,
|
|
91
|
+
.emvb-empty-shell {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
gap: 8px;
|
|
97
|
+
min-height: 200px;
|
|
98
|
+
padding: 24px 16px;
|
|
99
|
+
text-align: center;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Theme Builder type filters — underline tabs (same recipe as editor tabs) */
|
|
103
|
+
.emvb-theme-filters {
|
|
104
|
+
display: flex;
|
|
105
|
+
gap: 0;
|
|
106
|
+
width: fit-content;
|
|
107
|
+
max-width: 100%;
|
|
108
|
+
min-height: 28px;
|
|
109
|
+
margin: 0;
|
|
110
|
+
padding: 0;
|
|
111
|
+
overflow-x: auto;
|
|
112
|
+
scrollbar-width: thin;
|
|
113
|
+
border-bottom: 1px solid var(--color-kumo-hairline);
|
|
114
|
+
}
|
|
115
|
+
.emvb-theme-filter {
|
|
116
|
+
height: 28px;
|
|
117
|
+
min-height: 28px;
|
|
118
|
+
padding: 0 12px 2px;
|
|
119
|
+
border: 0;
|
|
120
|
+
border-radius: 0;
|
|
121
|
+
background: transparent;
|
|
122
|
+
color: var(--text-color-kumo-subtle);
|
|
123
|
+
font: inherit;
|
|
124
|
+
font-size: 13px;
|
|
125
|
+
line-height: 18px;
|
|
126
|
+
font-weight: 400;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
}
|
|
129
|
+
.emvb-theme-filter[data-active="true"],
|
|
130
|
+
.emvb-theme-filter[aria-selected="true"] {
|
|
131
|
+
color: var(--text-color-kumo-default);
|
|
132
|
+
font-weight: 600;
|
|
133
|
+
box-shadow: inset 0 -2px 0 0 var(--color-kumo-brand);
|
|
134
|
+
}
|
|
135
|
+
.emvb-theme-filter { flex: none; white-space: nowrap; }
|
|
136
|
+
.emvb-theme-filter-count { margin-left: 6px; color: var(--text-color-kumo-subtle); font-weight: 400; }
|
|
137
|
+
.emvb-theme-filter:hover { color: var(--text-color-kumo-default); }
|
|
138
|
+
.emvb-theme-filter:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
|
|
139
|
+
|
|
140
|
+
/* EmVB-owned dialog body (Kumo Dialog keeps host radius/shadow) */
|
|
141
|
+
.emvb-dialog { display: flex; flex-direction: column; gap: 10px; }
|
|
142
|
+
.emvb-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
|
|
143
|
+
.emvb-dialog :is(h2, [data-slot="title"]) {
|
|
144
|
+
margin: 0;
|
|
145
|
+
font-size: 14px;
|
|
146
|
+
line-height: 18px;
|
|
147
|
+
font-weight: 600;
|
|
148
|
+
color: var(--text-color-kumo-default);
|
|
149
|
+
}
|
|
150
|
+
.emvb-dialog :is(p, [data-slot="description"]) {
|
|
151
|
+
margin: 0;
|
|
152
|
+
font-size: 13px;
|
|
153
|
+
line-height: 1.35;
|
|
154
|
+
color: var(--text-color-kumo-subtle);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Popup triggers (W-087): one elevated card per trigger, settings under its type */
|
|
158
|
+
.emvb-triggers { display: flex; flex-direction: column; gap: 8px; }
|
|
159
|
+
.emvb-triggers > .emvb-section-label:not(:first-child) { margin-top: 12px; }
|
|
160
|
+
.emvb-triggers > .emvb-section-label + .emvb-helper { margin-top: -4px; }
|
|
161
|
+
.emvb-trigger-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
|
|
162
|
+
.emvb-trigger-row {
|
|
163
|
+
display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: 6px;
|
|
164
|
+
background: var(--emvb-glass-elevated, var(--color-kumo-elevated)); box-shadow: var(--emvb-elevation-s);
|
|
165
|
+
}
|
|
166
|
+
.emvb-trigger-head { display: flex; align-items: flex-end; gap: 4px; }
|
|
167
|
+
.emvb-trigger-head > :first-child { flex: 1 1 auto; min-width: 0; }
|
|
168
|
+
.emvb-device-fieldset { display: flex; flex-wrap: wrap; gap: 4px 16px; min-width: 0; margin: 0; padding: 0; border: 0; }
|
|
169
|
+
.emvb-device-fieldset > legend { float: left; width: 100%; padding: 0; }
|
|
170
|
+
.emvb-device-fieldset > .emvb-helper { width: 100%; margin: 0; }
|
|
171
|
+
.emvb-device-option { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; font-size: 13px; cursor: pointer; }
|
|
172
|
+
.emvb-device-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-kumo-brand); }
|
|
173
|
+
.emvb-device-option input:focus-visible { outline: 2px solid var(--color-kumo-brand); outline-offset: 2px; }
|
|
174
|
+
|
|
175
|
+
/* Conditions editor (theme-part settings) */
|
|
176
|
+
.emvb-section-label {
|
|
177
|
+
margin: 4px 0 0;
|
|
178
|
+
font-size: 13px;
|
|
179
|
+
font-weight: 600;
|
|
180
|
+
line-height: 1.2;
|
|
181
|
+
color: var(--text-color-kumo-default);
|
|
182
|
+
}
|
|
183
|
+
.emvb-condition-list {
|
|
184
|
+
list-style: none;
|
|
185
|
+
margin: 8px 0 0;
|
|
186
|
+
padding: 0;
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-direction: column;
|
|
189
|
+
gap: 8px;
|
|
190
|
+
}
|
|
191
|
+
.emvb-condition-row {
|
|
192
|
+
display: grid;
|
|
193
|
+
grid-template-columns: 96px 1fr 28px;
|
|
194
|
+
gap: 6px;
|
|
195
|
+
align-items: center;
|
|
196
|
+
padding: 6px;
|
|
197
|
+
border-radius: 6px;
|
|
198
|
+
background: var(--emvb-glass-strong, var(--color-kumo-base));
|
|
199
|
+
box-shadow: var(--emvb-elevation-s);
|
|
200
|
+
}
|
|
201
|
+
.emvb-condition-op,
|
|
202
|
+
.emvb-condition-where {
|
|
203
|
+
height: var(--emvb-control, 28px);
|
|
204
|
+
border-radius: 6px;
|
|
205
|
+
border: 1px solid var(--color-kumo-hairline);
|
|
206
|
+
background: var(--color-kumo-control, var(--color-kumo-base));
|
|
207
|
+
color: var(--text-color-kumo-default);
|
|
208
|
+
font: inherit;
|
|
209
|
+
font-size: 13px;
|
|
210
|
+
padding: 0 8px;
|
|
211
|
+
}
|
|
212
|
+
.emvb-condition-op:focus-visible,
|
|
213
|
+
.emvb-condition-where:focus-visible {
|
|
214
|
+
outline: 2px solid var(--color-kumo-brand);
|
|
215
|
+
outline-offset: 2px;
|
|
216
|
+
}
|
|
217
|
+
.emvb-condition-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
|
|
218
|
+
|
|
219
|
+
@media (prefers-reduced-motion: reduce) {
|
|
220
|
+
[data-emvb-editor] *, [data-emvb-page] * { transition: none !important; animation: none !important; }
|
|
221
|
+
}
|
|
222
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
223
|
+
.emvb-status,
|
|
224
|
+
.emvb-surface-card,
|
|
225
|
+
.emvb-condition-row {
|
|
226
|
+
background: var(--color-kumo-base);
|
|
227
|
+
-webkit-backdrop-filter: none;
|
|
228
|
+
backdrop-filter: none;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
`;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { LinkButton, Text } from "@cloudflare/kumo";
|
|
2
|
+
import { ArrowSquareOutIcon } from "@phosphor-icons/react";
|
|
3
|
+
import { summarizeLayout } from "../../core/index.ts";
|
|
4
|
+
import { PAGES_COLLECTION, PLUGIN_ID } from "../../constants.ts";
|
|
5
|
+
|
|
6
|
+
export type FieldWidgetProps = {
|
|
7
|
+
value: unknown;
|
|
8
|
+
onChange: (value: unknown) => void;
|
|
9
|
+
label: string;
|
|
10
|
+
id: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
options?: Record<string, unknown>;
|
|
13
|
+
minimal?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function parse(value: unknown): unknown {
|
|
17
|
+
if (typeof value !== "string") return value;
|
|
18
|
+
try {
|
|
19
|
+
return JSON.parse(value) as unknown;
|
|
20
|
+
} catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The entry id from `/_emdash/admin/content/emvb_pages/<id>`; field widgets don't receive it. */
|
|
26
|
+
export function entryIdFromLocation(pathname: string): string | undefined {
|
|
27
|
+
const match = new RegExp(`/content/${PAGES_COLLECTION}/([^/?#]+)`).exec(pathname);
|
|
28
|
+
const id = match?.[1];
|
|
29
|
+
return id && id !== "new" ? decodeURIComponent(id) : undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Read-only widget for the hidden collection's `layout` field (D-019). It summarises the page and
|
|
34
|
+
* links to EmVB. It has no inputs and never calls `onChange`, so the JSON can't be hand-edited here.
|
|
35
|
+
*/
|
|
36
|
+
export function LayoutField({ value, label, id }: FieldWidgetProps) {
|
|
37
|
+
const summary = summarizeLayout(parse(value));
|
|
38
|
+
const entryId = entryIdFromLocation(window.location.pathname);
|
|
39
|
+
const href = entryId
|
|
40
|
+
? `/_emdash/admin/plugins/${PLUGIN_ID}/editor?entry=${encodeURIComponent(entryId)}`
|
|
41
|
+
: `/_emdash/admin/plugins/${PLUGIN_ID}/pages`;
|
|
42
|
+
const description = !summary
|
|
43
|
+
? "This page has no content yet."
|
|
44
|
+
: `${summary.nodes} ${summary.nodes === 1 ? "element" : "elements"} · schema ${summary.schemaVersion ?? "unknown"}`;
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
id={id}
|
|
48
|
+
role="group"
|
|
49
|
+
aria-label={label}
|
|
50
|
+
data-emvb-widget="layout"
|
|
51
|
+
className="flex flex-col gap-2"
|
|
52
|
+
>
|
|
53
|
+
<Text variant="secondary">{label}</Text>
|
|
54
|
+
<Text>{description}</Text>
|
|
55
|
+
<Text variant="secondary">This page is edited in EmVB.</Text>
|
|
56
|
+
<div>
|
|
57
|
+
<LinkButton
|
|
58
|
+
href={href}
|
|
59
|
+
variant="secondary"
|
|
60
|
+
icon={<ArrowSquareOutIcon aria-hidden="true" />}
|
|
61
|
+
>
|
|
62
|
+
{entryId ? "Open in EmVB" : "Go to Visual pages"}
|
|
63
|
+
</LinkButton>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { RenderedPage } from "./render.ts";
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
page: RenderedPage;
|
|
6
|
+
/** Blank canvas mode: a whole document, without the site's layout. The slot ends the body. */
|
|
7
|
+
standalone?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { page, standalone = false, title = "", description } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
standalone ? (
|
|
17
|
+
<html lang="en">
|
|
18
|
+
<head>
|
|
19
|
+
<meta charset="utf-8" />
|
|
20
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
21
|
+
<title>{title}</title>
|
|
22
|
+
{description && <meta name="description" content={description} />}
|
|
23
|
+
<style is:inline set:html={page.css} />
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<Fragment set:html={page.html} />
|
|
27
|
+
<slot />
|
|
28
|
+
</body>
|
|
29
|
+
</html>
|
|
30
|
+
) : (
|
|
31
|
+
<>
|
|
32
|
+
<style is:inline set:html={page.css} />
|
|
33
|
+
<Fragment set:html={page.html} />
|
|
34
|
+
<slot />
|
|
35
|
+
</>
|
|
36
|
+
)
|
|
37
|
+
}
|