Skip to content
astrostyle v0.6.2

Containers

Dialogs, drawers, accordions, tooltips and menus hold content that comes and goes; tables, lists, dividers, key caps and skeletons arrange and stand in for it. Dialogs, drawers, tooltips and menus are native <dialog> and popover elements with small JavaScript modules; everything else is HTML and CSS.

Dialog 01

Close a dialog: ap:close reports its return value here.

Jump to sector 7G?

The drive needs two cycles to cool down afterwards. Press Escape, click outside or pick an answer.

Hull breach

A click outside does not close this one: answer, or press Escape.

<button class="ap-c-button" type="button" data-ap-dialog-open="jump">Jump</button>

<dialog class="ap-c-dialog" id="jump" aria-labelledby="jump-title" data-ap-dialog>
  <header class="ap-c-dialog__header">
    <h2 class="ap-c-dialog__title" id="jump-title">Jump to sector 7G?</h2>
  </header>
  <div class="ap-c-dialog__body">…</div>
  <footer class="ap-c-dialog__footer">
    <button class="ap-c-button" type="button" data-ap-dialog-close value="cancel">Cancel</button>
  </footer>
</dialog>
import { createDialog } from 'astrostyle/js/dialog'

const jump = createDialog(document.querySelector('#jump'), { dismissible: true })
jump.element.addEventListener('ap:close', (event) => console.log(event.detail.returnValue))

A native modal dialog: the page behind is inert and Escape closes it. The module adds openers (data-ap-dialog-open), close buttons whose value becomes the return value, backdrop close, focus return and the ap:open and ap:close events.

Tokens of dialog: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-dialog-bgvar(--ap-bg)
--ap-dialog-fgvar(--ap-text)
--ap-dialog-border-colorvar(--ap-border)
--ap-dialog-radiusvar(--ap-radius-card)
--ap-dialog-shadowvar(--ap-elevation-overlay)
--ap-dialog-width32rem
--ap-dialog-paddingvar(--ap-space-xl)
--ap-dialog-gapvar(--ap-space-lg)
--ap-dialog-edgevar(--ap-space-lg)
--ap-dialog-durationvar(--ap-duration-base)

Drawer 02

Filters

Category

Ship

<dialog class="ap-c-drawer" id="filters" aria-labelledby="filters-title" data-ap-dialog>
  <header class="ap-c-drawer__header">…</header>
  <div class="ap-c-drawer__body">…</div>
  <footer class="ap-c-drawer__footer">…</footer>
</dialog>

A dialog along the full height of the end edge; --start moves it to the start edge. Same module, same behavior. It takes the full width on narrow screens.

Tokens of drawer: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-drawer-bgvar(--ap-bg)
--ap-drawer-fgvar(--ap-text)
--ap-drawer-border-colorvar(--ap-border)
--ap-drawer-shadowvar(--ap-elevation-overlay)
--ap-drawer-width24rem
--ap-drawer-paddingvar(--ap-space-xl)
--ap-drawer-gapvar(--ap-space-lg)
--ap-drawer-startauto
--ap-drawer-end0
--ap-drawer-offsetvar(--ap-space-xl)
--ap-drawer-durationvar(--ap-duration-slow)

Accordion 03

How far can the ship jump?

Three sectors per cycle, two with a full hold.

Who can pilot it?

Anyone with a license and a steady hand.

What happens when the drive overheats during a jump that was already planned?

The jump is cancelled and the drive cools for one cycle.

<details class="ap-c-accordion" name="faq">
  <summary class="ap-c-accordion__summary">How far can the ship jump?</summary>
  <div class="ap-c-accordion__body">…</div>
</details>

Native <details>, no JavaScript. With the same name, only one opens at a time.

Tokens of accordion: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-accordion-border-colorvar(--ap-border-subtle)
--ap-accordion-summary-fgvar(--ap-text)
--ap-accordion-summary-hover-bgcolor-mix(in oklab, var(--ap-text) 6%, transparent)
--ap-accordion-chevron-colorvar(--ap-accent)
--ap-accordion-padding-inlinevar(--ap-space-sm)
--ap-accordion-body-paddingvar(--ap-space-sm) var(--ap-space-sm) var(--ap-space-lg)

Table 04

Manifest, cycle 7 (striped)
ItemCategoryQtyValue
Plasma cellsEquipment12480
Medusa spikeHacks11,150
Drone frameDrones2900
Ration packsSupplies40120
Crew (compact)
NameRoleLevel
VegaPilot4
OkonkwoEngineer3
<div class="ap-c-table" role="region" aria-labelledby="manifest" tabindex="0">
  <table>
    <caption id="manifest">Manifest, cycle 7</caption>
    …
  </table>
</div>

The class goes on a focusable region around the table, so a wide table scrolls sideways with the keyboard too. --striped and --compact change the look; ap-c-table__numeric aligns numbers to the end.

Tokens of table: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-table-border-colorvar(--ap-border-subtle)
--ap-table-radiusvar(--ap-radius-control)
--ap-table-head-bgvar(--ap-surface-1)
--ap-table-stripe-bgtransparent
--ap-table-cell-padding-blockvar(--ap-space-sm)
--ap-table-cell-padding-inlinevar(--ap-space-md)

List 05

  • Vega Pilot
  • Okonkwo Engineer
  • Hasegawa Hacker
<ul class="ap-c-list">
  <li class="ap-c-list__item">Vega <span class="ap-c-list__meta">Pilot</span></li>
  <li class="ap-c-list__item"><a class="ap-c-list__link" href="/sectors/7g">Sector 7G</a></li>
</ul>

A row can hold one link or button that fills it. aria-current marks the current item; --plain drops the hairlines.

Tokens of list: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-list-divider-colorvar(--ap-border-subtle)
--ap-list-gapvar(--ap-space-md)
--ap-list-padding-blockvar(--ap-space-sm)
--ap-list-padding-inlinevar(--ap-space-sm)
--ap-list-meta-colorvar(--ap-text-muted)
--ap-list-hover-bgcolor-mix(in oklab, var(--ap-text) 6%, transparent)

Divider 06


Or

<hr class="ap-c-divider">
<div class="ap-c-divider">Or</div>

An <hr> is announced as a separator; a labelled divider reads only its label.

Tokens of divider: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-divider-colorvar(--ap-border)
--ap-divider-widthvar(--ap-border-width-hairline)
--ap-divider-gapvar(--ap-space-md)
--ap-divider-label-colorvar(--ap-text-muted)

Keyboard key 07

Press Ctrl + K to search, Esc to close, ↑ ↓ to move.

<kbd class="ap-c-kbd">Ctrl</kbd> + <kbd class="ap-c-kbd">K</kbd>
Tokens of kbd: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-kbd-bgvar(--ap-surface-1)
--ap-kbd-fgvar(--ap-text)
--ap-kbd-border-colorvar(--ap-border-strong)
--ap-kbd-radiusvar(--ap-radius-control)

Skeleton 08

<div role="group" aria-busy="true" aria-label="Loading crew">
  <span class="ap-c-skeleton ap-c-skeleton--circle"></span>
  <span class="ap-c-skeleton" style="--ap-skeleton-inline-size: 60%"></span>
  <span class="ap-c-skeleton ap-c-skeleton--block"></span>
</div>

A text line by default, --block for media, --circle for avatars. Mark the loading region with role="group", aria-busy="true" and a name; --ap-skeleton-duration: 0s stops the pulse.

Tokens of skeleton: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-skeleton-bgcolor-mix(in oklab, var(--ap-text) 10%, transparent)
--ap-skeleton-radiusvar(--ap-radius-control)
--ap-skeleton-inline-size100%
--ap-skeleton-block-size1em
--ap-skeleton-durationcalc(var(--ap-duration-slow) * 5)

Tooltip 09

Long-range scan Needs two cycles to cool down
<button class="ap-c-button ap-c-button--icon" type="button" aria-labelledby="scan-tip" data-ap-tooltip="scan-tip">…</button>
<span class="ap-c-tooltip" id="scan-tip" role="tooltip" popover="manual">Long-range scan</span>

Hover or tab to the buttons. A popover in the top layer, placed above the trigger (below when there is no room) by createTooltip(); Escape hides it. Link it yourself: aria-labelledby for icon buttons, aria-describedby for extra hints.

Tokens of tooltip: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-tooltip-bgvar(--ap-text)
--ap-tooltip-fgvar(--ap-bg)
--ap-tooltip-radiusvar(--ap-radius-control)
--ap-tooltip-padding-blockvar(--ap-space-xs)
--ap-tooltip-padding-inlinevar(--ap-space-sm)
--ap-tooltip-max-width18rem
--ap-tooltip-durationvar(--ap-duration-fast)
Open the log

Pick an action: ap:select reports it here.

<button class="ap-c-button" type="button" data-ap-menu="ship-menu">Ship</button>
<div class="ap-c-menu" id="ship-menu" popover>
  <button class="ap-c-menu__item" type="button" value="rename">Rename</button>
  <div class="ap-c-menu__separator" role="separator"></div>
  <button class="ap-c-menu__item ap-c-menu__item--danger" type="button" value="scrap">Scrap</button>
</div>

Open it with a click or ↓, move with the arrows, type a letter to jump, Esc to close. A click outside closes it too.

Tokens of menu: set them on the element, on a parent or in a modifier.
TokenDefault
--ap-menu-bgvar(--ap-bg)
--ap-menu-fgvar(--ap-text)
--ap-menu-border-colorvar(--ap-border)
--ap-menu-radiusvar(--ap-radius-control)
--ap-menu-shadowvar(--ap-elevation-overlay)
--ap-menu-min-width12rem
--ap-menu-paddingvar(--ap-space-xs)
--ap-menu-item-hover-bgcolor-mix(in oklab, var(--ap-text) 8%, transparent)
--ap-menu-danger-fgvar(--ap-danger-text)