Skip to content

Commit

Permalink
Tooltips allow different inline and title text
Browse files Browse the repository at this point in the history
I frequently want to pluralise the inline text, but have the title of
the tooltip be singular.
  • Loading branch information
illicitonion committed Jan 23, 2025
1 parent 7c1d9e0 commit 567e0e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions common-theme/layouts/shortcodes/tooltip.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{{/* The title is what will displayed as the title of the tooltip. */}}
{{- $title := .Get "title" | default "tooltip" -}}
{{/* The text is what will be displayed in-line in the text (which can be hovered over). */}}
{{- $text := .Get "text" | default $title -}}
{{- $emoji := .Get "emoji" | default "🧶" -}}
<tool-tip-container tabindex="0">
<strong class="tooltip__trigger" id="trigger__{{- $title -}}">
{{ $title }}
<strong class="tooltip__trigger" id="trigger__{{- $text -}}">
{{ $text }}
</strong>
<span class="tooltip__emoji">{{ $emoji }}</span>
<tool-tip role="tooltip" aria-labelledby="{{ $title }}">
<tool-tip role="tooltip" aria-labelledby="{{ $text }}">
<span class="tooltip__title e-heading__2"
><span class="tooltip__emoji">{{ $emoji }}</span> {{ $title }}</span
>
Expand Down

0 comments on commit 567e0e1

Please sign in to comment.