Skip to content

v0.10.0

Choose a tag to compare

@github-actions github-actions released this 17 Nov 19:23
· 20 commits to main since this release

Every component gets a typed templ wrapper in the new module github.com/zweiundeins/starbase/templ, generated from its manifest, with script imports pinned to the release: a list, the autoloader, or exactly the components a page rendered. sb-toast takes a link or an action per toast and stops counting down while the page is hidden.

Added

Components

  • sb-toast: a toast can carry a link or an action: href or action with a label in the page's words (without a label, neither is shown). The link is an <a href> that closes the toast on a plain click and keeps it on a click that opens it elsewhere; the action is a <button> that emits sb-toast-action with {id, action} and closes the toast. Both sit in the tab order before the close button, are described by the toast's message and announced with it, and keyboard focus moves on to the next toast when they close theirs. Countdowns stop while the page is hidden (a background tab) and resume when it is shown, so a toast never expires unseen. The templ wrappers' sb.ToastMessage has Href, Action and Label.

Site and server

  • templ wrappers: the module github.com/zweiundeins/starbase/templ (package sb, in templ/, depending on templ and the standard library only) has a typed templ component for every component, generated from its manifest by go tool task templ-wrappers: @sb.Toggle(sb.ToggleProps{Label: "Notifications", Checked: true}).
    • Types:
      • Props are fields with doc comments from the manifest. Booleans work by presence, and flags that are on by default are sb.Flag.
      • oneOf values are constants named after their type (sb.ToggleSizeLg, sb.ToastVariantOK).
      • Whole numbers are int, others float64. Numbers whose default isn't 0, values that are the server's word, and server data such as sb-virtual-scroll's offset are pointers (sb.Int(0), sb.Num(0), sb.Str("")).
      • Lists in a string attribute are []string. JSON props are Go types (sb.DropdownItem, sb.Option, sb.Column, sb.RangeValue, …), where nil keeps the component's default and an empty slice writes [].
    • Content and attributes: content goes in as templ children, and events and Datastar attributes in Attrs (sb.Merge joins several sets). sb.TabSlot and sb.TabSlug name sb-tabs' panel slots.
    • Loading:
      • sb.Imports loads Datastar and the components, pinned with their integrity hashes, from a list or through the autoloader.
      • @sb.Tracked(sb.ImportsProps{}) { … } around <body> loads exactly the components rendered inside it, with the CSP nonce.
      • ScriptsOnly leaves out the import map and Datastar.
      • sb.Collect, sb.Pin, sb.DatastarBuild, sb.Snapshot, sb.Version and sb.Release serve a page that loads the files itself.
    • Docs: every component page has a templ tab under Installation.
    • Checks: CI fails when the wrappers are stale, and tests the module on its own. Browser tests render every component through its wrapper, with every field set, on Starbase's Datastar build and on the official release, and load a tracked page under a nonce CSP.
    • Versioning: the module is tagged templ/vX.Y.Z with each release.