From 69585eeb1435a6504e5dffa5c54111e2f19a72a2 Mon Sep 17 00:00:00 2001 From: joe128 Date: Sat, 24 Aug 2024 23:38:44 +0200 Subject: [PATCH] feat: add tooltips to cards --- .../content/docs/guide/shortcodes/cards.md | 26 ++++++++++--------- layouts/partials/shortcodes/card.html | 5 +++- layouts/shortcodes/card.html | 4 +++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/exampleSite/content/docs/guide/shortcodes/cards.md b/exampleSite/content/docs/guide/shortcodes/cards.md index 3d0767c1..809f9209 100644 --- a/exampleSite/content/docs/guide/shortcodes/cards.md +++ b/exampleSite/content/docs/guide/shortcodes/cards.md @@ -7,8 +7,8 @@ linkTitle: Cards {{< cards >}} {{< card link="../callout" title="Callout" icon="warning" >}} - {{< card link="../callout" title="Card with tag" icon="tag" tag="custom tag">}} - {{< card link="/" title="No Icon" >}} + {{< card link="../callout" title="Card with tag" icon="tag" tag="A custom tag with Tooltip" tagtooltip="Tooltip for Tag">}} + {{< card link="/" title="No Icon, but with Tooltip" linktooltip="Tooltip for Link" >}} {{< /cards >}} {{< cards >}} @@ -22,8 +22,8 @@ linkTitle: Cards ``` {{}} {{}} - {{}} - {{}} + {{}} + {{}} {{}} ``` @@ -37,14 +37,16 @@ linkTitle: Cards ## Card Parameters -| Parameter | Description | -|----------- |-----------------------------------------------------------------| -| `link` | URL (internal or external). | -| `title` | Title heading for the card. | -| `subtitle` | Subtitle heading (supports Markdown). | -| `icon` | Name of the icon. | -| `tag` | Text in tag. | -| `tagColor` | Color of the tag: `gray` (default), `yellow`, `red` and `blue`. | +| Parameter | Description | +|---------------|-----------------------------------------------------------------------| +| `link` | URL (internal or external). | +| `title` | Title heading for the card. | +| `linktooltip` | Tooltip (title-attribut) for the link. | +| `subtitle` | Subtitle heading (supports Markdown). | +| `icon` | Name of the icon. | +| `tag` | Text in tag. | +| `tagType` | Type of the tag: `info` (blue), `warning` (yellow) and `error` (red). | +| `tagtooltip` | Tooltip (title-attribut) for the Tag. | ## Image Card diff --git a/layouts/partials/shortcodes/card.html b/layouts/partials/shortcodes/card.html index 3bbe1517..2bd8018d 100644 --- a/layouts/partials/shortcodes/card.html +++ b/layouts/partials/shortcodes/card.html @@ -1,6 +1,7 @@ {{- $page := .page -}} {{- $link := .link -}} {{- $title := .title -}} +{{- $linktooltip := .linktooltip -}} {{- $icon := .icon -}} {{- $subtitle := .subtitle -}} {{- $image := .image -}} @@ -9,6 +10,7 @@ {{- $imageStyle := .imageStyle -}} {{- $tag := .tag -}} {{- $tagType := .tagType -}} +{{- $tagtooltip := .tagtooltip -}} {{ $linkClass := "hover:hx-border-gray-300 hx-bg-transparent hx-shadow-sm dark:hx-border-neutral-800 hover:hx-bg-slate-50 hover:hx-shadow-md dark:hover:hx-border-neutral-700 dark:hover:hx-bg-neutral-900" }} {{- with $image -}} @@ -25,6 +27,7 @@ href="{{ $href }}" {{ with $external }}target="_blank" rel="noreferrer"{{ end -}} {{- end -}} + {{- with $linktooltip }}title="{{- . -}}"{{ end -}} > {{- with $image -}} - {{ $tag }} + {{ $tag }} {{- end -}} diff --git a/layouts/shortcodes/card.html b/layouts/shortcodes/card.html index 4b183540..942cd9b0 100644 --- a/layouts/shortcodes/card.html +++ b/layouts/shortcodes/card.html @@ -1,6 +1,7 @@ {{- $context := . -}} {{- $link := .Get "link" -}} {{- $title := .Get "title" -}} +{{- $linktooltip := .Get "linktooltip" -}} {{- $icon := .Get "icon" -}} {{- $subtitle := .Get "subtitle" -}} {{- $image := .Get "image" -}} @@ -9,6 +10,7 @@ {{- $imageStyle := .Get "imageStyle" -}} {{- $tag := .Get "tag" -}} {{- $tagType := .Get "tagType" -}} +{{- $tagtooltip := .Get "tagtooltip" -}} {{/* Image processing options */}} {{- $method := .Get "method" | default "Resize" | humanize -}} @@ -44,6 +46,7 @@ "page" .Page "link" $link "title" $title + "linktooltip" $linktooltip "icon" $icon "subtitle" $subtitle "image" $image @@ -52,5 +55,6 @@ "imageStyle" $imageStyle "tag" $tag "tagType" $tagType + "tagtooltip" $tagtooltip ) -}}