@backmatter/studio 0.0.17 → 0.0.19
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/dist/chunks/{UiKitApp-D7vllRQE.js → UiKitApp-B1ANqCac.js} +528 -481
- package/dist/chunks/{WorkspaceRoutes-DH1LD-2Q.js → WorkspaceRoutes-BHNGrf-j.js} +24955 -24119
- package/dist/chunks/{dashboard-Dsaeud2x.js → dashboard-b-W6dGm5.js} +586 -565
- package/dist/chunks/{index-CGMqw2NH.js → index-HYioDjux.js} +104 -104
- package/dist/dashboard.js +2 -2
- package/dist/index.js +166 -159
- package/dist/site-widget.css +25 -6
- package/dist/site-widget.js +6925 -6840
- package/dist/studio.css +171 -42
- package/package.json +2 -2
- package/src/api.ts +44 -1
- package/src/chat/ChatMessage.tsx +4 -4
- package/src/chat/ChatProvider.tsx +6 -0
- package/src/chat/chat-helpers.ts +54 -2
- package/src/chrome/CommandPalette.tsx +3 -3
- package/src/chrome/ContentExplorerSidebar.tsx +421 -74
- package/src/chrome/WorkspaceStatusBar.tsx +24 -24
- package/src/chrome/commit-error.ts +48 -60
- package/src/chrome/commit-failure.tsx +2 -2
- package/src/chrome/content-path-tree.ts +4 -0
- package/src/chrome/explorer-row-menu.ts +28 -0
- package/src/chrome/folder-create-context.ts +14 -0
- package/src/chrome/use-publish-check.ts +75 -0
- package/src/{pages/code-session-routes.ts → content-routes.ts} +6 -6
- package/src/fields/FieldControl.tsx +198 -64
- package/src/fields/LinkFieldInput.tsx +315 -0
- package/src/fields/choose-field-input.ts +5 -0
- package/src/fields/link-targets.ts +60 -0
- package/src/host-path.ts +13 -0
- package/src/pages/CodeSessionPage.tsx +6 -241
- package/src/pages/DocEditorPage.tsx +121 -178
- package/src/pages/EmbedPublishPage.tsx +13 -5
- package/src/pages/GithubConnectPage.tsx +1 -1
- package/src/pages/LoginPage.tsx +67 -5
- package/src/pages/MediaFieldInput.tsx +712 -37
- package/src/pages/MediaGalleryPage.tsx +69 -5
- package/src/pages/PreviewAddress.tsx +293 -0
- package/src/pages/WorkspaceHomePage.tsx +1 -1
- package/src/pages/code-session-boot.ts +0 -12
- package/src/pages/media-selection.ts +79 -0
- package/src/pages/ui-kit/colors.tsx +2 -0
- package/src/pages/ui-kit/fields.tsx +60 -0
- package/src/styles/themes.ts +2 -0
- package/src/styles/tokens.stylex.ts +1 -0
- package/src/ui/Button.tsx +14 -0
- package/src/ui/Field.tsx +12 -1
- package/src/ui/Input.tsx +191 -97
- package/src/ui/popup.ts +13 -6
|
@@ -39,13 +39,18 @@ import {
|
|
|
39
39
|
import { MediaLightbox } from "./MediaLightbox";
|
|
40
40
|
|
|
41
41
|
const CELL = 168;
|
|
42
|
+
const hover = "@media (hover: hover)";
|
|
42
43
|
|
|
43
44
|
export function MediaGalleryPage({
|
|
44
45
|
pick = false,
|
|
45
46
|
onPick,
|
|
47
|
+
pickedUrls,
|
|
48
|
+
onToggleUrl,
|
|
46
49
|
}: {
|
|
47
50
|
pick?: boolean;
|
|
48
51
|
onPick?: (url: string) => void;
|
|
52
|
+
pickedUrls?: string[];
|
|
53
|
+
onToggleUrl?: (url: string) => void;
|
|
49
54
|
}) {
|
|
50
55
|
const { workspace } = useOutletContext<WorkspaceOutletContext>();
|
|
51
56
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
@@ -168,7 +173,6 @@ export function MediaGalleryPage({
|
|
|
168
173
|
}, [uploadFiles]);
|
|
169
174
|
|
|
170
175
|
useEffect(() => {
|
|
171
|
-
if (pick) return;
|
|
172
176
|
const hasFiles = (event: DragEvent) =>
|
|
173
177
|
Array.from(event.dataTransfer?.types ?? []).includes("Files");
|
|
174
178
|
const onEnter = (event: DragEvent) => {
|
|
@@ -202,7 +206,7 @@ export function MediaGalleryPage({
|
|
|
202
206
|
window.removeEventListener("dragleave", onLeave);
|
|
203
207
|
window.removeEventListener("drop", onDrop);
|
|
204
208
|
};
|
|
205
|
-
}, [
|
|
209
|
+
}, [uploadFiles]);
|
|
206
210
|
|
|
207
211
|
const browsable = [
|
|
208
212
|
...state.pending.flatMap((item) => (item.media ? [item.media] : [])),
|
|
@@ -400,6 +404,7 @@ export function MediaGalleryPage({
|
|
|
400
404
|
<div {...stylex.props(styles.search)}>
|
|
401
405
|
<Input
|
|
402
406
|
aria-label="Search media"
|
|
407
|
+
data-no-ring={pick ? "" : undefined}
|
|
403
408
|
placeholder="Search"
|
|
404
409
|
value={draft}
|
|
405
410
|
onChange={(event) => setDraft(event.target.value)}
|
|
@@ -479,10 +484,19 @@ export function MediaGalleryPage({
|
|
|
479
484
|
<MediaHit
|
|
480
485
|
item={cell.item}
|
|
481
486
|
menu={!pick}
|
|
482
|
-
selected={
|
|
487
|
+
selected={
|
|
488
|
+
onToggleUrl
|
|
489
|
+
? (pickedUrls?.includes(cell.item.url) ?? false)
|
|
490
|
+
: !pick && !sharedId && cell.item.id === selectedId
|
|
491
|
+
}
|
|
483
492
|
canDelete={canDelete}
|
|
493
|
+
onUnpick={onToggleUrl ? () => onToggleUrl(cell.item.url) : undefined}
|
|
484
494
|
onOpen={() => {
|
|
485
495
|
setSelectedId(null);
|
|
496
|
+
if (onToggleUrl) {
|
|
497
|
+
if (!pickedUrls?.includes(cell.item.url)) onToggleUrl(cell.item.url);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
486
500
|
if (pick) {
|
|
487
501
|
if (onPick) onPick(cell.item.url);
|
|
488
502
|
return;
|
|
@@ -544,6 +558,7 @@ function MediaHit({
|
|
|
544
558
|
canDelete,
|
|
545
559
|
onOpen,
|
|
546
560
|
onDelete,
|
|
561
|
+
onUnpick,
|
|
547
562
|
}: {
|
|
548
563
|
item: CatalogMedia;
|
|
549
564
|
menu: boolean;
|
|
@@ -551,18 +566,41 @@ function MediaHit({
|
|
|
551
566
|
canDelete: boolean;
|
|
552
567
|
onOpen: () => void;
|
|
553
568
|
onDelete: () => void;
|
|
569
|
+
onUnpick?: () => void;
|
|
554
570
|
}) {
|
|
555
571
|
const image = (
|
|
556
572
|
<button
|
|
557
573
|
type="button"
|
|
558
574
|
aria-current={selected ? "true" : undefined}
|
|
559
|
-
{...stylex.props(
|
|
575
|
+
{...stylex.props(
|
|
576
|
+
styles.hit,
|
|
577
|
+
!menu && styles.placed,
|
|
578
|
+
selected && styles.selected,
|
|
579
|
+
selected && onUnpick && styles.picked,
|
|
580
|
+
)}
|
|
560
581
|
onClick={onOpen}
|
|
561
582
|
>
|
|
562
583
|
<img src={item.thumbUrl} alt={item.alt?.trim() || item.filename} {...stylex.props(styles.image)} />
|
|
563
584
|
</button>
|
|
564
585
|
);
|
|
565
|
-
if (!menu)
|
|
586
|
+
if (!menu) {
|
|
587
|
+
if (!selected || !onUnpick) return image;
|
|
588
|
+
return (
|
|
589
|
+
<>
|
|
590
|
+
{image}
|
|
591
|
+
<button
|
|
592
|
+
type="button"
|
|
593
|
+
aria-label={`Remove ${item.filename} from selection`}
|
|
594
|
+
{...stylex.props(styles.unpick)}
|
|
595
|
+
onClick={onUnpick}
|
|
596
|
+
>
|
|
597
|
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
598
|
+
<path d="M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
599
|
+
</svg>
|
|
600
|
+
</button>
|
|
601
|
+
</>
|
|
602
|
+
);
|
|
603
|
+
}
|
|
566
604
|
return (
|
|
567
605
|
<ContextMenu.Root>
|
|
568
606
|
<ContextMenu.Trigger className={cx(styles.menuHit)}>{image}</ContextMenu.Trigger>
|
|
@@ -739,6 +777,32 @@ const styles = stylex.create({
|
|
|
739
777
|
outlineColor: colors.focus,
|
|
740
778
|
outlineOffset: 3,
|
|
741
779
|
},
|
|
780
|
+
picked: {
|
|
781
|
+
cursor: "default",
|
|
782
|
+
},
|
|
783
|
+
unpick: {
|
|
784
|
+
position: "absolute",
|
|
785
|
+
top: "12px",
|
|
786
|
+
right: "12px",
|
|
787
|
+
display: "flex",
|
|
788
|
+
alignItems: "center",
|
|
789
|
+
justifyContent: "center",
|
|
790
|
+
width: "26px",
|
|
791
|
+
height: "26px",
|
|
792
|
+
padding: 0,
|
|
793
|
+
borderWidth: 1,
|
|
794
|
+
borderStyle: "solid",
|
|
795
|
+
borderColor: "rgba(255, 255, 255, 0.6)",
|
|
796
|
+
borderRadius: "999px",
|
|
797
|
+
backgroundColor: "rgba(24, 24, 27, 0.85)",
|
|
798
|
+
color: "#fafafa",
|
|
799
|
+
cursor: "pointer",
|
|
800
|
+
[hover]: {
|
|
801
|
+
":hover": {
|
|
802
|
+
backgroundColor: "rgba(24, 24, 27, 1)",
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
},
|
|
742
806
|
menuHit: {
|
|
743
807
|
position: "absolute",
|
|
744
808
|
inset: space.sm,
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
// packages/studio/src/pages/PreviewAddress.tsx
|
|
2
|
+
import { useEffect, useRef, useState, type FormEvent } from "react";
|
|
3
|
+
import { Combobox } from "@base-ui/react/combobox";
|
|
4
|
+
import {
|
|
5
|
+
IconArrowRotateClockwise,
|
|
6
|
+
IconArrowUpRight,
|
|
7
|
+
IconGlobe,
|
|
8
|
+
} from "@central-icons-react/round-outlined-radius-2-stroke-1.5";
|
|
9
|
+
import * as stylex from "@stylexjs/stylex";
|
|
10
|
+
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
11
|
+
import { cx, popup, popupClassName } from "../ui/popup";
|
|
12
|
+
import { hostPath } from "../host-path";
|
|
13
|
+
import { routesMatching } from "../content-routes";
|
|
14
|
+
|
|
15
|
+
const hover = "@media (hover: hover)";
|
|
16
|
+
|
|
17
|
+
/** Reload, the page path, and open. The path opens the route list. */
|
|
18
|
+
export function PreviewAddress({
|
|
19
|
+
path,
|
|
20
|
+
enabled,
|
|
21
|
+
routes,
|
|
22
|
+
routesPending,
|
|
23
|
+
onOpenRoutes,
|
|
24
|
+
onPath,
|
|
25
|
+
onReload,
|
|
26
|
+
onOpen,
|
|
27
|
+
liveHref,
|
|
28
|
+
}: {
|
|
29
|
+
path: string;
|
|
30
|
+
enabled: boolean;
|
|
31
|
+
routes: readonly string[];
|
|
32
|
+
routesPending: boolean;
|
|
33
|
+
onOpenRoutes?: () => void;
|
|
34
|
+
onPath: (path: string) => void;
|
|
35
|
+
onReload: () => void;
|
|
36
|
+
onOpen: () => void;
|
|
37
|
+
/** Committed page on the public site. Absent when this model has no route. */
|
|
38
|
+
liveHref?: string | null;
|
|
39
|
+
}) {
|
|
40
|
+
const [query, setQuery] = useState<string | null>(null);
|
|
41
|
+
const [open, setOpen] = useState(false);
|
|
42
|
+
const picked = useRef(false);
|
|
43
|
+
const fieldRef = useRef<HTMLButtonElement>(null);
|
|
44
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
45
|
+
const shown = query ? routesMatching(routes, query) : [...routes];
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!open) return;
|
|
49
|
+
const input = inputRef.current;
|
|
50
|
+
input?.focus();
|
|
51
|
+
input?.select();
|
|
52
|
+
}, [open]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div {...stylex.props(styles.address)}>
|
|
56
|
+
<button
|
|
57
|
+
type="button"
|
|
58
|
+
aria-label="Reload preview"
|
|
59
|
+
disabled={!enabled}
|
|
60
|
+
onClick={onReload}
|
|
61
|
+
{...stylex.props(styles.iconButton)}
|
|
62
|
+
>
|
|
63
|
+
<IconArrowRotateClockwise size={14} ariaHidden />
|
|
64
|
+
</button>
|
|
65
|
+
<Combobox.Root
|
|
66
|
+
items={shown}
|
|
67
|
+
filteredItems={shown}
|
|
68
|
+
inputValue={query ?? ""}
|
|
69
|
+
disabled={!enabled}
|
|
70
|
+
open={open}
|
|
71
|
+
value={routes.includes(path) ? path : null}
|
|
72
|
+
onOpenChange={(next) => {
|
|
73
|
+
if (!enabled && next) return;
|
|
74
|
+
setOpen(next);
|
|
75
|
+
if (next) onOpenRoutes?.();
|
|
76
|
+
else setQuery(null);
|
|
77
|
+
}}
|
|
78
|
+
onInputValueChange={(value, details) => {
|
|
79
|
+
if (details.reason === "input-change" || details.reason === "input-clear") {
|
|
80
|
+
setQuery(value);
|
|
81
|
+
}
|
|
82
|
+
}}
|
|
83
|
+
onValueChange={(value) => {
|
|
84
|
+
if (typeof value !== "string") return;
|
|
85
|
+
picked.current = true;
|
|
86
|
+
setQuery(null);
|
|
87
|
+
onPath(hostPath(value));
|
|
88
|
+
queueMicrotask(() => {
|
|
89
|
+
picked.current = false;
|
|
90
|
+
});
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<Combobox.Trigger
|
|
94
|
+
ref={fieldRef}
|
|
95
|
+
aria-label="Preview path"
|
|
96
|
+
disabled={!enabled}
|
|
97
|
+
data-no-ring
|
|
98
|
+
className={cx(styles.addressTrigger)}
|
|
99
|
+
>
|
|
100
|
+
<IconGlobe size={13} ariaHidden />
|
|
101
|
+
<span {...stylex.props(styles.addressPath)}>{path}</span>
|
|
102
|
+
</Combobox.Trigger>
|
|
103
|
+
<Combobox.Portal>
|
|
104
|
+
<Combobox.Positioner
|
|
105
|
+
anchor={fieldRef}
|
|
106
|
+
side="bottom"
|
|
107
|
+
align="start"
|
|
108
|
+
sideOffset={6}
|
|
109
|
+
className={cx(popup.positioner)}
|
|
110
|
+
>
|
|
111
|
+
<Combobox.Popup
|
|
112
|
+
aria-label="Pages"
|
|
113
|
+
className={(state) => popupClassName(state, styles.routePopup)}
|
|
114
|
+
>
|
|
115
|
+
<form
|
|
116
|
+
onSubmit={(event: FormEvent<HTMLFormElement>) => {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
const fromList = picked.current;
|
|
119
|
+
picked.current = false;
|
|
120
|
+
if (fromList) return;
|
|
121
|
+
const typed = event.currentTarget.querySelector("input")?.value;
|
|
122
|
+
if (typed?.trim()) onPath(hostPath(typed));
|
|
123
|
+
setOpen(false);
|
|
124
|
+
setQuery(null);
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<Combobox.Input
|
|
128
|
+
ref={inputRef}
|
|
129
|
+
placeholder="Find a page"
|
|
130
|
+
aria-label="Find a page"
|
|
131
|
+
spellCheck={false}
|
|
132
|
+
autoComplete="off"
|
|
133
|
+
data-no-ring
|
|
134
|
+
className={cx(popup.quietInput, styles.routeSearch)}
|
|
135
|
+
onKeyDown={(event) => {
|
|
136
|
+
if (event.key !== "Enter") return;
|
|
137
|
+
// A highlighted row is chosen by the combobox. A bare Enter goes to the typed path.
|
|
138
|
+
if (event.currentTarget.getAttribute("aria-activedescendant")) return;
|
|
139
|
+
const typed = event.currentTarget.value.trim();
|
|
140
|
+
if (!typed) return;
|
|
141
|
+
picked.current = true;
|
|
142
|
+
onPath(hostPath(typed));
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
</form>
|
|
146
|
+
<div {...stylex.props(popup.separator)} />
|
|
147
|
+
<Combobox.Empty className={cx(popup.empty)}>
|
|
148
|
+
{routesPending ? "Loading pages" : "No pages"}
|
|
149
|
+
</Combobox.Empty>
|
|
150
|
+
<Combobox.List className={cx(styles.routeList)}>
|
|
151
|
+
{(route: string) => (
|
|
152
|
+
<Combobox.Item
|
|
153
|
+
key={route}
|
|
154
|
+
value={route}
|
|
155
|
+
className={(state) =>
|
|
156
|
+
cx(
|
|
157
|
+
popup.item,
|
|
158
|
+
styles.routeItem,
|
|
159
|
+
state.highlighted && popup.itemHighlighted,
|
|
160
|
+
state.selected && popup.itemSelected,
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
>
|
|
164
|
+
{route}
|
|
165
|
+
</Combobox.Item>
|
|
166
|
+
)}
|
|
167
|
+
</Combobox.List>
|
|
168
|
+
</Combobox.Popup>
|
|
169
|
+
</Combobox.Positioner>
|
|
170
|
+
</Combobox.Portal>
|
|
171
|
+
</Combobox.Root>
|
|
172
|
+
<button
|
|
173
|
+
type="button"
|
|
174
|
+
aria-label="Open preview in a new tab"
|
|
175
|
+
disabled={!enabled}
|
|
176
|
+
onClick={onOpen}
|
|
177
|
+
{...stylex.props(styles.iconButton)}
|
|
178
|
+
>
|
|
179
|
+
<IconArrowUpRight size={14} ariaHidden />
|
|
180
|
+
</button>
|
|
181
|
+
{liveHref ? (
|
|
182
|
+
<a href={liveHref} target="_blank" rel="noreferrer" {...stylex.props(styles.liveLink)}>
|
|
183
|
+
View live
|
|
184
|
+
</a>
|
|
185
|
+
) : null}
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const styles = stylex.create({
|
|
191
|
+
address: {
|
|
192
|
+
display: "flex",
|
|
193
|
+
alignItems: "center",
|
|
194
|
+
gap: space.xs,
|
|
195
|
+
minWidth: 0,
|
|
196
|
+
},
|
|
197
|
+
addressTrigger: {
|
|
198
|
+
display: "flex",
|
|
199
|
+
flex: 1,
|
|
200
|
+
alignItems: "center",
|
|
201
|
+
gap: space.xs,
|
|
202
|
+
minWidth: 0,
|
|
203
|
+
height: "28px",
|
|
204
|
+
paddingInline: space.sm,
|
|
205
|
+
borderWidth: 0,
|
|
206
|
+
borderRadius: "999px",
|
|
207
|
+
font: "inherit",
|
|
208
|
+
textAlign: "left",
|
|
209
|
+
cursor: { default: "pointer", ":disabled": "default" },
|
|
210
|
+
color: { default: colors.textMuted, ":disabled": colors.textMuted },
|
|
211
|
+
backgroundColor: colors.bgPanelInset,
|
|
212
|
+
":focus-visible": {
|
|
213
|
+
outlineWidth: 2,
|
|
214
|
+
outlineStyle: "solid",
|
|
215
|
+
outlineColor: colors.focus,
|
|
216
|
+
outlineOffset: 1,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
addressPath: {
|
|
220
|
+
flex: 1,
|
|
221
|
+
minWidth: 0,
|
|
222
|
+
overflow: "hidden",
|
|
223
|
+
textOverflow: "ellipsis",
|
|
224
|
+
whiteSpace: "nowrap",
|
|
225
|
+
fontFamily: type.mono,
|
|
226
|
+
fontSize: type.xs,
|
|
227
|
+
color: colors.text,
|
|
228
|
+
},
|
|
229
|
+
routeSearch: {
|
|
230
|
+
fontFamily: type.mono,
|
|
231
|
+
fontSize: type.xs,
|
|
232
|
+
},
|
|
233
|
+
routePopup: {
|
|
234
|
+
width: "var(--anchor-width)",
|
|
235
|
+
minWidth: "220px",
|
|
236
|
+
maxHeight: "min(320px, var(--available-height))",
|
|
237
|
+
display: "flex",
|
|
238
|
+
flexDirection: "column",
|
|
239
|
+
overflowY: "hidden",
|
|
240
|
+
},
|
|
241
|
+
routeList: {
|
|
242
|
+
minHeight: 0,
|
|
243
|
+
overflowY: "auto",
|
|
244
|
+
},
|
|
245
|
+
routeItem: {
|
|
246
|
+
fontFamily: type.mono,
|
|
247
|
+
},
|
|
248
|
+
liveLink: {
|
|
249
|
+
display: "inline-flex",
|
|
250
|
+
alignItems: "center",
|
|
251
|
+
flexShrink: 0,
|
|
252
|
+
height: "28px",
|
|
253
|
+
paddingInline: space.sm,
|
|
254
|
+
borderRadius: radius.sm,
|
|
255
|
+
color: {
|
|
256
|
+
default: colors.textMuted,
|
|
257
|
+
[hover]: { default: colors.textMuted, ":hover": colors.text },
|
|
258
|
+
},
|
|
259
|
+
fontSize: type.xs,
|
|
260
|
+
fontWeight: 500,
|
|
261
|
+
whiteSpace: "nowrap",
|
|
262
|
+
textDecoration: "none",
|
|
263
|
+
":focus-visible": {
|
|
264
|
+
outlineWidth: 2,
|
|
265
|
+
outlineStyle: "solid",
|
|
266
|
+
outlineColor: colors.focus,
|
|
267
|
+
outlineOffset: 1,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
iconButton: {
|
|
271
|
+
display: "inline-flex",
|
|
272
|
+
alignItems: "center",
|
|
273
|
+
justifyContent: "center",
|
|
274
|
+
flexShrink: 0,
|
|
275
|
+
width: "28px",
|
|
276
|
+
height: "28px",
|
|
277
|
+
padding: 0,
|
|
278
|
+
borderWidth: 0,
|
|
279
|
+
borderRadius: radius.sm,
|
|
280
|
+
cursor: { default: "pointer", ":disabled": "default" },
|
|
281
|
+
color: { default: colors.textMuted, ":disabled": colors.border },
|
|
282
|
+
backgroundColor: {
|
|
283
|
+
default: "transparent",
|
|
284
|
+
[hover]: { default: null, ":hover:not(:disabled)": colors.bgHover },
|
|
285
|
+
},
|
|
286
|
+
":focus-visible": {
|
|
287
|
+
outlineWidth: 2,
|
|
288
|
+
outlineStyle: "solid",
|
|
289
|
+
outlineColor: colors.focus,
|
|
290
|
+
outlineOffset: 1,
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
@@ -82,7 +82,7 @@ function UncommittedCard({ summary }: { summary: HomeSummary }) {
|
|
|
82
82
|
return (
|
|
83
83
|
<section {...stylex.props(styles.card, styles.span)}>
|
|
84
84
|
<Text size="sm" tone="muted" weight="medium">
|
|
85
|
-
|
|
85
|
+
Unpublished
|
|
86
86
|
</Text>
|
|
87
87
|
<p {...stylex.props(styles.value)}>{summary.uncommitted}</p>
|
|
88
88
|
<Text size="sm" tone={summary.conflicts > 0 ? "danger" : "muted"}>
|
|
@@ -29,15 +29,3 @@ export function bootSteps(input: {
|
|
|
29
29
|
if (input.phase === "stopped") return at(0, "failed");
|
|
30
30
|
return at(input.furthest === "starting" ? 2 : input.furthest === "installing" ? 1 : 0, "failed");
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
/** Normalizes what someone types in the address bar to a path inside the host. */
|
|
34
|
-
export function hostPath(input: string): string {
|
|
35
|
-
const trimmed = input.trim();
|
|
36
|
-
if (!trimmed) return "/";
|
|
37
|
-
try {
|
|
38
|
-
const url = new URL(trimmed);
|
|
39
|
-
return `${url.pathname}${url.search}${url.hash}` || "/";
|
|
40
|
-
} catch {
|
|
41
|
-
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// packages/studio/src/pages/media-selection.ts
|
|
2
|
+
|
|
3
|
+
export function toggleMediaUrl(urls: readonly string[], url: string): string[] {
|
|
4
|
+
const index = urls.indexOf(url);
|
|
5
|
+
if (index >= 0) {
|
|
6
|
+
return urls.filter((_, i) => i !== index);
|
|
7
|
+
}
|
|
8
|
+
return [...urls, url];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function appendMediaUrls(
|
|
12
|
+
existing: readonly string[],
|
|
13
|
+
incoming: readonly string[],
|
|
14
|
+
): string[] {
|
|
15
|
+
const next = [...existing];
|
|
16
|
+
for (const url of incoming) {
|
|
17
|
+
if (!next.includes(url)) {
|
|
18
|
+
next.push(url);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return next;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function moveMediaUrl(urls: readonly string[], from: number, to: number): string[] {
|
|
25
|
+
if (from < 0 || from >= urls.length || to < 0 || to >= urls.length) {
|
|
26
|
+
return [...urls];
|
|
27
|
+
}
|
|
28
|
+
const next = [...urls];
|
|
29
|
+
const [item] = next.splice(from, 1);
|
|
30
|
+
next.splice(to, 0, item!);
|
|
31
|
+
return next;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function acceptedDrop(
|
|
35
|
+
existing: readonly string[],
|
|
36
|
+
accepted: readonly string[],
|
|
37
|
+
multiple: boolean,
|
|
38
|
+
): { urls: string[]; notAdded: number } {
|
|
39
|
+
if (!multiple) {
|
|
40
|
+
if (accepted.length === 0) {
|
|
41
|
+
return { urls: [...existing], notAdded: 0 };
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
urls: [accepted[0]!],
|
|
45
|
+
notAdded: Math.max(0, accepted.length - 1),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { urls: appendMediaUrls(existing, accepted), notAdded: 0 };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function notAddedMessage(count: number): string | null {
|
|
52
|
+
if (count === 0) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (count === 1) {
|
|
56
|
+
return "1 image was not added";
|
|
57
|
+
}
|
|
58
|
+
return `${count} images were not added`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function editorUrls(
|
|
62
|
+
value: unknown,
|
|
63
|
+
multiple: boolean,
|
|
64
|
+
): { urls: string[]; raw: unknown } {
|
|
65
|
+
if (value === undefined || value === null || value === "") {
|
|
66
|
+
return { urls: [], raw: undefined };
|
|
67
|
+
}
|
|
68
|
+
if (typeof value === "string") {
|
|
69
|
+
return { urls: [value], raw: value };
|
|
70
|
+
}
|
|
71
|
+
if (Array.isArray(value)) {
|
|
72
|
+
if (multiple) {
|
|
73
|
+
const urls = value.filter((item): item is string => typeof item === "string");
|
|
74
|
+
return { urls, raw: value };
|
|
75
|
+
}
|
|
76
|
+
return { urls: [], raw: value };
|
|
77
|
+
}
|
|
78
|
+
return { urls: [], raw: undefined };
|
|
79
|
+
}
|
|
@@ -54,6 +54,7 @@ const styles = stylex.create({
|
|
|
54
54
|
bgPanel: { backgroundColor: colors.bgPanel },
|
|
55
55
|
bgPanelInset: { backgroundColor: colors.bgPanelInset },
|
|
56
56
|
bgSurface: { backgroundColor: colors.bgSurface },
|
|
57
|
+
bgRaised: { backgroundColor: colors.bgRaised },
|
|
57
58
|
bgHover: { backgroundColor: colors.bgHover },
|
|
58
59
|
bgActive: { backgroundColor: colors.bgActive },
|
|
59
60
|
bgInput: { backgroundColor: colors.bgInput },
|
|
@@ -77,6 +78,7 @@ const SWATCHES = [
|
|
|
77
78
|
["bgPanel", styles.bgPanel],
|
|
78
79
|
["bgPanelInset", styles.bgPanelInset],
|
|
79
80
|
["bgSurface", styles.bgSurface],
|
|
81
|
+
["bgRaised", styles.bgRaised],
|
|
80
82
|
["bgHover", styles.bgHover],
|
|
81
83
|
["bgActive", styles.bgActive],
|
|
82
84
|
["bgInput", styles.bgInput],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/studio/src/pages/ui-kit/fields.tsx
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { FieldControl } from "../../fields/FieldControl";
|
|
3
4
|
import { Field } from "../../ui/Field";
|
|
4
5
|
import { Input, Select, Textarea } from "../../ui/Input";
|
|
5
6
|
import { Columns, Specimen, Topic } from "./topic";
|
|
@@ -7,6 +8,53 @@ import { UI_KIT_TOPICS } from "./topics";
|
|
|
7
8
|
|
|
8
9
|
const topic = UI_KIT_TOPICS.find((item) => item.slug === "fields")!;
|
|
9
10
|
|
|
11
|
+
function SliderSpecimen({
|
|
12
|
+
label,
|
|
13
|
+
initial,
|
|
14
|
+
readOnly = false,
|
|
15
|
+
}: {
|
|
16
|
+
label: string;
|
|
17
|
+
initial: number | undefined;
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
}) {
|
|
20
|
+
const [value, setValue] = useState<unknown>(initial);
|
|
21
|
+
return (
|
|
22
|
+
<Field label={label}>
|
|
23
|
+
<FieldControl
|
|
24
|
+
name={label}
|
|
25
|
+
field={{ kind: "number", min: 1, max: 8, step: 1 }}
|
|
26
|
+
value={value}
|
|
27
|
+
models={[]}
|
|
28
|
+
objects={[]}
|
|
29
|
+
ancestorObjectNames={[]}
|
|
30
|
+
readOnly={readOnly}
|
|
31
|
+
onChange={setValue}
|
|
32
|
+
/>
|
|
33
|
+
</Field>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function RelationSpecimen() {
|
|
38
|
+
const [value, setValue] = useState<string | null>(null);
|
|
39
|
+
return (
|
|
40
|
+
<Field label="Sales contact">
|
|
41
|
+
<Select
|
|
42
|
+
searchable
|
|
43
|
+
chip
|
|
44
|
+
clearable
|
|
45
|
+
placeholder="Select a value"
|
|
46
|
+
aria-label="Sales contact"
|
|
47
|
+
value={value}
|
|
48
|
+
onValueChange={setValue}
|
|
49
|
+
options={[
|
|
50
|
+
{ value: "jonah", label: "Jonah Wren" },
|
|
51
|
+
{ value: "mae", label: "Mae Holt" },
|
|
52
|
+
]}
|
|
53
|
+
/>
|
|
54
|
+
</Field>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
10
58
|
export function FieldsTopic() {
|
|
11
59
|
const [locale, setLocale] = useState("en");
|
|
12
60
|
|
|
@@ -23,6 +71,9 @@ export function FieldsTopic() {
|
|
|
23
71
|
<Input defaultValue="Locked" disabled />
|
|
24
72
|
</Field>
|
|
25
73
|
</Specimen>
|
|
74
|
+
<Specimen label="Relation" block>
|
|
75
|
+
<RelationSpecimen />
|
|
76
|
+
</Specimen>
|
|
26
77
|
<Specimen label="Select" block>
|
|
27
78
|
<Field label="Select">
|
|
28
79
|
<Select
|
|
@@ -36,6 +87,15 @@ export function FieldsTopic() {
|
|
|
36
87
|
/>
|
|
37
88
|
</Field>
|
|
38
89
|
</Specimen>
|
|
90
|
+
<Specimen label="Slider" block>
|
|
91
|
+
<SliderSpecimen label="Beds" initial={4} />
|
|
92
|
+
</Specimen>
|
|
93
|
+
<Specimen label="Slider empty" block>
|
|
94
|
+
<SliderSpecimen label="Baths" initial={undefined} />
|
|
95
|
+
</Specimen>
|
|
96
|
+
<Specimen label="Slider locked" block>
|
|
97
|
+
<SliderSpecimen label="Limit" initial={8} readOnly />
|
|
98
|
+
</Specimen>
|
|
39
99
|
<Specimen label="Textarea" block>
|
|
40
100
|
<Field label="Body">
|
|
41
101
|
<Textarea mono rows={4} defaultValue={"---\ntitle: Hello\n---\n\nParagraph."} />
|
package/src/styles/themes.ts
CHANGED
|
@@ -8,6 +8,7 @@ export const lightTheme = stylex.createTheme(colors, {
|
|
|
8
8
|
bgPanel: "#f4f4f5",
|
|
9
9
|
bgPanelInset: "#ececef",
|
|
10
10
|
bgSurface: "#ffffff",
|
|
11
|
+
bgRaised: "#ffffff",
|
|
11
12
|
bgHover: "rgba(24, 24, 27, 0.05)",
|
|
12
13
|
bgActive: "rgba(24, 24, 27, 0.08)",
|
|
13
14
|
bgInput: "#ffffff",
|
|
@@ -31,6 +32,7 @@ export const darkTheme = stylex.createTheme(colors, {
|
|
|
31
32
|
bgPanel: "#131316",
|
|
32
33
|
bgPanelInset: "#0f0f12",
|
|
33
34
|
bgSurface: "#1f1f23",
|
|
35
|
+
bgRaised: "#2c2c32",
|
|
34
36
|
bgHover: "rgba(255, 255, 255, 0.06)",
|
|
35
37
|
bgActive: "rgba(255, 255, 255, 0.1)",
|
|
36
38
|
bgInput: "#18181b",
|