@brimsites/brimjs 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +22 -2
  3. package/bin/brim.js +5 -0
  4. package/dist/cli.js +3802 -0
  5. package/editor-dist/editor.css +1 -0
  6. package/editor-dist/editor.js +91 -0
  7. package/package.json +71 -3
  8. package/skills/brim-convert/SKILL.md +256 -0
  9. package/skills/brim-hosting/SKILL.md +221 -0
  10. package/src/astro-shim.d.ts +5 -0
  11. package/src/auth/accounts.ts +341 -0
  12. package/src/auth/password.ts +34 -0
  13. package/src/auth/permissions.ts +44 -0
  14. package/src/blocks/accordion/Accordion.astro +48 -0
  15. package/src/blocks/accordion/accordion.css +63 -0
  16. package/src/blocks/analytics/Analytics.astro +45 -0
  17. package/src/blocks/analytics/ConsentBanner.astro +41 -0
  18. package/src/blocks/analytics/analytics.client.ts +125 -0
  19. package/src/blocks/analytics/analytics.css +51 -0
  20. package/src/blocks/analytics/consent.ts +51 -0
  21. package/src/blocks/button/Button.astro +64 -0
  22. package/src/blocks/button/button.css +100 -0
  23. package/src/blocks/carousel/Carousel.astro +140 -0
  24. package/src/blocks/carousel/carousel.client.ts +153 -0
  25. package/src/blocks/carousel/carousel.css +181 -0
  26. package/src/blocks/data/icons.ts +285 -0
  27. package/src/blocks/data/image-shapes.ts +91 -0
  28. package/src/blocks/data/social-icons.ts +41 -0
  29. package/src/blocks/data/social-networks.ts +256 -0
  30. package/src/blocks/divider/Divider.astro +27 -0
  31. package/src/blocks/divider/divider.css +17 -0
  32. package/src/blocks/form/Captcha.astro +27 -0
  33. package/src/blocks/form/Form.astro +250 -0
  34. package/src/blocks/form/FormField.astro +138 -0
  35. package/src/blocks/form/Newsletter.astro +80 -0
  36. package/src/blocks/form/form.client.ts +339 -0
  37. package/src/blocks/form/form.css +271 -0
  38. package/src/blocks/gallery/ImageGallery.astro +126 -0
  39. package/src/blocks/gallery/gallery.css +43 -0
  40. package/src/blocks/gallery/lightbox.client.ts +178 -0
  41. package/src/blocks/gallery/lightbox.css +134 -0
  42. package/src/blocks/icon/Icon.astro +41 -0
  43. package/src/blocks/icon/icon.css +16 -0
  44. package/src/blocks/image/Image.astro +158 -0
  45. package/src/blocks/image/image.css +42 -0
  46. package/src/blocks/images.ts +64 -0
  47. package/src/blocks/in-editor.client.ts +8 -0
  48. package/src/blocks/listing/Listing.astro +288 -0
  49. package/src/blocks/listing/ListingCards.astro +48 -0
  50. package/src/blocks/listing/listing.css +136 -0
  51. package/src/blocks/listing/query.ts +363 -0
  52. package/src/blocks/map/Map.astro +75 -0
  53. package/src/blocks/map/map.css +32 -0
  54. package/src/blocks/schemas/accordion.ts +118 -0
  55. package/src/blocks/schemas/button.ts +78 -0
  56. package/src/blocks/schemas/carousel.ts +133 -0
  57. package/src/blocks/schemas/divider.ts +29 -0
  58. package/src/blocks/schemas/form-field-types.ts +29 -0
  59. package/src/blocks/schemas/form.ts +350 -0
  60. package/src/blocks/schemas/icon.ts +24 -0
  61. package/src/blocks/schemas/image-gallery.ts +54 -0
  62. package/src/blocks/schemas/image.ts +87 -0
  63. package/src/blocks/schemas/index.ts +33 -0
  64. package/src/blocks/schemas/listing.ts +14 -0
  65. package/src/blocks/schemas/map.ts +81 -0
  66. package/src/blocks/schemas/newsletter.ts +324 -0
  67. package/src/blocks/schemas/social-media.ts +348 -0
  68. package/src/blocks/schemas/text.ts +151 -0
  69. package/src/blocks/schemas/video.ts +57 -0
  70. package/src/blocks/search/Search.astro +147 -0
  71. package/src/blocks/search/search.css +69 -0
  72. package/src/blocks/search/state.ts +28 -0
  73. package/src/blocks/settings.ts +94 -0
  74. package/src/blocks/social/SocialMedia.astro +102 -0
  75. package/src/blocks/social/social-links.ts +16 -0
  76. package/src/blocks/social/social.css +31 -0
  77. package/src/blocks/theme.ts +35 -0
  78. package/src/blocks/types.ts +52 -0
  79. package/src/blocks/video/Video.astro +90 -0
  80. package/src/blocks/video/video-source.ts +77 -0
  81. package/src/blocks/video/video.client.ts +43 -0
  82. package/src/blocks/video/video.css +29 -0
  83. package/src/check.ts +1119 -0
  84. package/src/cli.ts +493 -0
  85. package/src/components/Blocks.astro +68 -0
  86. package/src/components/Field.astro +61 -0
  87. package/src/components/Footer.astro +36 -0
  88. package/src/components/Link.astro +18 -0
  89. package/src/components/MobileMenu.astro +77 -0
  90. package/src/components/Navbar.astro +42 -0
  91. package/src/components/RichText.astro +32 -0
  92. package/src/components/Seo.astro +202 -0
  93. package/src/components/Setting.astro +46 -0
  94. package/src/components/Shared.astro +17 -0
  95. package/src/components/Text.astro +91 -0
  96. package/src/components/blocks.css +86 -0
  97. package/src/components/index.ts +27 -0
  98. package/src/components/mobile-menu.client.ts +21 -0
  99. package/src/components/mobile-menu.css +52 -0
  100. package/src/components/text.css +48 -0
  101. package/src/config.ts +413 -0
  102. package/src/content/block-layout.ts +63 -0
  103. package/src/content/block-values.ts +48 -0
  104. package/src/content/content-check.ts +174 -0
  105. package/src/content/content-types.ts +408 -0
  106. package/src/content/drafts.ts +115 -0
  107. package/src/content/feed.ts +237 -0
  108. package/src/content/field-types.ts +107 -0
  109. package/src/content/history.ts +140 -0
  110. package/src/content/ids.ts +50 -0
  111. package/src/content/image-size.ts +212 -0
  112. package/src/content/image-sizes.ts +126 -0
  113. package/src/content/item-fields.ts +110 -0
  114. package/src/content/item-head.ts +126 -0
  115. package/src/content/item-image.ts +26 -0
  116. package/src/content/item-path.ts +122 -0
  117. package/src/content/items.ts +580 -0
  118. package/src/content/language-scopes.ts +40 -0
  119. package/src/content/media.ts +271 -0
  120. package/src/content/menus.ts +51 -0
  121. package/src/content/page-templates.ts +52 -0
  122. package/src/content/redirects.ts +112 -0
  123. package/src/content/references.ts +165 -0
  124. package/src/content/rich-text.ts +63 -0
  125. package/src/content/search.ts +167 -0
  126. package/src/content/seed.ts +229 -0
  127. package/src/content/site-settings.ts +111 -0
  128. package/src/content/sitemap.ts +143 -0
  129. package/src/content/store.ts +225 -0
  130. package/src/content/tags.ts +67 -0
  131. package/src/content/text-default.ts +139 -0
  132. package/src/content/types.ts +137 -0
  133. package/src/content/validate.ts +253 -0
  134. package/src/content/validation-error.ts +2 -0
  135. package/src/db/cached.ts +140 -0
  136. package/src/db/database.ts +15 -0
  137. package/src/db/libsql.ts +29 -0
  138. package/src/db/schema.ts +189 -0
  139. package/src/db/url.ts +44 -0
  140. package/src/editor/client/BlockSettings.tsx +1063 -0
  141. package/src/editor/client/Chrome.tsx +284 -0
  142. package/src/editor/client/ContentBrowser.tsx +1299 -0
  143. package/src/editor/client/Editor.tsx +1756 -0
  144. package/src/editor/client/HistoryPanel.tsx +114 -0
  145. package/src/editor/client/ImagesWidget.tsx +113 -0
  146. package/src/editor/client/Inspector.tsx +127 -0
  147. package/src/editor/client/ItemForm.tsx +535 -0
  148. package/src/editor/client/LinkWidget.tsx +440 -0
  149. package/src/editor/client/ListingPanel.tsx +99 -0
  150. package/src/editor/client/Login.tsx +338 -0
  151. package/src/editor/client/Menu.tsx +64 -0
  152. package/src/editor/client/PageSettings.tsx +270 -0
  153. package/src/editor/client/RedirectsSettings.tsx +130 -0
  154. package/src/editor/client/Resize.tsx +204 -0
  155. package/src/editor/client/Sidebar.tsx +51 -0
  156. package/src/editor/client/SiteMap.tsx +568 -0
  157. package/src/editor/client/SiteSettings.tsx +409 -0
  158. package/src/editor/client/TextTools.tsx +391 -0
  159. package/src/editor/client/Toolbar.tsx +449 -0
  160. package/src/editor/client/VideoUpload.tsx +251 -0
  161. package/src/editor/client/api.ts +417 -0
  162. package/src/editor/client/brand.ts +20 -0
  163. package/src/editor/client/connection.ts +98 -0
  164. package/src/editor/client/context.ts +19 -0
  165. package/src/editor/client/css.d.ts +2 -0
  166. package/src/editor/client/editor.css +4656 -0
  167. package/src/editor/client/fields.tsx +812 -0
  168. package/src/editor/client/icons.tsx +174 -0
  169. package/src/editor/client/keys.ts +15 -0
  170. package/src/editor/client/kinds.ts +289 -0
  171. package/src/editor/client/languages.ts +32 -0
  172. package/src/editor/client/main.tsx +100 -0
  173. package/src/editor/client/responses.ts +26 -0
  174. package/src/editor/client/rich-text.ts +326 -0
  175. package/src/editor/client/site-tree.ts +239 -0
  176. package/src/editor/client/theme.ts +55 -0
  177. package/src/editor/client/tsconfig.json +18 -0
  178. package/src/editor/client/tus.ts +137 -0
  179. package/src/editor/client/use-rect.ts +50 -0
  180. package/src/editor/client/widgets.tsx +1218 -0
  181. package/src/forms/captcha.ts +83 -0
  182. package/src/forms/define.ts +166 -0
  183. package/src/forms/fields.ts +197 -0
  184. package/src/forms/file-types.ts +108 -0
  185. package/src/forms/files.ts +216 -0
  186. package/src/forms/form-page.ts +9 -0
  187. package/src/forms/handler.ts +622 -0
  188. package/src/forms/spec.ts +89 -0
  189. package/src/forms/store.ts +96 -0
  190. package/src/forms/work.ts +50 -0
  191. package/src/icons/library.ts +144 -0
  192. package/src/icons/load.ts +63 -0
  193. package/src/index.ts +99 -0
  194. package/src/init.ts +257 -0
  195. package/src/integration.ts +469 -0
  196. package/src/mail/mailer.ts +197 -0
  197. package/src/mail/notify.ts +272 -0
  198. package/src/mail/settings.ts +173 -0
  199. package/src/mail/templates.ts +191 -0
  200. package/src/mcp/page-nodes.ts +209 -0
  201. package/src/mcp/server.ts +111 -0
  202. package/src/mcp/tools.ts +637 -0
  203. package/src/runtime/TemplatePage.astro +39 -0
  204. package/src/runtime/TemplatePageStatic.astro +13 -0
  205. package/src/runtime/admin-route.ts +80 -0
  206. package/src/runtime/connect.ts +53 -0
  207. package/src/runtime/content.ts +188 -0
  208. package/src/runtime/context.ts +131 -0
  209. package/src/runtime/form-files.ts +18 -0
  210. package/src/runtime/forms-route.ts +33 -0
  211. package/src/runtime/forms.ts +28 -0
  212. package/src/runtime/icons.ts +5 -0
  213. package/src/runtime/media.ts +175 -0
  214. package/src/runtime/middleware.ts +186 -0
  215. package/src/runtime/nav.ts +13 -0
  216. package/src/runtime/query-reads.ts +49 -0
  217. package/src/runtime/query-store.ts +16 -0
  218. package/src/runtime/request-state.ts +69 -0
  219. package/src/runtime/robots.ts +29 -0
  220. package/src/runtime/rss-static.ts +16 -0
  221. package/src/runtime/rss.ts +29 -0
  222. package/src/runtime/server.ts +29 -0
  223. package/src/runtime/sitemap.ts +34 -0
  224. package/src/runtime/template-paths.ts +34 -0
  225. package/src/runtime/uploads-route.ts +13 -0
  226. package/src/seed-cli.ts +253 -0
  227. package/src/server/auth.ts +31 -0
  228. package/src/server/fetch-image.ts +219 -0
  229. package/src/server/handler.ts +2106 -0
  230. package/src/server/http.ts +162 -0
  231. package/src/server/locales.ts +73 -0
  232. package/src/server/node.ts +57 -0
  233. package/src/server/query-params.ts +249 -0
  234. package/src/server/rate-limit.ts +72 -0
  235. package/src/server/video-host.ts +162 -0
  236. package/src/starter.ts +70 -0
  237. package/src/version.ts +4 -0
  238. package/src/virtual.d.ts +65 -0
@@ -0,0 +1,114 @@
1
+ import { useEffect, useState } from "react";
2
+ import { type HistoryEntry, api } from "./api.ts";
3
+ import { Sidebar } from "./Sidebar.tsx";
4
+
5
+ const ACTIONS: Record<HistoryEntry["action"], string> = {
6
+ changed: "changed",
7
+ reset: "reset to original",
8
+ deleted: "deleted",
9
+ };
10
+ const TARGETS: Record<HistoryEntry["target"], string> = { node: "Element", item: "Item", page: "Page" };
11
+
12
+ /**
13
+ * What changed lately on this page or on the whole site, newest first, with who changed it. "Restore" puts the
14
+ * element, item or deleted page back to what it was before that change; restoring is a change too, so it can be
15
+ * taken back in turn.
16
+ */
17
+ export function HistoryPanel({
18
+ path,
19
+ onRestored,
20
+ onClose,
21
+ }: {
22
+ /** The page being edited, for "This page". */
23
+ path: string;
24
+ /** Called after a change was taken back, so the page is drawn again. */
25
+ onRestored: (entry: HistoryEntry) => void;
26
+ onClose: () => void;
27
+ }) {
28
+ const [everywhere, setEverywhere] = useState(false);
29
+ const [entries, setEntries] = useState<HistoryEntry[] | null>(null);
30
+ const [error, setError] = useState("");
31
+ const [busy, setBusy] = useState("");
32
+
33
+ const load = (): void => {
34
+ api.history(everywhere ? undefined : path).then(
35
+ (loaded) => setEntries(loaded.history),
36
+ (failure: unknown) => setError(failure instanceof Error ? failure.message : String(failure)),
37
+ );
38
+ };
39
+ useEffect(load, [everywhere, path]);
40
+
41
+ async function restore(entry: HistoryEntry): Promise<void> {
42
+ setBusy(entry.id);
43
+ setError("");
44
+ try {
45
+ await api.restoreHistory(entry.id);
46
+ onRestored(entry);
47
+ load();
48
+ } catch (failure) {
49
+ setError(failure instanceof Error ? failure.message : String(failure));
50
+ } finally {
51
+ setBusy("");
52
+ }
53
+ }
54
+
55
+ return (
56
+ <Sidebar title="History" onClose={onClose}>
57
+ <p className="brim-sidebar-note">
58
+ Changes of the last 90 days. Restore puts something back to what it was before that change.
59
+ </p>
60
+ <div className="cb-view-toggle brim-history__scope" role="group" aria-label="Which changes">
61
+ <button type="button" aria-pressed={!everywhere} onClick={() => setEverywhere(false)}>
62
+ This page
63
+ </button>
64
+ <button type="button" aria-pressed={everywhere} onClick={() => setEverywhere(true)}>
65
+ Whole site
66
+ </button>
67
+ </div>
68
+ {error && (
69
+ <p className="field-error" role="alert">
70
+ {error}
71
+ </p>
72
+ )}
73
+ {entries && entries.length === 0 && (
74
+ <p className="brim-sidebar-note">
75
+ {everywhere ? "Nothing was changed yet." : "Nothing was changed on this page yet."}
76
+ </p>
77
+ )}
78
+ {entries && entries.length > 0 && (
79
+ <ul className="brim-redirects brim-history">
80
+ {entries.map((entry) => (
81
+ <li key={entry.id} className="brim-redirects__row">
82
+ <span className="brim-history__what">
83
+ <strong>{entry.title}</strong>
84
+ <span>
85
+ {TARGETS[entry.target]} {ACTIONS[entry.action]}
86
+ {everywhere && entry.page ? ` · ${entry.page}` : ""}
87
+ </span>
88
+ <span>
89
+ {entry.user} · {when(entry.at)}
90
+ </span>
91
+ </span>
92
+ <button
93
+ type="button"
94
+ className="brim-toolbar-btn brim-toolbar-btn--outline"
95
+ disabled={busy !== ""}
96
+ onClick={() => void restore(entry)}
97
+ >
98
+ {busy === entry.id ? "Restoring…" : "Restore"}
99
+ </button>
100
+ </li>
101
+ ))}
102
+ </ul>
103
+ )}
104
+ </Sidebar>
105
+ );
106
+ }
107
+
108
+ /** "Today 14:05", or the date and time for an older change, as the browser writes them. */
109
+ function when(at: string): string {
110
+ const date = new Date(at);
111
+ const time = date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
112
+ const today = new Date().toDateString() === date.toDateString();
113
+ return today ? `Today ${time}` : `${date.toLocaleDateString(undefined, { day: "numeric", month: "short" })} ${time}`;
114
+ }
@@ -0,0 +1,113 @@
1
+ import { type ReactNode, useEffect, useState } from "react";
2
+ import { TextWidget } from "./fields.tsx";
3
+ import { LinkWidget } from "./LinkWidget.tsx";
4
+ import { CardList, ImageUploadWidget } from "./widgets.tsx";
5
+
6
+ /** One image of a list: its address and description, and what a gallery or carousel block also keeps. */
7
+ export interface ListedImage {
8
+ url?: unknown;
9
+ alt?: unknown;
10
+ caption?: unknown;
11
+ link?: unknown;
12
+ title?: unknown;
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ /**
17
+ * Several images, the same widget wherever they are edited: a gallery or carousel block, and an item's `gallery`
18
+ * field. Each is a card with its picture, opened to change the image and describe it; cards are moved and removed
19
+ * from their row. `extras` adds what a block keeps beside each image (a caption, a link); a field keeps none.
20
+ */
21
+ export function ImagesWidget({
22
+ label,
23
+ images,
24
+ extras = false,
25
+ onChange,
26
+ }: {
27
+ label: string;
28
+ images: ListedImage[];
29
+ extras?: boolean;
30
+ onChange: (images: ListedImage[]) => void;
31
+ }) {
32
+ return (
33
+ <CardList<ListedImage>
34
+ label={label}
35
+ addLabel="Add image"
36
+ entries={images}
37
+ title={(entry, index) => String(entry.title || entry.caption || entry.alt || `Image ${index + 1}`)}
38
+ thumbnail={(entry) => (typeof entry.url === "string" && entry.url ? entry.url : undefined)}
39
+ create={() => ({ url: "", alt: "" })}
40
+ render={(entry, change) => {
41
+ const field = (key: string, title: string): ReactNode => (
42
+ <TextWidget
43
+ label={title}
44
+ value={String(entry[key] ?? "")}
45
+ onChange={(next) => change({ ...entry, [key]: next })}
46
+ />
47
+ );
48
+ return (
49
+ <>
50
+ <ImageUploadWidget
51
+ label="Image"
52
+ value={String(entry.url ?? "")}
53
+ onChange={(url) => change({ ...entry, url })}
54
+ />
55
+ {field("alt", "Alt Text")}
56
+ {extras && field("caption", "Caption")}
57
+ {extras && (
58
+ <LinkWidget
59
+ label="Link"
60
+ value={String(entry.link ?? "")}
61
+ onChange={(link) => change({ ...entry, link })}
62
+ />
63
+ )}
64
+ </>
65
+ );
66
+ }}
67
+ onChange={onChange}
68
+ />
69
+ );
70
+ }
71
+
72
+ /**
73
+ * An item's `gallery` field (`[{ src, alt }]`) in the images widget, which speaks of `url`: what the owner sees and
74
+ * does is the same as in a gallery block. An image left without a picture is not kept.
75
+ */
76
+ export function GalleryFieldWidget({
77
+ label,
78
+ value,
79
+ onChange,
80
+ }: {
81
+ label: string;
82
+ value: unknown;
83
+ onChange: (value: { src: string; alt: string }[]) => void;
84
+ }) {
85
+ const fromValue = (): ListedImage[] =>
86
+ (Array.isArray(value) ? (value as Record<string, unknown>[]) : []).map((image) => ({
87
+ url: image.src,
88
+ alt: image.alt,
89
+ }));
90
+ // A card just added has no picture yet: it stays here until it gets one, and only pictures are saved.
91
+ const [images, setImages] = useState<ListedImage[]>(fromValue);
92
+ const saved = (list: ListedImage[]) =>
93
+ list
94
+ .filter((image) => typeof image.url === "string" && image.url !== "")
95
+ .map((image) => ({ src: String(image.url), alt: String(image.alt ?? "") }));
96
+ // Changed elsewhere (on the page, by an undo), the field shows the item's images again.
97
+ useEffect(() => {
98
+ if (JSON.stringify(saved(images)) !== JSON.stringify(saved(fromValue()))) setImages(fromValue());
99
+ // eslint-disable-next-line react-hooks/exhaustive-deps
100
+ }, [value]);
101
+
102
+ return (
103
+ <ImagesWidget
104
+ label={label}
105
+ images={images}
106
+ onChange={(next) => {
107
+ setImages(next);
108
+ const kept = saved(next);
109
+ if (JSON.stringify(kept) !== JSON.stringify(saved(images))) onChange(kept);
110
+ }}
111
+ />
112
+ );
113
+ }
@@ -0,0 +1,127 @@
1
+ import { useState } from "react";
2
+ import type { BlockLayout } from "../../content/block-layout.ts";
3
+ import { BlockSettings } from "./BlockSettings.tsx";
4
+ import { SelectWidget, SettingField } from "./fields.tsx";
5
+ import type { FormValue, NodeKind } from "./kinds.ts";
6
+ import { Fieldset, Sidebar } from "./Sidebar.tsx";
7
+
8
+ /** The settings of the selected node. Every change is saved as soon as it is made. */
9
+ export function Inspector({
10
+ element,
11
+ kind,
12
+ note,
13
+ only,
14
+ onChange,
15
+ onReset,
16
+ resetNote,
17
+ layout,
18
+ onClose,
19
+ }: {
20
+ element: HTMLElement;
21
+ kind: NodeKind;
22
+ /** Where else a change shows, for a node shared by every page or by every item's page. */
23
+ note: string | undefined;
24
+ /** The block settings to show, when only some of them can be changed here. */
25
+ only: ((name: string) => boolean) | undefined;
26
+ onChange: (form: FormValue) => void;
27
+ /** Absent when there is nothing of the element's own to reset here. */
28
+ onReset: (() => void) | undefined;
29
+ /** Where a reset shows: this page, every page, or every item of a type. */
30
+ resetNote?: string | undefined;
31
+ /** For a block of a `blocks` field: how wide it is and to which side, where no code of the site places it. */
32
+ layout?: { value: BlockLayout; onChange: (layout: BlockLayout) => void } | undefined;
33
+ onClose: () => void;
34
+ }) {
35
+ const [placed, setPlaced] = useState(layout?.value);
36
+ const [form, setForm] = useState(() => kind.read(element));
37
+
38
+ function change(next: FormValue): void {
39
+ setForm(next);
40
+ onChange(next);
41
+ }
42
+
43
+ return (
44
+ <Sidebar title={`${kind.title} Settings`} onClose={onClose}>
45
+ {note && <p className="brim-sidebar-note">{note}</p>}
46
+ {kind.block ? (
47
+ <BlockSettings definition={kind.block} value={form} only={only} onChange={change} />
48
+ ) : (
49
+ <Fieldset title="Default" open>
50
+ <SettingField schema={kind.schema(element)} value={form} onChange={(next) => change(next as FormValue)} />
51
+ </Fieldset>
52
+ )}
53
+ {layout && placed && (
54
+ <Fieldset title="Layout">
55
+ <SelectWidget
56
+ label="Width"
57
+ description="How wide the block is in the page's column."
58
+ options={[
59
+ { value: "narrow", label: "Narrow" },
60
+ { value: "content", label: "As the text" },
61
+ { value: "wide", label: "Wide" },
62
+ { value: "full", label: "Full width" },
63
+ ]}
64
+ value={placed.width}
65
+ onChange={(width) => {
66
+ const next = { ...placed, width: width as BlockLayout["width"] };
67
+ setPlaced(next);
68
+ layout.onChange(next);
69
+ }}
70
+ />
71
+ <SelectWidget
72
+ label="Position"
73
+ description="Where it sits when it is narrower than the column."
74
+ options={[
75
+ { value: "left", label: "Left" },
76
+ { value: "center", label: "Center" },
77
+ { value: "right", label: "Right" },
78
+ ]}
79
+ value={placed.align}
80
+ onChange={(align) => {
81
+ const next = { ...placed, align: align as BlockLayout["align"] };
82
+ setPlaced(next);
83
+ layout.onChange(next);
84
+ }}
85
+ />
86
+ <SelectWidget
87
+ label="Space above"
88
+ description="In steps of the site's spacing between blocks."
89
+ options={[
90
+ { value: "none", label: "None" },
91
+ { value: "small", label: "Small" },
92
+ { value: "normal", label: "Normal" },
93
+ { value: "large", label: "Large" },
94
+ ]}
95
+ value={placed.space}
96
+ onChange={(space) => {
97
+ const next = { ...placed, space: space as BlockLayout["space"] };
98
+ setPlaced(next);
99
+ layout.onChange(next);
100
+ }}
101
+ />
102
+ </Fieldset>
103
+ )}
104
+ {kind.options && (
105
+ <BlockSettings
106
+ definition={kind.options}
107
+ value={(form.options ?? {}) as FormValue}
108
+ openFirst={false}
109
+ onChange={(options) => change({ ...form, options })}
110
+ />
111
+ )}
112
+ {onReset && (
113
+ <Fieldset title="Reset">
114
+ <div className="field-group">
115
+ <p className="field-description">
116
+ Removes everything you changed on this element (its text, image, link or settings) and brings back what
117
+ the site's code says. {resetNote} It can't be undone.
118
+ </p>
119
+ <button type="button" className="brim-toolbar-btn brim-toolbar-btn--outline" onClick={onReset}>
120
+ Reset to original
121
+ </button>
122
+ </div>
123
+ </Fieldset>
124
+ )}
125
+ </Sidebar>
126
+ );
127
+ }