Fit the studio's toolbar, popups and right panel to its islands

This commit is contained in:
piexel committed 2026-11-11 00:52:59 +01:00
1 parent 9f3da18f2b
commit 4bdac458c0
14 files changed
+49 -50

No files matched your search

@@ -7,7 +7,7 @@ function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
className={cn( className={cn(
"pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none", "pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none",
"[&_svg:not([class*='size-'])]:size-3", "[&_svg:not([class*='size-'])]:size-3",
"[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10", "[[data-slot=tooltip-content]_&]:bg-secondary [[data-slot=tooltip-content]_&]:text-secondary-text",
className className
)} )}
{...props} {...props}
@@ -31,7 +31,7 @@ function TooltipTrigger({
function TooltipContent({ function TooltipContent({
className, className,
sideOffset = 0, sideOffset = 6,
children, children,
...props ...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) { }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
@@ -41,13 +41,12 @@ function TooltipContent({
data-slot="tooltip-content" data-slot="tooltip-content"
sideOffset={sideOffset} sideOffset={sideOffset}
className={cn( className={cn(
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95", "z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md border border-overlay-border bg-popover px-2.5 py-1.5 text-xs text-balance text-popover-foreground shadow-md fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
className className
)} )}
{...props} {...props}
> >
{children} {children}
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" />
</TooltipPrimitive.Content> </TooltipPrimitive.Content>
</TooltipPrimitive.Portal> </TooltipPrimitive.Portal>
) )
+4 -2
View File
@@ -52,9 +52,10 @@ export function HoverCard({ hover, point, viewId, previewing, detailed, minY }:
return ( return (
<div <div
ref={card} ref={card}
className="pointer-events-none absolute z-10 w-80 rounded-[10px] border border-overlay-border bg-popover px-3.5 py-3 text-popover-foreground shadow-xl backdrop-blur-sm" className="pointer-events-none absolute z-10 w-80 overflow-hidden rounded-lg border border-overlay-border bg-popover text-popover-foreground shadow-lg"
style={position} style={position}
> >
<div className="px-3.5 pt-3 pb-2.5">
<Header subject={subject} region={labelsRegions ? null : hover.region} /> <Header subject={subject} region={labelsRegions ? null : hover.region} />
{parent !== null && <p className="mt-0.5 truncate text-[12px] text-secondary-text">child of {parent}</p>} {parent !== null && <p className="mt-0.5 truncate text-[12px] text-secondary-text">child of {parent}</p>}
<p className="mt-0.5 truncate text-[12px] text-secondary-text tabular-nums">{ground(hover, minY)}</p> <p className="mt-0.5 truncate text-[12px] text-secondary-text tabular-nums">{ground(hover, minY)}</p>
@@ -72,7 +73,8 @@ export function HoverCard({ hover, point, viewId, previewing, detailed, minY }:
</dl> </dl>
</section> </section>
))} ))}
<div className="mt-2.5 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground"> </div>
<div className="flex flex-wrap gap-x-3 gap-y-1 border-t bg-background/40 px-3.5 py-1.5 text-[11px] text-secondary-text">
{!detailed && <Hint keyText="Shift" label="More" />} {!detailed && <Hint keyText="Shift" label="More" />}
{highlightKey !== '' && <Hint keyText={highlightKey} label="Highlight" />} {highlightKey !== '' && <Hint keyText={highlightKey} label="Highlight" />}
<Hint keyText="Alt+Click" label="Open file" /> <Hint keyText="Alt+Click" label="Open file" />
+1 -1
View File
@@ -27,7 +27,7 @@ export function Legend({ title, shares, selection, emptyText = 'Drawing the map
const sharedNames = namesUsedMoreThanOnce(shares) const sharedNames = namesUsedMoreThanOnce(shares)
return ( return (
<section className={cn('flex min-h-0 flex-col', className)}> <section className={cn('flex min-h-0 flex-col', className)}>
<h2 className="px-4 pt-2.5 pb-1.5 text-[11px] font-semibold text-muted-foreground">{title}</h2> <h2 className="truncate px-4 pt-2.5 pb-2 text-[13px] font-semibold">{title}</h2>
<ScrollArea className="min-h-0 flex-1"> <ScrollArea className="min-h-0 flex-1">
<ul className="px-1.5 pb-1"> <ul className="px-1.5 pb-1">
{shares.length === 0 && <li className="px-2.5 py-1 text-muted-foreground">{emptyText}</li>} {shares.length === 0 && <li className="px-2.5 py-1 text-muted-foreground">{emptyText}</li>}
+19 -15
View File
@@ -228,8 +228,8 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
onDisconnect={onDisconnect} onDisconnect={onDisconnect}
/> />
<SidebarSlot.Provider value={sidebarSlot}> <SidebarSlot.Provider value={sidebarSlot}>
<div className="relative flex min-h-0 flex-1 gap-1.5 p-1.5"> <div className="flex min-h-0 flex-1 gap-1.5 p-1.5">
<ViewList views={views} current={viewId} onSelect={selectView} slotRef={setSidebarSlot} floating={showsMap} /> <ViewList views={views} current={viewId} onSelect={selectView} slotRef={setSidebarSlot} />
{viewId === 'regions' && regions.length > 1 && ( {viewId === 'regions' && regions.length > 1 && (
<SidebarPanel className="flex-1 overflow-y-auto p-1.5"> <SidebarPanel className="flex-1 overflow-y-auto p-1.5">
<RegionPreviewList regions={regions} current={layer.preview} onSelect={selectPreview} /> <RegionPreviewList regions={regions} current={layer.preview} onSelect={selectPreview} />
@@ -279,21 +279,25 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
</div> </div>
)} )}
</div> </div>
<Panel className="w-[250px]"> <div className="flex w-[250px] shrink-0 flex-col gap-1.5">
{inspectsPicks && ( {inspectsPicks && (
<PickInspector <Panel className="min-h-0 flex-[7]">
title={previewName ?? view.label} <PickInspector
inspection={inspection} title={previewName ?? view.label}
display={{ picksLabel: viewId === 'regions' && layer.preview === null ? 'Regions' : 'Biomes', value: pickDisplay, onChange: setPickDisplay }} inspection={inspection}
/> display={{ picksLabel: viewId === 'regions' && layer.preview === null ? 'Regions' : 'Biomes', value: pickDisplay, onChange: setPickDisplay }}
/>
</Panel>
)} )}
<Legend <Panel className="min-h-0 flex-[3]">
className={inspectsPicks ? 'flex-[3]' : 'flex-1'} <Legend
title={legendTitle(layer)} className="flex-1"
shares={shares} title={legendTitle(layer)}
selection={{ highlight, onSelect: (subject) => setHighlight((current) => (sameSubject(current, subject) ? null : subject)) }} shares={shares}
/> selection={{ highlight, onSelect: (subject) => setHighlight((current) => (sameSubject(current, subject) ? null : subject)) }}
</Panel> />
</Panel>
</div>
</> </>
)} )}
</div> </div>
@@ -31,7 +31,7 @@ const DEFAULT_RELIEF_BLOCKS = 64
const RELIEF_STEPS = 1000 const RELIEF_STEPS = 1000
const SWATCH_STEPS = 24 const SWATCH_STEPS = 24
const TOGGLE_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground' const TOGGLE_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground'
const PILL = 'pointer-events-none absolute rounded-md border border-overlay-border bg-card/90 px-3 py-1.5 text-[12px] text-secondary-text' const PILL = 'pointer-events-none absolute rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text'
interface NoiseStudioProps { interface NoiseStudioProps {
client: BridgeClient client: BridgeClient
@@ -94,7 +94,7 @@ export function NoiseStudio({ client, packRevision, onSummary, tell }: NoiseStud
<NoiseTerrainView client={client} source={source} seed={seed} revision={packRevision} framing={terrainFraming} scale={scale} reliefBlocks={reliefBlocks} tell={tell} /> <NoiseTerrainView client={client} source={source} seed={seed} revision={packRevision} framing={terrainFraming} scale={scale} reliefBlocks={reliefBlocks} tell={tell} />
)} )}
<div className="absolute top-3 left-3 flex items-center gap-2"> <div className="absolute top-3 left-3 flex items-center gap-2">
<ToggleGroup type="single" variant="outline" size="sm" className="bg-card/90" value={display} onValueChange={(value) => value !== '' && showAs(value as NoiseDisplay)}> <ToggleGroup type="single" variant="outline" size="sm" className="bg-card" value={display} onValueChange={(value) => value !== '' && showAs(value as NoiseDisplay)}>
<ToggleGroupItem value="flat" className={TOGGLE_ITEM} title="The noise from above, coloured by value"> <ToggleGroupItem value="flat" className={TOGGLE_ITEM} title="The noise from above, coloured by value">
2D 2D
</ToggleGroupItem> </ToggleGroupItem>
@@ -103,7 +103,7 @@ export function NoiseStudio({ client, packRevision, onSummary, tell }: NoiseStud
</ToggleGroupItem> </ToggleGroupItem>
</ToggleGroup> </ToggleGroup>
{display === 'flat' && ( {display === 'flat' && (
<Button variant="outline" size="icon-sm" className="bg-card/90" title="Back to 0, 0" onClick={() => controllerRef.current?.resetView()}> <Button variant="outline" size="icon-sm" className="bg-card" title="Back to 0, 0" onClick={() => controllerRef.current?.resetView()}>
<IdeIcon name="reset" /> <IdeIcon name="reset" />
</Button> </Button>
)} )}
@@ -261,7 +261,7 @@ function ReliefControl({ blocks, onChange }: { blocks: number; onChange(blocks:
const span = Math.log(TALLEST_RELIEF_BLOCKS) - Math.log(LOWEST_RELIEF_BLOCKS) const span = Math.log(TALLEST_RELIEF_BLOCKS) - Math.log(LOWEST_RELIEF_BLOCKS)
const step = Math.round(((Math.log(blocks) - Math.log(LOWEST_RELIEF_BLOCKS)) / span) * RELIEF_STEPS) const step = Math.round(((Math.log(blocks) - Math.log(LOWEST_RELIEF_BLOCKS)) / span) * RELIEF_STEPS)
return ( return (
<label className="flex h-8 items-center gap-2 rounded-md border bg-card/90 px-3 text-[12px] text-secondary-text" title="How many blocks the highest noise rises above the lowest"> <label className="flex h-8 items-center gap-2 rounded-md border bg-card px-3 text-[12px] text-secondary-text" title="How many blocks the highest noise rises above the lowest">
Relief Relief
<input <input
type="range" type="range"
@@ -25,7 +25,7 @@ interface LegendBlocks {
} }
const EMPTY_LEGEND: LegendBlocks = { examples: new Map(), someNone: false } const EMPTY_LEGEND: LegendBlocks = { examples: new Map(), someNone: false }
const PILL = 'pointer-events-none absolute rounded-md border border-overlay-border bg-card/90 px-3 py-1.5 text-[12px] text-secondary-text' const PILL = 'pointer-events-none absolute rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text'
interface PatternStudioProps { interface PatternStudioProps {
client: BridgeClient client: BridgeClient
@@ -64,7 +64,7 @@ export function PatternStudio({ client, view, packRevision, onSummary, tell }: P
<> <>
<div className="relative min-w-0 flex-1 overflow-hidden rounded-lg"> <div className="relative min-w-0 flex-1 overflow-hidden rounded-lg">
<TiledCanvas create={createView} viewRef={viewRef} className="absolute inset-0 size-full cursor-grab active:cursor-grabbing" /> <TiledCanvas create={createView} viewRef={viewRef} className="absolute inset-0 size-full cursor-grab active:cursor-grabbing" />
<div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card/90 p-1 text-[12px] tabular-nums"> <div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card p-1 text-[12px] tabular-nums">
{entry !== null && entry.depths > 1 && ( {entry !== null && entry.depths > 1 && (
<> <>
<Button variant="ghost" size="icon-sm" title="Higher" onClick={() => chooseDepth(depth - 1)}> <Button variant="ghost" size="icon-sm" title="Higher" onClick={() => chooseDepth(depth - 1)}>
@@ -32,7 +32,7 @@ interface PickInspectorProps {
*/ */
export function PickInspector({ title, inspection, display }: PickInspectorProps): React.JSX.Element { export function PickInspector({ title, inspection, display }: PickInspectorProps): React.JSX.Element {
return ( return (
<section className="flex min-h-0 flex-[7] flex-col border-b"> <section className="flex min-h-0 flex-1 flex-col">
<header className="px-4 pt-2.5 pb-2.5"> <header className="px-4 pt-2.5 pb-2.5">
<h2 className="truncate text-[13px] font-semibold">{title}</h2> <h2 className="truncate text-[13px] font-semibold">{title}</h2>
<p className="truncate text-[11.5px] text-secondary-text">{inspection?.detail ?? 'Measuring what is in view…'}</p> <p className="truncate text-[11.5px] text-secondary-text">{inspection?.detail ?? 'Measuring what is in view…'}</p>
@@ -23,7 +23,7 @@ const NUMBER = new Intl.NumberFormat('en-US')
// Saved tiles are read at up to 16 blocks a pixel, which is level 4. // Saved tiles are read at up to 16 blocks a pixel, which is level 4.
const COARSEST_SAVED_LEVEL = 4 const COARSEST_SAVED_LEVEL = 4
const COLORING_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground' const COLORING_ITEM = 'h-7 px-3 text-[12px] data-[state=on]:bg-selection data-[state=on]:text-foreground'
const PILL = 'pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card/90 px-3 py-1.5 text-[12px] text-secondary-text' const PILL = 'pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text'
interface SavedWorldStudioProps { interface SavedWorldStudioProps {
client: BridgeClient client: BridgeClient
@@ -93,7 +93,7 @@ export function SavedWorldStudio({ client, world, onSummary, onProgress, tell }:
type="single" type="single"
variant="outline" variant="outline"
size="sm" size="sm"
className="bg-card/90" className="bg-card"
value={coloring} value={coloring}
onValueChange={(value) => value !== '' && setColoring(value as SavedTerrainColoring)} onValueChange={(value) => value !== '' && setColoring(value as SavedTerrainColoring)}
> >
@@ -107,7 +107,7 @@ export function SavedWorldStudio({ client, world, onSummary, onProgress, tell }:
Height Height
</ToggleGroupItem> </ToggleGroupItem>
</ToggleGroup> </ToggleGroup>
<Button variant="outline" size="icon-sm" className="bg-card/90" title="Read again" disabled={reading} onClick={() => setReadings((count) => count + 1)}> <Button variant="outline" size="icon-sm" className="bg-card" title="Read again" disabled={reading} onClick={() => setReadings((count) => count + 1)}>
<IdeIcon name="refresh" /> <IdeIcon name="refresh" />
</Button> </Button>
</div> </div>
@@ -166,7 +166,7 @@ function SceneArea({ entry, variant, shown, status, onVariant, onPick }: SceneAr
<div className="relative min-h-0 flex-[11] overflow-hidden rounded-lg"> <div className="relative min-h-0 flex-[11] overflow-hidden rounded-lg">
<SceneViewport content={shown?.mesh.content ?? null} framing={shown?.scene} onPick={onPick} /> <SceneViewport content={shown?.mesh.content ?? null} framing={shown?.scene} onPick={onPick} />
{entry !== null && entry.variants > 1 && ( {entry !== null && entry.variants > 1 && (
<div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card/90 p-1 text-[12px] tabular-nums"> <div className="absolute top-3 left-3 flex items-center gap-1 rounded-md border border-overlay-border bg-card p-1 text-[12px] tabular-nums">
<Button variant="ghost" size="icon-sm" title="Previous variant" onClick={() => onVariant(variant - 1)}> <Button variant="ghost" size="icon-sm" title="Previous variant" onClick={() => onVariant(variant - 1)}>
<IdeIcon name="chevronLeft" /> <IdeIcon name="chevronLeft" />
</Button> </Button>
@@ -179,7 +179,7 @@ function SceneArea({ entry, variant, shown, status, onVariant, onPick }: SceneAr
</div> </div>
)} )}
{status !== null && ( {status !== null && (
<div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card/90 px-3 py-1.5 text-[12px] text-secondary-text"> <div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text">
{status} {status}
</div> </div>
)} )}
@@ -49,8 +49,8 @@ export function StudioToolbar(props: StudioToolbarProps): React.JSX.Element {
<IdeIcon name="help" /> <IdeIcon name="help" />
</ToolButton> </ToolButton>
<IconHint hint="Change the studio's keys"> <IconHint hint="Change the studio's keys">
<Button variant="ghost" size="sm" className={TEXT_BUTTON} onClick={props.onSettings}> <Button variant="ghost" size="icon-sm" onClick={props.onSettings}>
Settings <IdeIcon name="settings" />
</Button> </Button>
</IconHint> </IconHint>
<IconHint hint="Back to the world list"> <IconHint hint="Back to the world list">
+3 -9
View File
@@ -27,19 +27,13 @@ interface ViewListProps {
onSelect(view: string): void onSelect(view: string): void
/** Receives the element the shown view fills with its own lists, under the views. */ /** Receives the element the shown view fills with its own lists, under the views. */
slotRef(element: HTMLElement | null): void slotRef(element: HTMLElement | null): void
/** Whether the island lies on top of the map, as in v3e, instead of taking a column of its own. */
floating: boolean
} }
const IN_COLUMN = 'bg-card'
const ON_THE_MAP =
'absolute top-3.5 left-3.5 z-10 max-h-[calc(100%-1.75rem)] border border-overlay-border bg-card/90 shadow-lg backdrop-blur-md'
/** The left island: the views the server offers in their groups, then the shown view's own lists. */ /** The left island: the views the server offers in their groups, then the shown view's own lists. */
export function ViewList({ views, current, onSelect, slotRef, floating }: ViewListProps): React.JSX.Element { export function ViewList({ views, current, onSelect, slotRef }: ViewListProps): React.JSX.Element {
const groups = [...new Set(views.map((view) => view.groupLabel))] const groups = [...new Set(views.map((view) => view.groupLabel))]
return ( return (
<div className={cn('flex w-60 shrink-0 flex-col overflow-hidden rounded-lg', floating ? ON_THE_MAP : IN_COLUMN)}> <div className="flex w-60 shrink-0 flex-col overflow-hidden rounded-lg bg-card">
<nav className="flex shrink-0 flex-col gap-2 overflow-y-auto p-1.5"> <nav className="flex shrink-0 flex-col gap-2 overflow-y-auto p-1.5">
{groups.map((group) => ( {groups.map((group) => (
<section key={group}> <section key={group}>
@@ -52,7 +46,7 @@ export function ViewList({ views, current, onSelect, slotRef, floating }: ViewLi
</section> </section>
))} ))}
</nav> </nav>
<div ref={slotRef} className="flex min-h-0 flex-1 flex-col border-t border-overlay-border/60 empty:hidden" /> <div ref={slotRef} className="flex min-h-0 flex-1 flex-col border-t empty:hidden" />
</div> </div>
) )
} }
@@ -75,7 +75,7 @@ export function WorldStudio3D({ client, world, mapArea, packRevision, onSummary,
type="single" type="single"
variant="outline" variant="outline"
size="sm" size="sm"
className="absolute top-3 left-3 bg-card/90" className="absolute top-3 left-3 bg-card"
value={coloring} value={coloring}
onValueChange={(value) => value !== '' && setColoring(value as MapTerrainColoring)} onValueChange={(value) => value !== '' && setColoring(value as MapTerrainColoring)}
> >
@@ -90,7 +90,7 @@ export function WorldStudio3D({ client, world, mapArea, packRevision, onSummary,
</ToggleGroupItem> </ToggleGroupItem>
</ToggleGroup> </ToggleGroup>
{sampling && ( {sampling && (
<div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card/90 px-3 py-1.5 text-[12px] text-secondary-text"> <div className="pointer-events-none absolute top-3 left-1/2 -translate-x-1/2 rounded-md border border-overlay-border bg-card px-3 py-1.5 text-[12px] text-secondary-text">
Sampling the terrain Sampling the terrain
</div> </div>
)} )}
+3 -3
View File
@@ -8,7 +8,7 @@
--foreground: #000000; --foreground: #000000;
--card: #f7f8fa; --card: #f7f8fa;
--card-foreground: #000000; --card-foreground: #000000;
--popover: rgb(255 255 255 / 0.94); --popover: #ffffff;
--popover-foreground: #000000; --popover-foreground: #000000;
--primary: #3574f0; --primary: #3574f0;
--primary-foreground: #ffffff; --primary-foreground: #ffffff;
@@ -37,7 +37,7 @@
--foreground: #dfe1e5; --foreground: #dfe1e5;
--card: #2b2d30; --card: #2b2d30;
--card-foreground: #dfe1e5; --card-foreground: #dfe1e5;
--popover: rgb(43 45 48 / 0.93); --popover: #2b2d30;
--popover-foreground: #dfe1e5; --popover-foreground: #dfe1e5;
--primary: #3574f0; --primary: #3574f0;
--primary-foreground: #ffffff; --primary-foreground: #ffffff;
@@ -53,7 +53,7 @@
--warning: #f2c55c; --warning: #f2c55c;
--success: #5fb865; --success: #5fb865;
--link: #548af7; --link: #548af7;
--border: #1e1f22; --border: #393b40;
--input: #4e5157; --input: #4e5157;
--ring: #3574f0; --ring: #3574f0;
--overlay-border: #43454a; --overlay-border: #43454a;