Desk Window
@sushindustries/uiA window you can drag, resize, close and stack, without re-rendering its contents every frame.
tanstacktanstack add https://adamjurek.com/r/tanstack/desk-window.jsonpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/desk-window.jsonOne 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(--x, 0) var(--y, 0);
width: var(--w, min(30rem, calc(100% - var(--s-5))));
}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.jsonpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/desk-window.jsonpnpm add @sushindustries/ui @sushindustries/atomsWhat you get
| Version | 0.1.0 |
| Category | layout · Overlays |
| Files | desk-window.tsx, icon.tsx |
| Dependencies | None |
| Tags | block, drag, pointer, touch, no-deps |
No runtime dependencies
It brings nothing with it beyond the stylesheet.