Count Cards¶
A row of large counts over labels, tinted by status.
Decision¶
| When | Use |
|---|---|
| A summary of counts at the top of a page or tab | Count Cards. |
| A state with a detail line, or a count that opens its page | Status Card. |
| Cards for records | stolon-card-list and stolon-card-item, or the Record Card. Never confuse them with Count Cards. |
Usage¶
<div class="stolon-cards stolon-compact" id="mainStatusRow">
<div class="stolon-card stolon-green"><span class="stolon-card-count">0</span><span class="stolon-card-label">Synced</span></div>
<div class="stolon-card stolon-purple"><span class="stolon-card-count">0</span><span class="stolon-card-label">Pending</span></div>
</div>
shared.renderCards('statusRow', [
{ label: 'Queued', count: 12, color: 'orange' },
{ label: 'Synced', count: 340, color: 'green' }
]);
Classes: stolon-cards, stolon-card, stolon-card-count, stolon-card-label.
States and Modifiers¶
shared.renderCards(containerId, cards)takes an id or element, addsstolon-cardsto it, and fills[{ label, count, color }]. Count and label are set as text. A null count shows nothing. A missing element is ignored.- The color modifiers are
stolon-green,stolon-red,stolon-orange,stolon-purple,stolon-blue,stolon-gray,stolon-yellow,stolon-pink, andstolon-teal.renderCardsalso takes a hex code such as#e91e63, drawn with thestolon-custommodifier. - The cards wrap in Balanced Rows, so five cards that do not fit in one row become three and two, never four and one. A card with
hiddentakes no place. compactmakes a tighter row of small cards, with a smaller gap, padding, and label, for many counts on a phone.--stolon-balance-maxcaps the cards in a row.style="--stolon-balance-max: 4"never shows more than four.- Cards in page markup are balanced by
createConfigPage, or bybindBalancedRows(view)on a page built another way. - Put a
titleon a card for a tooltip.
Gotchas¶
renderCardsdraws only a known color name or a hex code. Any other color leaves the card untinted.- There is no keyboard behavior.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
| Class | What it looks like |
|---|---|
stolon-cards |
Row of count cards that wraps to fit |
stolon-card |
Rounded card showing a large count over a label, tinted by status |
stolon-card-count |
Large bold count at the top of a card |
stolon-card-label |
Small label under the count |
stolon-card.stolon-green |
Status color modifiers for a card, each tinting the fill, text, and border |
stolon-cards.stolon-compact |
A tighter row of small count cards, for many counts in little room, such as on a phone |
Example¶
Example Code¶
<!-- title: Count Cards -->
<div id="statusRow"></div>
<div class="stolon-cards stolon-compact" style="--stolon-balance-max: 4">
<div class="stolon-card stolon-pink"><span class="stolon-card-count">4</span><span class="stolon-card-label">Pink</span></div>
<div class="stolon-card stolon-teal"><span class="stolon-card-count">9</span><span class="stolon-card-label">Teal</span></div>
<div class="stolon-card stolon-yellow"><span class="stolon-card-count">2</span><span class="stolon-card-label">Yellow</span></div>
<div class="stolon-card stolon-blue"><span class="stolon-card-count">6</span><span class="stolon-card-label">Blue</span></div>
<div class="stolon-card stolon-gray"><span class="stolon-card-count">1</span><span class="stolon-card-label">Gray</span></div>
</div>
<script type="module">
const base = await window.__baseReady;
const shared = base.createShared(document.getElementById('view'), 'preview-plugin', 'Preview');
base.bindBalancedRows(document.getElementById('view'));
shared.renderCards('statusRow', [
{ label: 'Queued', count: 12, color: 'orange' },
{ label: 'Synced', count: 340, color: 'green' },
{ label: 'Errored', count: 3, color: 'red' },
{ label: 'Pending', count: 21, color: 'purple' },
{ label: 'Ignored', count: 8, color: 'gray' }
]);
</script>