Media library
A shared file library with an upload queue, a grid of previews and a carousel viewer.
What it is built from
AppShellSideNavTopBarMobileTabBarPageHeaderFileDropzoneUploadQueueVirtualGridMediaCardImageCarouselDialogContextMenuChipTagGroupSearchControltoast
Try it
- Drop a few files on the drop zone (or click it and select some): they join the queue, reach 100% and appear at the start of the grid. A dropped image is previewed as itself, any other file as an icon of its type.
- The queued file
team-offsite.jpgsoon fails on its own (at 60%), and then “Retry” appears: press it. A file withfailin its name also fails once. - Click a card (or press Enter on a focused one) to open the viewer: page through the carousel with the buttons, a swipe or the arrow keys.
- Right-click, long-press or press Shift+F10 on a focused card for its menu: open, rename, download,
delete. You can undo a deletion from the
toast. - The chips on top filter the grid to one file type; the search in the header matches names and tags.
How it is built
The drop zone chooses, the queue shows, and there is no transport. FileDropzone only collects files; it also
shows the rejected ones with a reason (here, anything over 50 MB). UploadQueue stores nothing: the
rows, the progress and the “Retry” and “Cancel” buttons come from the Gallery screen, and the “network” is a single
setTimeout. The kit announces the outcome of the queue in a live region, and a toast reports that the
files reached the library.
Previews are object URLs, and the Gallery screen revokes them. For a dropped image URL.createObjectURL is
called when it joins the queue; a canceled upload releases its URL at once, the others when the Gallery screen
goes away. A deleted file keeps its URL for as long as “Undo” is available. The library's initial files are inline SVGs
with no external URLs, and where there is no preview Image renders the icon of the type through
fallback.
Opening and the menu belong to the grid, not to the card. A VirtualGrid cell is a gridcell, so buttons
inside it are allowed, but they are not needed here because the grid handles opening and the menu. So MediaCard is display-only here, without actions.
The grid's onAction opens the viewer: a click or Enter opens the cell without selecting it, so pressing the
same card again opens the viewer again. The menu is the contextMenu property of the item: the
ContextMenuItem and ContextMenuSeparator items go there, and the grid itself sets up the panel and the
trigger and returns focus to the cell. The Gallery screen sets the height of the scrolling container, and the
layout counts the columns. The menu is not the only way to the actions: the same “Rename / Download /
Delete” actions are in the viewer.
The viewer is a Dialog with a Carousel. The strip scrolls natively, with snapping; defaultIndex opens it on
the clicked card without animation, and onIndexChange updates the title and tags once scrolling stops. The slides
are frozen when the viewer opens, so an upload that finishes meanwhile does not shift the strip; while the viewer is
closed there is no strip, so the next opening starts from a fresh scroll position.