Storefront
A home goods shop with a mega menu catalog, a listing with facets and a cart that recounts as you go.
What it is built from
AppShellTopBarMobileTabBarMegaMenuCarouselMediaCardCardImageBreadcrumbsPageHeaderPaginationRangeSliderRadioGroupSwatchGroupToggleSelectRatingSearchControlDrawerNumberInputProgressEmptyStatetoast
Try it
- Point at a category in the category column on the left: its flyout opens right away, over the carousel. Move the pointer diagonally toward the flyout across the neighboring categories, and the flyout stays put: that is menu aim.
- Click a link in the flyout, a column heading or “Sale”: the section's listing opens, and the catalog marks the current section. The same catalog drops down from the “Catalog” button in the header.
- Narrow the results with the facets (price, rating, color, “In stock only”). On a phone, “Filters” opens them in a panel from the bottom, and the catalog lives on the “Catalog” tab, where a category opens in place of the category column.
- Find a product with the search in the header, say “oak chair”, and press Enter.
- Put a few products in the cart, change the quantities and watch the bar fill up toward free shipping. The “Checkout” button places an order whose number continues the numbering of the Orders (CRM) screen: it is the same shop, and the bestsellers on the home page are 12 products from its orders.
How it is built
One catalog, three wrappers. The screen writes the categories once, in a separate component: they need not be
direct children of MegaMenu. The column on the home page is an inline MegaMenu, the button in the header is a
MegaMenuTrigger around the same MegaMenu, and the “Catalog” tab on a phone is an inline one again. The catalog does
not work out which section is current: the screen sets active on the category and the link, as with active on
NavItem.
The router is one click handler. Every link in the shop is a real a with a #/… address; the kit knows nothing
about routes. The screen catches the click on AppShell in the capture phase and turns the address into its own
state. A click in the dropdown catalog gets there too: the overlay lives in a portal, but React carries the event
through the component tree, not the DOM. The overlay closes itself after a click on any link, and preventDefault
does not stop that; the screen closes the inline flyout itself, through a controlled value. The screen lets clicks
with a modifier key through.
The flyout is not a portal, so it needs room. On the home page the category column stands to the left of the carousel, and
the flyout opens over it; an ancestor with overflow: hidden would clip the flyout. One flyout width serves every
category and all three wrappers, and a CSS expression sets it: on a tablet the flyout narrows to fit beside the
column, and the link columns rearrange into two. A flyout can hold any custom content; here it is a MediaCard
across the full row under the columns.
Facets are the screen's state. The listing is built on a grid of cards, not on a DataTable, so there is no
useTableState here. A new section opens on its first page, unfiltered. The price range comes from the section's
products, and a slider pulled back to both ends counts as off again, so it drops out of the count on the “Filters”
button. On a wide screen the facets stand at the side; on a narrow one the same facets are in a Drawer from the
bottom, with the number of products found on its “Show N products” button.