Skip to content

Glossary(term) tooltip syntax — focus pages

Section titled “Glossary(term) tooltip syntax — focus pages”

Continuation of 2026-06-23_Tooltip-Component. Replaces the initial hardcoded per-term injection approach with a generic build-time resolver.

Previous approach (Tooltip-Component session): injectFASTTooltip() matched F.A.S.T. text via regex and wrapped it. Each new term required a new function + regex. This was recognised as brittle hardcoding.

New approach: authors write Glossary(TermName) anywhere in KB focus markdown. The build pipeline resolves it from Core/Misc/Glossary.md — no code changes needed for new terms.

Design constraint: Glossary() is opt-in, not auto-magic. The pipeline does NOT auto-tooltip every substring matching a Glossary key. Auto-matching would silently tooltip common terms (AI, HTML, SSOT) wherever they appear. Explicit Glossary() call gives authors control over which occurrences get a tooltip and where.

Code changes — sites/mbr/src/utils/load-focus-content.ts

Section titled “Code changes — sites/mbr/src/utils/load-focus-content.ts”
  • loadGlossaryTerms() — reads Core/Misc/Glossary.md once at build time, splits on ### Term headings, returns Map<string, string> with bold (**text**) converted to <b>text</b>
  • injectGlossaryTooltips(html, terms) — replaces Glossary(TermName) tokens with .ft tooltip spans; degrades to plain text if term not found
  • processHtml() simplified: injectBrands → injectGlossaryTooltips (F.A.S.T. auto-inject removed)
  • injectFASTTooltip(), injectCancer50Tooltip(), loadCancer50TooltipHtml(), C50_FALLBACK all removed
  • defaultContent() derives F.A.S.T. and Cancer50Pledge tooltips from the loaded glossary map

Code changes — sites/sdc/src/utils/load-focus-content.ts

Section titled “Code changes — sites/sdc/src/utils/load-focus-content.ts”
  • Same loadGlossaryTerms() + injectGlossaryTooltips() infrastructure added
  • SDC content currently has no Glossary() terms; infrastructure ready for future use
  • MBR/_WorkingOn/Focus.md**Cancer50Pledge**Glossary(Cancer50Pledge); F.A.S.T.Glossary(F.A.S.T.) in body + plan_intro; info callout documents Glossary() syntax
  • SDC/_WorkingOn/Focus.md — info callout updated with Glossary syntax note
  • README.md (monorepo) — Glossary(TermName) syntax added to Focus Pages section with examples
  • LESSONS.md (monorepo) — two entries added: visibility:hidden measurability; set:html / Astro component injection pattern

The initial .ft tooltip positioning JS only handled vertical flipping (top → bottom). No horizontal clamping. Cancer50Pledge appears near the left edge of the focus page — its 18rem tooltip bubble overflowed the left viewport edge.

Fix in sites/mbr/src/pages/focus.astro:

  • positionTooltip() now clamps horizontally after vertical check: shifts tip.style.left by calc(50% + Npx) when bubble overflows left or right viewport edge
  • Caret (::after) tracks the shift via --caret-left CSS variable so it continues pointing at the trigger word
  • Measurement uses getBoundingClientRect() on the visibility:hidden bubble (no show/hide dance needed)
FileChange
sites/mbr/src/utils/load-focus-content.tsGeneric Glossary loader + injector; per-term functions removed
sites/sdc/src/utils/load-focus-content.tsGlossary infrastructure added
sites/mbr/src/pages/focus.astroHorizontal viewport clamping in positionTooltip(); --caret-left CSS var
MBR/_WorkingOn/Focus.mdGlossary() syntax in body + plan_intro; info callout
SDC/_WorkingOn/Focus.mdInfo callout updated
README.mdGlossary syntax documented in Focus Pages section
LESSONS.mdTwo new entries
  • Glossary() is case-sensitive — term must match the ### Heading in Glossary.md exactly
  • Glossary.md is parsed at build time; changes require a rebuild to take effect
  • visibility:hidden bubble is measurable with getBoundingClientRect() — correct rect returned even when hidden
  • Caret offset must be adjusted when bubble is horizontally clamped — use --caret-left CSS variable; pseudo-elements can’t be styled directly from JS