@backmatter/studio 0.0.18 → 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-DkuQBiQZ.js → UiKitApp-B1ANqCac.js} +528 -481
- package/dist/chunks/{WorkspaceRoutes-DVvb3N-V.js → WorkspaceRoutes-BHNGrf-j.js} +24371 -23915
- package/dist/chunks/{dashboard-B4FITg6c.js → dashboard-b-W6dGm5.js} +586 -565
- package/dist/chunks/{index-CegtXnEI.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 +159 -36
- package/package.json +2 -2
- package/src/api.ts +41 -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/fields/FieldControl.tsx +173 -62
- package/src/pages/DocEditorPage.tsx +47 -64
- 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 +155 -63
- package/src/pages/MediaGalleryPage.tsx +56 -3
- package/src/pages/PreviewAddress.tsx +30 -0
- package/src/pages/WorkspaceHomePage.tsx +1 -1
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/studio/src/pages/MediaFieldInput.tsx
|
|
2
|
-
import { useCallback, useEffect, useRef, useState, type DragEvent } from "react";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState, type DragEvent, type KeyboardEvent } from "react";
|
|
3
3
|
import { Dialog } from "@base-ui/react/dialog";
|
|
4
4
|
import { mediaIdFromUrl, mediaVariantUrl } from "@backmatter/core";
|
|
5
5
|
import * as stylex from "@stylexjs/stylex";
|
|
@@ -61,6 +61,9 @@ export function MediaFieldInput({
|
|
|
61
61
|
const [notAdded, setNotAdded] = useState(0);
|
|
62
62
|
const [pending, setPending] = useState<PendingUpload[]>([]);
|
|
63
63
|
const dragFrom = useRef<number | null>(null);
|
|
64
|
+
const [dropIndex, setDropIndex] = useState<number | null>(null);
|
|
65
|
+
const focusIndex = useRef<number | null>(null);
|
|
66
|
+
const gridRef = useRef<HTMLDivElement>(null);
|
|
64
67
|
const valueRef = useRef(value);
|
|
65
68
|
valueRef.current = value;
|
|
66
69
|
const onChangeRef = useRef(onChange);
|
|
@@ -171,12 +174,34 @@ export function MediaFieldInput({
|
|
|
171
174
|
event.preventDefault();
|
|
172
175
|
const from = dragFrom.current;
|
|
173
176
|
dragFrom.current = null;
|
|
177
|
+
setDropIndex(null);
|
|
174
178
|
if (from === null || from === toIndex) return;
|
|
175
179
|
write(moveMediaUrl(savedUrls, from, toIndex));
|
|
176
180
|
},
|
|
177
181
|
[savedUrls, write],
|
|
178
182
|
);
|
|
179
183
|
|
|
184
|
+
const onThumbKeyDown = useCallback(
|
|
185
|
+
(index: number, event: KeyboardEvent) => {
|
|
186
|
+
if (!event.altKey) return;
|
|
187
|
+
const step = event.key === "ArrowLeft" ? -1 : event.key === "ArrowRight" ? 1 : 0;
|
|
188
|
+
const to = index + step;
|
|
189
|
+
if (step === 0 || to < 0 || to >= savedUrls.length) return;
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
if (to >= GALLERY_PER_ROW) setExpanded(true);
|
|
192
|
+
focusIndex.current = to;
|
|
193
|
+
write(moveMediaUrl(savedUrls, index, to));
|
|
194
|
+
},
|
|
195
|
+
[savedUrls, write],
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
const index = focusIndex.current;
|
|
200
|
+
if (index === null) return;
|
|
201
|
+
focusIndex.current = null;
|
|
202
|
+
gridRef.current?.querySelectorAll<HTMLElement>("[data-media-thumb]")[index]?.focus();
|
|
203
|
+
});
|
|
204
|
+
|
|
180
205
|
const note = notAddedMessage(notAdded);
|
|
181
206
|
const messages = [...rejections, ...(note ? [note] : [])];
|
|
182
207
|
|
|
@@ -224,23 +249,39 @@ export function MediaFieldInput({
|
|
|
224
249
|
>
|
|
225
250
|
{multiple && showThumb ? (
|
|
226
251
|
<div {...stylex.props(styles.galleryStack)}>
|
|
227
|
-
<div data-media-grid {...stylex.props(styles.galleryGrid)}>
|
|
252
|
+
<div ref={gridRef} data-media-grid {...stylex.props(styles.galleryGrid)}>
|
|
228
253
|
{galleryUrls.map((url, index) => {
|
|
229
254
|
const thumb = thumbForUrl(url);
|
|
230
255
|
return (
|
|
231
256
|
<div
|
|
232
257
|
key={`${url}-${index}`}
|
|
233
258
|
data-media-thumb
|
|
259
|
+
role="group"
|
|
260
|
+
aria-label={`Image ${index + 1} of ${savedUrls.length}`}
|
|
261
|
+
aria-keyshortcuts={readOnly ? undefined : "Alt+ArrowLeft Alt+ArrowRight"}
|
|
262
|
+
tabIndex={readOnly ? undefined : 0}
|
|
234
263
|
draggable={!readOnly}
|
|
235
|
-
{...stylex.props(
|
|
264
|
+
{...stylex.props(
|
|
265
|
+
styles.thumbWrap,
|
|
266
|
+
!readOnly && styles.thumbMovable,
|
|
267
|
+
dropIndex === index && styles.thumbDropTarget,
|
|
268
|
+
)}
|
|
269
|
+
onKeyDown={readOnly ? undefined : (event) => onThumbKeyDown(index, event)}
|
|
236
270
|
onDragStart={() => {
|
|
237
271
|
dragFrom.current = index;
|
|
238
272
|
}}
|
|
239
|
-
|
|
273
|
+
onDragEnd={() => {
|
|
274
|
+
dragFrom.current = null;
|
|
275
|
+
setDropIndex(null);
|
|
276
|
+
}}
|
|
277
|
+
onDragOver={(event) => {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
if (dragFrom.current !== null && dropIndex !== index) setDropIndex(index);
|
|
280
|
+
}}
|
|
240
281
|
onDrop={(event) => onThumbDrop(index, event)}
|
|
241
282
|
>
|
|
242
283
|
{thumb ? (
|
|
243
|
-
<img src={thumb} alt="" {...stylex.props(styles.galleryTile)} />
|
|
284
|
+
<img src={thumb} alt="" draggable={false} {...stylex.props(styles.galleryTile)} />
|
|
244
285
|
) : (
|
|
245
286
|
<div {...stylex.props(styles.galleryTile, styles.moreEmpty)} />
|
|
246
287
|
)}
|
|
@@ -251,7 +292,7 @@ export function MediaFieldInput({
|
|
|
251
292
|
{...stylex.props(styles.galleryRemove)}
|
|
252
293
|
onClick={() => removeAt(index)}
|
|
253
294
|
>
|
|
254
|
-
|
|
295
|
+
<CloseIcon />
|
|
255
296
|
</button>
|
|
256
297
|
)}
|
|
257
298
|
</div>
|
|
@@ -262,31 +303,25 @@ export function MediaFieldInput({
|
|
|
262
303
|
<img src={item.previewUrl} alt="" {...stylex.props(styles.galleryTile, styles.pending)} />
|
|
263
304
|
</div>
|
|
264
305
|
))}
|
|
306
|
+
{readOnly ? null : (
|
|
307
|
+
<button
|
|
308
|
+
type="button"
|
|
309
|
+
aria-label="Add images"
|
|
310
|
+
{...stylex.props(styles.galleryTile, styles.addTile)}
|
|
311
|
+
onClick={openModal}
|
|
312
|
+
>
|
|
313
|
+
<PlusIcon />
|
|
314
|
+
</button>
|
|
315
|
+
)}
|
|
265
316
|
</div>
|
|
266
|
-
{hiddenCount > 0
|
|
267
|
-
<
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
{expanded ? "Show less" : "Show more"}
|
|
275
|
-
</button>
|
|
276
|
-
) : (
|
|
277
|
-
<span />
|
|
278
|
-
)}
|
|
279
|
-
{readOnly ? null : (
|
|
280
|
-
<button
|
|
281
|
-
type="button"
|
|
282
|
-
aria-label="Edit image"
|
|
283
|
-
{...stylex.props(styles.iconBtn)}
|
|
284
|
-
onClick={openModal}
|
|
285
|
-
>
|
|
286
|
-
<PencilIcon />
|
|
287
|
-
</button>
|
|
288
|
-
)}
|
|
289
|
-
</div>
|
|
317
|
+
{hiddenCount > 0 ? (
|
|
318
|
+
<button
|
|
319
|
+
type="button"
|
|
320
|
+
{...stylex.props(styles.showMore)}
|
|
321
|
+
onClick={() => setExpanded((current) => !current)}
|
|
322
|
+
>
|
|
323
|
+
{expanded ? "Show less" : `Show ${hiddenCount} more`}
|
|
324
|
+
</button>
|
|
290
325
|
) : null}
|
|
291
326
|
</div>
|
|
292
327
|
) : multiple && pending[0] ? (
|
|
@@ -472,6 +507,14 @@ function PencilIcon() {
|
|
|
472
507
|
);
|
|
473
508
|
}
|
|
474
509
|
|
|
510
|
+
function PlusIcon() {
|
|
511
|
+
return (
|
|
512
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
513
|
+
<path d="M8 3.5V12.5M3.5 8H12.5" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" />
|
|
514
|
+
</svg>
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
|
|
475
518
|
function CloseIcon() {
|
|
476
519
|
return (
|
|
477
520
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
@@ -480,11 +523,6 @@ function CloseIcon() {
|
|
|
480
523
|
);
|
|
481
524
|
}
|
|
482
525
|
|
|
483
|
-
const fade = stylex.keyframes({
|
|
484
|
-
from: { opacity: 0 },
|
|
485
|
-
to: { opacity: 1 },
|
|
486
|
-
});
|
|
487
|
-
|
|
488
526
|
const styles = stylex.create({
|
|
489
527
|
stack: {
|
|
490
528
|
display: "flex",
|
|
@@ -506,44 +544,67 @@ const styles = stylex.create({
|
|
|
506
544
|
galleryStack: {
|
|
507
545
|
display: "flex",
|
|
508
546
|
flexDirection: "column",
|
|
509
|
-
gap: space.
|
|
510
|
-
width: "
|
|
511
|
-
maxWidth: "100%",
|
|
547
|
+
gap: space.sm,
|
|
548
|
+
width: "100%",
|
|
512
549
|
},
|
|
513
550
|
galleryGrid: {
|
|
514
551
|
display: "grid",
|
|
515
|
-
gridTemplateColumns: "repeat(
|
|
516
|
-
gap:
|
|
552
|
+
gridTemplateColumns: "repeat(auto-fill, 72px)",
|
|
553
|
+
gap: space.sm,
|
|
517
554
|
},
|
|
518
555
|
galleryTile: {
|
|
519
|
-
|
|
520
|
-
|
|
556
|
+
display: "block",
|
|
557
|
+
width: "72px",
|
|
558
|
+
height: "72px",
|
|
521
559
|
objectFit: "cover",
|
|
522
|
-
borderRadius: radius.
|
|
560
|
+
borderRadius: radius.md,
|
|
523
561
|
backgroundColor: colors.bgPanel,
|
|
524
562
|
},
|
|
525
563
|
galleryRemove: {
|
|
526
564
|
position: "absolute",
|
|
527
|
-
top:
|
|
528
|
-
right:
|
|
529
|
-
|
|
530
|
-
|
|
565
|
+
top: space.xs,
|
|
566
|
+
right: space.xs,
|
|
567
|
+
display: "flex",
|
|
568
|
+
alignItems: "center",
|
|
569
|
+
justifyContent: "center",
|
|
570
|
+
width: "22px",
|
|
571
|
+
height: "22px",
|
|
531
572
|
padding: 0,
|
|
532
|
-
borderWidth:
|
|
573
|
+
borderWidth: 1,
|
|
574
|
+
borderStyle: "solid",
|
|
575
|
+
borderColor: "rgba(255, 255, 255, 0.6)",
|
|
533
576
|
borderRadius: "999px",
|
|
534
|
-
backgroundColor:
|
|
535
|
-
color:
|
|
577
|
+
backgroundColor: "rgba(24, 24, 27, 0.85)",
|
|
578
|
+
color: "#fafafa",
|
|
536
579
|
cursor: "pointer",
|
|
537
|
-
|
|
538
|
-
|
|
580
|
+
opacity: {
|
|
581
|
+
default: "var(--remove-opacity, 0)",
|
|
582
|
+
":focus-visible": 1,
|
|
583
|
+
},
|
|
584
|
+
transitionProperty: "opacity",
|
|
585
|
+
transitionDuration: "120ms",
|
|
539
586
|
},
|
|
540
|
-
|
|
587
|
+
addTile: {
|
|
541
588
|
display: "flex",
|
|
542
589
|
alignItems: "center",
|
|
543
|
-
justifyContent: "
|
|
544
|
-
|
|
590
|
+
justifyContent: "center",
|
|
591
|
+
boxSizing: "border-box",
|
|
592
|
+
padding: 0,
|
|
593
|
+
borderWidth: 1,
|
|
594
|
+
borderStyle: "dashed",
|
|
595
|
+
borderColor: colors.border,
|
|
596
|
+
backgroundColor: "transparent",
|
|
597
|
+
color: colors.textMuted,
|
|
598
|
+
cursor: "pointer",
|
|
599
|
+
[hover]: {
|
|
600
|
+
":hover": {
|
|
601
|
+
backgroundColor: colors.bgHover,
|
|
602
|
+
color: colors.text,
|
|
603
|
+
},
|
|
604
|
+
},
|
|
545
605
|
},
|
|
546
606
|
showMore: {
|
|
607
|
+
alignSelf: "flex-start",
|
|
547
608
|
padding: 0,
|
|
548
609
|
borderWidth: 0,
|
|
549
610
|
backgroundColor: "transparent",
|
|
@@ -563,6 +624,30 @@ const styles = stylex.create({
|
|
|
563
624
|
},
|
|
564
625
|
thumbWrap: {
|
|
565
626
|
position: "relative",
|
|
627
|
+
borderRadius: radius.md,
|
|
628
|
+
"--remove-opacity": {
|
|
629
|
+
default: 0,
|
|
630
|
+
":hover": 1,
|
|
631
|
+
":focus-within": 1,
|
|
632
|
+
"@media (hover: none)": 1,
|
|
633
|
+
},
|
|
634
|
+
outlineOffset: 2,
|
|
635
|
+
":focus-visible": {
|
|
636
|
+
outlineWidth: 2,
|
|
637
|
+
outlineStyle: "solid",
|
|
638
|
+
outlineColor: colors.focus,
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
thumbMovable: {
|
|
642
|
+
cursor: "grab",
|
|
643
|
+
":active": {
|
|
644
|
+
cursor: "grabbing",
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
thumbDropTarget: {
|
|
648
|
+
outlineWidth: 2,
|
|
649
|
+
outlineStyle: "dashed",
|
|
650
|
+
outlineColor: colors.focus,
|
|
566
651
|
},
|
|
567
652
|
thumb: {
|
|
568
653
|
width: "4.5rem",
|
|
@@ -675,10 +760,11 @@ const styles = stylex.create({
|
|
|
675
760
|
zIndex: z.overlay,
|
|
676
761
|
backgroundColor: colors.overlay,
|
|
677
762
|
backdropFilter: "blur(8px)",
|
|
678
|
-
|
|
679
|
-
|
|
763
|
+
transitionProperty: "opacity",
|
|
764
|
+
transitionDuration: "160ms",
|
|
765
|
+
transitionTimingFunction: "ease-out",
|
|
680
766
|
"@media (prefers-reduced-motion: reduce)": {
|
|
681
|
-
|
|
767
|
+
transitionDuration: "0ms",
|
|
682
768
|
},
|
|
683
769
|
},
|
|
684
770
|
backdropHidden: {
|
|
@@ -686,20 +772,26 @@ const styles = stylex.create({
|
|
|
686
772
|
},
|
|
687
773
|
popup: {
|
|
688
774
|
position: "fixed",
|
|
689
|
-
|
|
690
|
-
left: "50%",
|
|
775
|
+
inset: "clamp(12px, 3vw, 32px)",
|
|
691
776
|
zIndex: z.palette,
|
|
692
|
-
transform: "translateX(-50%)",
|
|
693
|
-
width: "min(960px, calc(100vw - 32px))",
|
|
694
|
-
height: "min(720px, 80vh)",
|
|
695
777
|
display: "flex",
|
|
696
778
|
flexDirection: "column",
|
|
697
779
|
backgroundColor: colors.bgSurface,
|
|
698
780
|
borderRadius: radius.md,
|
|
781
|
+
boxShadow: "0 24px 64px rgba(0, 0, 0, 0.35)",
|
|
699
782
|
overflow: "hidden",
|
|
783
|
+
outline: "none",
|
|
784
|
+
transformOrigin: "center",
|
|
785
|
+
transitionProperty: "opacity, transform",
|
|
786
|
+
transitionDuration: "160ms",
|
|
787
|
+
transitionTimingFunction: "cubic-bezier(0.2, 0, 0, 1)",
|
|
788
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
789
|
+
transitionDuration: "0ms",
|
|
790
|
+
},
|
|
700
791
|
},
|
|
701
792
|
popupHidden: {
|
|
702
793
|
opacity: 0,
|
|
794
|
+
transform: "scale(0.98)",
|
|
703
795
|
},
|
|
704
796
|
title: {
|
|
705
797
|
margin: 0,
|
|
@@ -39,6 +39,7 @@ 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,
|
|
@@ -403,6 +404,7 @@ export function MediaGalleryPage({
|
|
|
403
404
|
<div {...stylex.props(styles.search)}>
|
|
404
405
|
<Input
|
|
405
406
|
aria-label="Search media"
|
|
407
|
+
data-no-ring={pick ? "" : undefined}
|
|
406
408
|
placeholder="Search"
|
|
407
409
|
value={draft}
|
|
408
410
|
onChange={(event) => setDraft(event.target.value)}
|
|
@@ -488,10 +490,11 @@ export function MediaGalleryPage({
|
|
|
488
490
|
: !pick && !sharedId && cell.item.id === selectedId
|
|
489
491
|
}
|
|
490
492
|
canDelete={canDelete}
|
|
493
|
+
onUnpick={onToggleUrl ? () => onToggleUrl(cell.item.url) : undefined}
|
|
491
494
|
onOpen={() => {
|
|
492
495
|
setSelectedId(null);
|
|
493
496
|
if (onToggleUrl) {
|
|
494
|
-
onToggleUrl(cell.item.url);
|
|
497
|
+
if (!pickedUrls?.includes(cell.item.url)) onToggleUrl(cell.item.url);
|
|
495
498
|
return;
|
|
496
499
|
}
|
|
497
500
|
if (pick) {
|
|
@@ -555,6 +558,7 @@ function MediaHit({
|
|
|
555
558
|
canDelete,
|
|
556
559
|
onOpen,
|
|
557
560
|
onDelete,
|
|
561
|
+
onUnpick,
|
|
558
562
|
}: {
|
|
559
563
|
item: CatalogMedia;
|
|
560
564
|
menu: boolean;
|
|
@@ -562,18 +566,41 @@ function MediaHit({
|
|
|
562
566
|
canDelete: boolean;
|
|
563
567
|
onOpen: () => void;
|
|
564
568
|
onDelete: () => void;
|
|
569
|
+
onUnpick?: () => void;
|
|
565
570
|
}) {
|
|
566
571
|
const image = (
|
|
567
572
|
<button
|
|
568
573
|
type="button"
|
|
569
574
|
aria-current={selected ? "true" : undefined}
|
|
570
|
-
{...stylex.props(
|
|
575
|
+
{...stylex.props(
|
|
576
|
+
styles.hit,
|
|
577
|
+
!menu && styles.placed,
|
|
578
|
+
selected && styles.selected,
|
|
579
|
+
selected && onUnpick && styles.picked,
|
|
580
|
+
)}
|
|
571
581
|
onClick={onOpen}
|
|
572
582
|
>
|
|
573
583
|
<img src={item.thumbUrl} alt={item.alt?.trim() || item.filename} {...stylex.props(styles.image)} />
|
|
574
584
|
</button>
|
|
575
585
|
);
|
|
576
|
-
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
|
+
}
|
|
577
604
|
return (
|
|
578
605
|
<ContextMenu.Root>
|
|
579
606
|
<ContextMenu.Trigger className={cx(styles.menuHit)}>{image}</ContextMenu.Trigger>
|
|
@@ -750,6 +777,32 @@ const styles = stylex.create({
|
|
|
750
777
|
outlineColor: colors.focus,
|
|
751
778
|
outlineOffset: 3,
|
|
752
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
|
+
},
|
|
753
806
|
menuHit: {
|
|
754
807
|
position: "absolute",
|
|
755
808
|
inset: space.sm,
|
|
@@ -24,6 +24,7 @@ export function PreviewAddress({
|
|
|
24
24
|
onPath,
|
|
25
25
|
onReload,
|
|
26
26
|
onOpen,
|
|
27
|
+
liveHref,
|
|
27
28
|
}: {
|
|
28
29
|
path: string;
|
|
29
30
|
enabled: boolean;
|
|
@@ -33,6 +34,8 @@ export function PreviewAddress({
|
|
|
33
34
|
onPath: (path: string) => void;
|
|
34
35
|
onReload: () => void;
|
|
35
36
|
onOpen: () => void;
|
|
37
|
+
/** Committed page on the public site. Absent when this model has no route. */
|
|
38
|
+
liveHref?: string | null;
|
|
36
39
|
}) {
|
|
37
40
|
const [query, setQuery] = useState<string | null>(null);
|
|
38
41
|
const [open, setOpen] = useState(false);
|
|
@@ -175,6 +178,11 @@ export function PreviewAddress({
|
|
|
175
178
|
>
|
|
176
179
|
<IconArrowUpRight size={14} ariaHidden />
|
|
177
180
|
</button>
|
|
181
|
+
{liveHref ? (
|
|
182
|
+
<a href={liveHref} target="_blank" rel="noreferrer" {...stylex.props(styles.liveLink)}>
|
|
183
|
+
View live
|
|
184
|
+
</a>
|
|
185
|
+
) : null}
|
|
178
186
|
</div>
|
|
179
187
|
);
|
|
180
188
|
}
|
|
@@ -237,6 +245,28 @@ const styles = stylex.create({
|
|
|
237
245
|
routeItem: {
|
|
238
246
|
fontFamily: type.mono,
|
|
239
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
|
+
},
|
|
240
270
|
iconButton: {
|
|
241
271
|
display: "inline-flex",
|
|
242
272
|
alignItems: "center",
|
|
@@ -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"}>
|
|
@@ -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",
|