|
| 1 | +{{- /* Modified version of https://github.com/imfing/hextra/blob/v0.9.7/layouts/partials/shortcodes/badge.html */ -}} |
| 2 | +{{- /* |
| 3 | +Creates a badge with the given id and class. |
| 4 | + |
| 5 | +@param {string} content The content of the badge. |
| 6 | +@param {string} type The type of the badge. |
| 7 | +@param {string} id The id of the badge. |
| 8 | +@param {string} class The class of the badge. |
| 9 | +@param {boolean} border Whether to render a border around the badge. |
| 10 | +@param {string} icon The icon of the badge. |
| 11 | + |
| 12 | +*/ -}} |
| 13 | + |
| 14 | +{{- $content := .content -}} |
| 15 | +{{- $type := .type -}} |
| 16 | +{{- $id := .id | default "" -}} |
| 17 | +{{- $class := .class | default "" -}} |
| 18 | +{{- $border := .border | default false -}} |
| 19 | +{{- $icon := .icon | default "" -}} |
| 20 | + |
| 21 | +{{- $defaultClass := "hx-text-gray-600 hx-bg-gray-100 dark:hx-bg-neutral-800 dark:hx-text-neutral-200 hx-border-gray-200 dark:hx-border-neutral-700" -}} |
| 22 | + |
| 23 | +{{- $styleClass := newScratch -}} |
| 24 | +{{- $styleClass.Set "info" "hx-border-blue-200 hx-bg-blue-100 hx-text-blue-900 dark:hx-border-blue-200/30 dark:hx-bg-blue-900/30 dark:hx-text-blue-200" -}} |
| 25 | +{{- $styleClass.Set "warning" "hx-border-yellow-100 hx-bg-yellow-50 hx-text-yellow-900 dark:hx-border-yellow-200/30 dark:hx-bg-yellow-700/30 dark:hx-text-yellow-200" -}} |
| 26 | +{{- $styleClass.Set "error" "hx-border-red-200 hx-bg-red-100 hx-text-red-900 dark:hx-border-red-200/30 dark:hx-bg-red-900/30 dark:hx-text-red-200" -}} |
| 27 | +{{- $styleClass.Set "green" "hx-border-green-200 hx-bg-green-100 hx-text-green-900 dark:hx-border-green-200/30 dark:hx-bg-green-900/30 dark:hx-text-green-200" -}} |
| 28 | +{{- $styleClass.Set "indigo" "hx-border-indigo-200 hx-bg-indigo-100 hx-text-indigo-900 dark:hx-border-indigo-200/30 dark:hx-bg-indigo-900/30 dark:hx-text-indigo-200" -}} |
| 29 | +{{- $styleClass.Set "amber" "hx-border-amber-200 hx-bg-amber-100 hx-text-amber-900 dark:hx-border-amber-200/30 dark:hx-bg-amber-900/30 dark:hx-text-amber-200" -}} |
| 30 | + |
| 31 | +{{- $borderClass := cond (eq $border true) "hx-border" "" -}} |
| 32 | +{{- $badgeClass := or ($styleClass.Get $type) $defaultClass -}} |
| 33 | +<div class="hextra-badge"> |
| 34 | + <div id="{{ $id }}" class="hx-inline-flex hx-gap-1 hx-items-center hx-rounded-full hx-px-2.5 hx-leading-6 hx-text-[.65rem] {{ $borderClass }} {{ $badgeClass }} {{ $class }}"> |
| 35 | + {{- with $icon -}}{{- partial "utils/icon" (dict "name" . "attributes" "height=12") -}}{{- end -}} |
| 36 | + {{- $content -}} |
| 37 | + </div> |
| 38 | +</div> |
| 39 | +{{- /* Strip trailing newline. */ -}} |
0 commit comments