Desk Window

@sushindustries/ui

A window you can drag, resize, close and stack, without re-rendering its contents every frame.

6 min read
View as MarkdownEdit on GitHub
Viewport width
Phone22remthe floor, the narrowest this promises to work at
tanstacktanstack add https://adamjurek.com/r/tanstack/desk-window.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/desk-window.json

One rule

Position is written to the element during the drag, and to state only on release.

Sixty state updates a second would re-render the window's whole contents on every frame of every drag, and the contents of these are grids of icons. During a drag the handler writes two custom properties straight onto the node; when the pointer lifts, exactly one state update records where it ended up.

.desk-window {
	translate: var(--win-x, 0) var(--win-y, 0);
	width: var(--w, min(30rem, calc(100% - var(--s-5))));
}
css

var(--w, <default>) is what lets one rule serve both a window nobody has resized and one somebody has, with no second class.

Where this is used

Every open folder and every page shown on the home page desktop. FolderShelf owns which windows exist; this owns how one behaves.

Install

tanstack add https://adamjurek.com/r/tanstack/desk-window.json
shell
pnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/desk-window.json
shell
pnpm add @sushindustries/ui @sushindustries/atoms
shell

What you get

Version0.1.0
Categorylayout · Overlays
Filesdesk-window.tsx
DependenciesNone
Also installsiconIconThe glyph set, generated from a Markdown table where every drawing carries its reason. One component, typed names, no icon font.@sushindustries/ui · content
Tagsblock, drag, pointer, touch, no-deps

No runtime dependencies

It brings nothing with it beyond the stylesheet.

UsesIconIconThe glyph set, generated from a Markdown table where every drawing carries its reason. One component, typed names, no icon font.@sushindustries/ui · content
Used byFolder ShelfFolder ShelfA desktop of folders that open into draggable windows, several at once, remembered between visits.@sushindustries/ui · layout