Lay the studio out as IntelliJ's islands: a view stripe, icon tools and a tinted frame

This commit is contained in:
piexel committed 2026-11-11 01:15:31 +01:00
1 parent 6cf5d7131b
commit 49e8bf7885
8 files changed
+60 -37

No files matched your search

@@ -61,7 +61,7 @@ function DialogContent({
<DialogPrimitive.Content
data-slot="dialog-content"
className={cn(
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
className
)}
{...props}
@@ -45,7 +45,7 @@ export function ConnectScreen({ connecting, error, onConnect, onLink }: ConnectS
}, [onConnect])
return (
<div className="flex h-full items-center justify-center bg-background">
<div className="window-frame flex h-full items-center justify-center">
<div className="w-[440px] rounded-xl border border-overlay-border bg-card p-6 shadow-lg">
<h1 className="text-[15px] font-semibold">Open a world</h1>
<p className="mt-1 text-secondary-text">
+2 -2
View File
@@ -212,10 +212,10 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
)
return (
<div className="flex h-full flex-col bg-background">
<div className="window-frame flex h-full flex-col">
<StudioToolbar world={world} theme={theme} onHelp={() => setHelpOpen(true)} onSettings={() => setSettingsOpen(true)} onDisconnect={onDisconnect} />
<SidebarSlot.Provider value={sidebarSlot}>
<div className="flex min-h-0 flex-1 gap-1.5 p-1.5">
<div className="flex min-h-0 flex-1 gap-1.5 px-1.5">
<ViewList views={views} current={viewId} onSelect={selectView} slotRef={setSidebarSlot} />
{viewId === 'regions' && regions.length > 1 && (
<SidebarPanel className="flex-1 overflow-y-auto p-1.5">
@@ -21,7 +21,7 @@ export function RegionPreviewList({ regions, current, onSelect }: RegionPreviewL
const shown = wanted === '' ? regions : regions.filter((region) => `${region.name} ${region.key}`.toLowerCase().includes(wanted))
return (
<section>
<h2 className="px-2 pt-1 pb-1.5 text-[11px] font-semibold text-muted-foreground">Preview a region</h2>
<h2 className="px-2 pt-1 pb-2 text-[13px] font-semibold">Preview a region</h2>
{regions.length >= SEARCHABLE_FROM_REGIONS && (
<Input
className="mb-1 h-7 text-[12px]"
+3 -2
View File
@@ -16,8 +16,9 @@ export function SidebarPanel({ className, children }: { className?: string; chil
return createPortal(<section className={cn('flex min-h-0 flex-col overflow-hidden', className)}>{children}</section>, slot)
}
/** One choice of a switch in an island's header: plain until chosen, like the header's other buttons. */
export const HEADER_CHOICE = 'h-7 flex-none rounded-md! px-2.5 text-[12.5px] font-normal hover:bg-accent hover:text-foreground data-[state=on]:bg-selection data-[state=on]:text-foreground'
/** One choice of a switch in an island's header: plain until chosen and outlined then, as IntelliJ's tabs are. */
export const HEADER_CHOICE =
'h-7 flex-none rounded-md! border border-transparent px-2.5 text-[12.5px] font-normal hover:bg-accent hover:text-foreground data-[state=on]:border-input data-[state=on]:bg-transparent data-[state=on]:text-foreground'
interface StepperProps {
/** Where the steps are now: "Variant 2 of 5". */
@@ -66,20 +66,20 @@ export function MapTools({ toggles, hasPlayers, onToggle, onRefresh, onResetZoom
return (
<>
<ToolToggle action="grid" hint="Show chunk and region borders" pressed={toggles.grid} onPressed={() => onToggle('grid')}>
<IdeIcon name="grid" className="size-3.5" /> Grid
<IdeIcon name="grid" />
</ToolToggle>
<ToolToggle action="borders" hint="Outline the regions on every view" pressed={toggles.regionBorders} onPressed={() => onToggle('regionBorders')}>
<IdeIcon name="views/regions" className="size-3.5" /> Borders
<IdeIcon name="views/regions" />
</ToolToggle>
<ToolToggle action="shading" hint="Shade hills and valleys" pressed={toggles.shading} onPressed={() => onToggle('shading')}>
<IdeIcon name="views/height" className="size-3.5" /> Shading
<IdeIcon name="views/height" />
</ToolToggle>
<Separator orientation="vertical" className="mx-1 h-4!" />
<ToolToggle action="entities" hint="Show mobs and other entities" pressed={toggles.entities} disabled={!hasPlayers} onPressed={() => onToggle('entities')}>
<IdeIcon name="user" className="size-3.5" /> Entities
<IdeIcon name="user" />
</ToolToggle>
<ToolToggle action="follow" hint="Keep your player in the middle" pressed={toggles.follow} disabled={!hasPlayers} onPressed={() => onToggle('follow')}>
<IdeIcon name="locate" className="size-3.5" /> Follow
<IdeIcon name="locate" />
</ToolToggle>
<Separator orientation="vertical" className="mx-1 h-4!" />
<ToolButton action="resetZoom" hint="Go back to the default zoom" onClick={onResetZoom}>
@@ -134,7 +134,7 @@ function ToolToggle({ action, hint, pressed, disabled, onPressed, children }: To
pressed={pressed}
disabled={disabled}
onPressedChange={onPressed}
className="h-7 gap-1.5 px-2 text-[12.5px] font-normal hover:bg-accent hover:text-foreground data-[state=on]:bg-selection data-[state=on]:text-foreground [&_svg:not([class*='size-'])]:size-3.5"
className="size-7 min-w-7 p-0 hover:bg-accent hover:text-foreground data-[state=on]:bg-selection data-[state=on]:text-foreground [&_svg:not([class*='size-'])]:size-3.5"
>
{children}
</Toggle>
+36 -21
View File
@@ -1,5 +1,7 @@
import { Fragment } from 'react'
import { IdeIcon, type IdeIconName } from '@/components/IdeIcon'
import { Kbd } from '@/components/ui/kbd'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
import { cn } from '@/lib/utils'
import type { ViewInfo } from '../bridge/types'
import { viewShortcutId } from './shortcuts'
@@ -25,43 +27,56 @@ interface ViewListProps {
views: ViewInfo[]
current: string
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, beside the views. */
slotRef(element: HTMLElement | null): void
}
/** The left island: the views the server offers in their groups, then the shown view's own lists. */
/**
* The views the server offers, as a stripe of buttons on the window's edge in their groups, and beside it the island
* the shown view fills with its own lists, which is not there for a view without any (IntelliJ's tool window stripe).
*/
export function ViewList({ views, current, onSelect, slotRef }: ViewListProps): React.JSX.Element {
const groups = [...new Set(views.map((view) => view.groupLabel))]
return (
<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">
{groups.map((group) => (
<section key={group}>
<h2 className="px-2 pt-1 pb-1 text-[11px] font-semibold text-muted-foreground">{group}</h2>
<>
<nav className="flex w-8 shrink-0 flex-col items-center gap-1.5 overflow-y-auto">
{groups.map((group, index) => (
<Fragment key={group}>
{index > 0 && <span className="my-0.5 h-px w-5 shrink-0 bg-input" />}
{views
.filter((view) => view.groupLabel === group)
.map((view) => (
<ViewRow key={view.id} view={view} selected={view.id === current} onSelect={() => onSelect(view.id)} />
<ViewButton key={view.id} view={view} selected={view.id === current} onSelect={() => onSelect(view.id)} />
))}
</section>
</Fragment>
))}
</nav>
<div ref={slotRef} className="flex min-h-0 flex-1 flex-col border-t empty:hidden" />
</div>
<div ref={slotRef} className="flex w-60 shrink-0 flex-col overflow-hidden rounded-lg bg-card empty:hidden" />
</>
)
}
function ViewRow({ view, selected, onSelect }: { view: ViewInfo; selected: boolean; onSelect(): void }): React.JSX.Element {
function ViewButton({ view, selected, onSelect }: { view: ViewInfo; selected: boolean; onSelect(): void }): React.JSX.Element {
const keyText = useKeyText()(viewShortcutId(view.id))
return (
<button
onClick={onSelect}
title={view.description}
className={cn('flex h-[26px] w-full items-center gap-2 rounded-md px-2 text-left', selected ? 'bg-selection' : 'hover:bg-accent')}
>
<IdeIcon name={VIEW_ICONS[view.id] ?? FALLBACK_ICON} className="size-3.5" />
<span className="min-w-0 flex-1 truncate">{view.label}</span>
{keyText !== '' && <Kbd className="h-4 min-w-4 border border-input/60 bg-transparent text-[10px] uppercase">{keyText}</Kbd>}
</button>
<Tooltip>
<TooltipTrigger asChild>
<button
onClick={onSelect}
aria-label={view.label}
aria-pressed={selected}
className={cn('flex size-8 shrink-0 items-center justify-center rounded-lg', selected ? 'bg-primary [&_img]:brightness-0 [&_img]:invert' : 'hover:bg-selection')}
>
<IdeIcon name={VIEW_ICONS[view.id] ?? FALLBACK_ICON} className="size-[18px]" />
</button>
</TooltipTrigger>
<TooltipContent side="right" className="flex max-w-64 flex-col items-start gap-0.5">
<span className="flex items-center gap-2 font-medium">
{view.label}
{keyText !== '' && <Kbd className="uppercase">{keyText}</Kbd>}
</span>
<span className="text-secondary-text">{view.description}</span>
</TooltipContent>
</Tooltip>
)
}
+10 -3
View File
@@ -4,7 +4,7 @@
/* The studio's colours, taken from the Swing studio (StudioTheme) so both look alike. */
:root {
--background: #ffffff;
--background: #dfe2e8;
--foreground: #000000;
--card: #f7f8fa;
--card-foreground: #000000;
@@ -28,7 +28,7 @@
--input: #c9ccd6;
--ring: #3574f0;
--overlay-border: #dfe1e5;
--map-background: #e4e6eb;
--map-background: #eceef2;
--radius: 10px;
}
@@ -57,7 +57,7 @@
--input: #4e5157;
--ring: #3574f0;
--overlay-border: #43454a;
--map-background: #16171a;
--map-background: #25272a;
}
@theme inline {
@@ -109,3 +109,10 @@
@apply bg-background text-foreground text-[13px] antialiased select-none;
}
}
/* The window around the islands: its colour, tinted with the accent from the top left corner as IntelliJ's islands theme does. */
.window-frame {
background:
radial-gradient(ellipse 55% 45% at 0% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent),
var(--background);
}