# Organisms

Larger sections of an interface built from molecules and atoms. A level of [Atomic Design](https://atomicdesign.bradfrost.com/); APIs follow the [component API convention](https://domestic-ui.odonckers.dev/index.md#component-api).

## Pages

- [Page header](https://domestic-ui.odonckers.dev/components/organisms/page-header.md): The top of a screen: an optional breadcrumb, the title, a description and actions that sit beside the title when there is room and wrap under it when not. API: `data-page-header` on a `<header>` inside `<main>`: optional breadcrumb `<nav>`, heading, optional `<p>`, actions last.
- [Dialog and drawer](https://domestic-ui.odonckers.dev/patterns/dialog.md): A modal `<dialog>`, either centered or as a drawer along one edge of the viewport.
- [Site navigation](https://domestic-ui.odonckers.dev/patterns/nav.md): The main links of a site in a `<nav>` landmark, with the current page marked.
- [Data table](https://domestic-ui.odonckers.dev/patterns/data-table.md): Rows of records in a native `<table>` with a caption, header cells and optional sorting.
- [Filter bar](https://domestic-ui.odonckers.dev/patterns/filter-bar.md): A row of native form controls that narrows a list or table.
- [Large forms](https://domestic-ui.odonckers.dev/patterns/large-forms.md): Long forms split into labelled groups, in one or more columns.
- [Stat row](https://domestic-ui.odonckers.dev/patterns/stat-row.md): A row of headline numbers, each a small card with a label, the value and a note.

## Our choices

From [`css/components/organisms/README.md`](https://github.com/odonckers/domestic-ui/blob/main/css/components/organisms/README.md):

- **Our choice:** the page header takes its layout from its children's elements (a `<nav>` breadcrumb, a heading, a `<p>`, and a last child of actions) rather than extra attributes, so it is the markup any page already writes; `<header>` inside `<main>` is not the banner landmark.
- **Our choice:** the filter bar is a plain `<form method="get">` in `<search>` with an Apply button, so the filters live in the URL, work with JavaScript off, and do not interrupt screen reader users while they set several; the result count is a `role="status"` element present from page load, so changes are announced.
- **Our choice:** form sections are `<section>` elements with a `<header>` and one body, not fieldsets with legends, because a legend cannot be placed in a grid column and headed sections show up in the headings list; related controls are still grouped in a `<fieldset>` inside the body.
- **Our choice:** the data table's sortable headers are plain text in the markup and `<dui-table>` turns them into buttons, so with JavaScript off there are no buttons that do nothing; following the [APG Sortable Table](https://www.w3.org/WAI/ARIA/apg/patterns/table/examples/sortable-table/) example, `aria-sort` is on the sorted header only, the arrow is hidden from assistive technology and the caption gets a visually hidden hint once the buttons exist.
- **Our choice:** the data table has hairline row separators and no zebra stripes; the row under the pointer gets the raised surface, and cells use the 14px interface size.
- **Our choice:** a selected row is marked by its checked checkbox, a bar on its leading edge and a tint, never color alone; the count is a `role="status"` element in the page from load, and the bulk actions are disabled until a row is selected. The "select all" checkbox is added by the script, since it would do nothing without it.
- **Our choice:** a sticky table header sticks to the nearest scroll container: put the table in `data-scroll="block inline"` (at most `--dui-size-pane` tall), or in no scroll container to stick to the viewport. In `data-scroll="inline"` alone it cannot stick.
- **Our choice:** numeric columns are marked per cell (`data-table-cell="number"`), the same attribute as the table, because words on the table cannot target a column.
- **Our choice:** every organism and layout switches with a container query on its own box, not a media query, because it sits in regions of any width (a split, an app shell's main area). Container query conditions cannot read custom properties, so each breakpoint is a length written in the file header.

## Not shipped, and why

| Candidate | Decision |
| --- | --- |
| Filters that apply on every keystroke | Not built in. A page MAY apply on change, but the default is a submit button, so several filters can be set without interruptions and the form works without JavaScript. |
| A `<fieldset>` as the top-level form section | Not used. A `<legend>` cannot be placed in a grid column; sections are headed `<section>` elements, with fieldsets for groups inside them. |
| App shell, sidebar navigation | Not organisms. The app shell is a layout ([`app-shell.css`](https://domestic-ui.odonckers.dev/patterns/app-shell.md), with [`<dui-app-shell>`](https://github.com/odonckers/domestic-ui/blob/main/web-components/dui-app-shell.js)) and the sidebar navigation is the [nav molecule](https://domestic-ui.odonckers.dev/patterns/nav.md) (`data-nav="vertical"`); see [app-shell.md](https://domestic-ui.odonckers.dev/explainers/app-shell.md). |
| Tree view for navigation | Not used. An [APG Tree View](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/) is for hierarchies users navigate as data; site navigation is disclosure groups and links. |
| Editable cells, arrow keys between cells | Not in the data table. Cells that are edited in place make the table an [APG Grid](https://www.w3.org/WAI/ARIA/apg/patterns/grid/), a different widget with its own keyboard model. |
| Announcing the new order after a sort | Not done. As in the APG Sortable Table example, `aria-sort` on the header is the announcement; a caption hint says which headers sort. |
| Sorting several columns at once, resizing or hiding columns | Not built in. Cancel `dui-table-sort` and sort on the server for multi-column orders. |
