Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

glossary-wc

Searchable, categorized glossary for ubiquitous language and project taxonomy — progressively enhances a dl definition list.

Overview

A web component that progressively enhances a <dl> definition list into a searchable, categorized glossary with alphabet navigation and cross-linking. Without JavaScript, the definition list renders normally. With JavaScript, terms are grouped by category, searchable, and navigable via a letter jump bar.

Attributes

AttributeTypeDefaultDescription
data-titlestring—Glossary heading, rendered as a real heading. (The title attribute is not used: it would also become a hover tooltip and the element’s description.)
data-heading-levelnumber2Heading level (1–6) for data-title
srcstring (URL)—JSON data URL (see Data mode)
searchableboolean—Adds a search input that filters terms by name and definition text
compactboolean—Reduced spacing
data-stateread-only—In src mode: loading, ready or error

Term Attributes

Each term is wrapped in a <div> inside the <dl> with these data attributes:

AttributeOnDescription
data-category<div>Category label for grouping (e.g., "Domain", "Technical"). Terms without one go under “Uncategorized”.
data-term-id<div>Unique ID, set as the div’s id for fragment anchors and cross-links

The authored <dl> stays in the element (hidden) while it is upgraded, and its term <div>s are moved back into it on teardown — moving the element or re-rendering it gives the same result every time.

Enhanced Features

  • Search — when searchable is set, a search input filters terms by name and definition text. Matches inside collapsed categories are revealed while searching; clearing the search restores the categories you collapsed.
  • Categories — terms grouped under collapsible category headers, sorted with the language’s collation
  • Letter jump bar — one link per first letter actually used, pointing at the first term with that letter. Letters come from the terms via Intl.Collator for the element’s lang: accent-insensitive where the language treats accents as variants (É files under E in English), non-Latin scripts by their first character (А, あ…), and digits or symbols under #. While searching, letters with no visible term are aria-disabled.
  • Cross-linking — use standard <a href="#term-id"> inside definitions to link between terms; a link into a collapsed category expands it. Links stay on the page under <base href>.
  • Term count — visual badges showing total and filtered counts (the count is announced through the live region, not the heading or button names)

Data mode

With src, the JSON is fetched once per URL. An inline <dl> is optional: it renders as the fallback while loading and stays if the fetch fails, when data-state="error" is set and an error message is shown. glossary-wc:ready fires after the loaded terms render.

  • title is used as the heading when data-title is not set.
  • definition is rendered as text — markup in it is shown literally, never parsed.
  • definitionHtml is an explicit opt-in for formatted definitions. It is passed through VB’s HTML sanitizer (scripts, frames, event handlers and javascript: URLs are removed) and used instead of definition. Only use it for content you trust.
  • seeAlso lists term ids; each becomes a link labelled with that term’s own text.

JavaScript API

The terms property reads the parsed glossary as { id, term, definition, category, seeAlso? } records. Assigning it rebuilds the glossary from records in the JSON format above (written into the source <dl>, so they survive moves) and fires glossary-wc:terms-changed.

Labels and languages

Every UI string can be replaced with a data-label-* attribute. Counts use Intl.PluralRules for the nearest lang, so add any plural category you need (-one, -few, -many, -other…).

AttributeDefault
data-label-searchSearch glossary terms (input name)
data-label-search-placeholderSearch terms…
data-label-termsGlossary terms (region name)
data-label-alphabetAlphabet navigation (jump-bar name)
data-label-found-one / -other{count} term found / {count} terms found
data-label-all-one / -otherShowing {count} term / Showing all {count} terms (search cleared)
data-label-uncategorizedUncategorized
data-label-see-alsoSee also:
data-label-errorCould not load the glossary terms.

Events

EventDetailWhen
glossary-wc:ready{ termCount, categories }After every render; not while src is loading
glossary-wc:search{ query, matchCount }After the (debounced) search is applied
glossary-wc:terms-changed{ terms, source: 'property' }After terms is assigned
glossary-wc:error{ url, error }When src fails to load

Accessibility

  • The <dl> provides native definition list semantics before and after upgrade
  • The search input sits in a <search> landmark and has an aria-label (the placeholder is only a hint)
  • One polite live region announces the match count, and the full count when the search is cleared; count badges are hidden from assistive technology so they are not read into the heading or toggle names
  • Category groups are collapsible buttons with aria-expanded and aria-controls
  • Jump-bar letters are at least 24×24 px (WCAG 2.5.8); letters with no visible term are aria-disabled while searching. They stay in the tab order so keyboard users can reach them, and activating one does nothing
  • Term IDs enable fragment anchor navigation; the target is focused
  • The collapse chevron follows the writing direction in RTL

Related

↑