Definition List¶
A read only list of label and value pairs. The label sits beside its value and stacks above it on a narrow screen. The columns layout sets each label over its value in balanced columns, with an optional route arrow between two items.
Decision¶
| When | Use |
|---|---|
| The details of one thing, such as a version and an id | Definition List |
| A few short facts side by side, such as a last sync and a library, or a From and To route | The columns layout |
| Rows that need the card surface | Record Card |
Usage¶
import { createDefinitionList } from './configurationpage?name=myplugin_stolon.js';
container.appendChild(createDefinitionList({
items: [{ label: 'Version', value: '1.2.0' }, { label: 'Id', value: id, mono: true }]
}).element);
Set short facts side by side, with a size under each path and an arrow from source to local:
container.appendChild(createDefinitionList({
layout: 'columns',
arrow: true,
items: [
{ label: 'Source Path', value: sourcePath, mono: true, meta: '4.2 GB' },
{ label: 'Local Path', value: localPath, mono: true, note: 'Not synced yet.' }
]
}).element);
Classes: stolon-defs, stolon-defs-row, stolon-defs-missing, stolon-columns, stolon-compact, stolon-has-arrow. The handle is { element, getValue, setValue, setItems, setHeight, destroy }.
Parts: stolon-defs-label, stolon-defs-value, stolon-defs-meta, stolon-defs-note, stolon-defs-arrow.
States and Modifiers¶
- An item is
{ label, value, mono, meta, note, arrow }.monoshows the value in the mono font.meta, such as a size, andnoteare dimmed small lines under the value, in either layout. - A value may be a node, which is placed as it is, or
{ text, badge, link, mono }.badgeis a label or{ label, color }drawn as a Badge,linkis an address that opens in a new tab withtextas its words, andmonoshows the text in the mono font. - A missing value shows
emptyText, "None" by default, dimmed withstolon-defs-missing. - The list is a
dl. In the rows layout every row shares one label column, as wide as the longest label up to 40% of the list. A longer label wraps, and an unbroken one such asJF_COMMUNITY_RATINGbreaks anywhere, so a label never runs over its value. An engine withoutsubgridgives the labels a column of at least 120px and 30% of the row, and they wrap the same way. - A row is one column at 600px and below, with its label over its value.
layout: 'columns'sets each label small, uppercase, and dimmed over its value, withcolumns, in balanced rows at least 200px wide on the wash. The List lays it out as a grid.layout: 'rows', the default, keeps each label beside its value.- In the columns layout,
arrow: truedraws anarrow_forwardafter every item but the last, andarrow: trueon an item draws one after that item, withstolon-has-arrowon its row. When two columns no longer fit the list's own width it takesstolon-compact, the columns stack, and each arrow turns down. - The rows are a List, so
height,maxHeight,minHeight, andsetHeightwork as they do there.heightis'auto'by default, so the list grows with its rows.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
createDefinitionList¶
function createDefinitionList(options?: DefinitionListOptions): DefinitionListHandle
A read-only list of label and value pairs. The label sits beside its value and stacks above it on a narrow screen. The columns layout sets each label over its value, in balanced columns on the wash, and a route arrow between two items, such as From and To, turns down when the items stack.
| Option | Type | What it does |
|---|---|---|
items |
DefinitionItem[] |
array of { label, value, mono, meta, note, arrow } where value is text, a node, or { text, badge, link, mono }, a badge is a label or { label, color }, a link opens in a new tab, mono shows the value in the mono font, meta and note are dimmed lines under the value, and arrow draws a route arrow after the item [optional] |
layout |
'rows' | 'columns' |
'rows' sets each label beside its value, and 'columns' sets it over its value, in balanced columns on the wash (default 'rows') |
arrow |
boolean |
true draws a route arrow between every two items, in one row that stacks when narrow (default false) |
emptyText |
string |
text for a missing value (default 'None') |
height |
ListHeight |
the list's height, 'auto', 'fill', a number of pixels, or a CSS length (default 'auto') |
maxHeight |
number | string | null |
the most the list grows to before it scrolls [optional] |
minHeight |
number | string | null |
the least a filling list takes (default 160px) [optional] |
| Handle member | Type |
|---|---|
getValue |
(): DefinitionItem[] |
setValue |
(next: DefinitionItem[]): void |
setItems |
(next: DefinitionItem[]): void |
setHeight |
(height: ListHeight, maxHeight?: number | string | null): void |
destroy |
(): void |
| Type | What it is |
|---|---|
DefinitionValue |
A value drawn as more than text: a badge with a status color name or hex code, a link, or text in the mono font. text is the shown text, which a badge or link may also give. |
DefinitionItem |
One label and value pair. value is text, a node, or a DefinitionValue, and mono shows a text value in the mono font. meta and note are dimmed lines under the value, and arrow draws a route arrow after the item. |
| Class | What it looks like |
|---|---|
stolon-defs |
Read-only list of labels and values, side by side and stacked on a narrow screen |
stolon-defs-label |
The dimmed label every label and value list shares, a definition list's and a record card's |
stolon-defs-meta |
Dimmed lines under a value, a meta line such as a size and a note, in the value's column |
stolon-defs-value |
A value drawn as a badge, a link, or mono text, which wrap beside each other |
stolon-defs.stolon-columns |
The columns layout, each small uppercase label over its value, in balanced columns on the wash |
Example¶
Example Code¶
<!-- title: Definition List -->
<div id="mount" style="display: grid; gap: 24px;"></div>
<script type="module">
const base = await window.__baseReady;
const mount = document.getElementById('mount');
mount.appendChild(base.createDefinitionList({ items: [
{ label: 'Version', value: '12.4.14.1' },
{ label: 'Id', value: '2f40d5d8-5b6a', mono: true },
{ label: 'Last Sync' }
] }).element);
mount.appendChild(base.createDefinitionList({ layout: 'columns', items: [
{ label: 'Last Sync', value: 'Today at 3:12 PM' },
{ label: 'Library', value: 'Movies to Films' },
{ label: 'Status', value: { badge: { label: 'Synced', color: 'green' } } }
] }).element);
mount.appendChild(base.createDefinitionList({ layout: 'columns', arrow: true, items: [
{ label: 'Source Path', value: '/media/movies/Alien (1979)/Alien.mkv', mono: true, meta: 'Size 4.2 GB' },
{ label: 'Local Path', value: '/data/films/Alien (1979)/Alien.mkv', mono: true, meta: 'Size 4.2 GB', note: 'Renamed to match the local library.' }
] }).element);
</script>