Skip to content

Commit b8924b0

Browse files
committed
dev: overrides badge partial to have 'icon-only' option
1 parent 0d414ec commit b8924b0

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

docs/content/docs/plugins/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ weight: 7
44
---
55

66
{{< cards >}}
7-
{{< card link="/docs/plugins/module-plugins/" title="Module Plugin System" icon="puzzle" tag="Recommended" >}}
7+
{{< card link="/docs/plugins/module-plugins/" title="Module Plugin System" icon="puzzle" tag="Recommended" tagType="icon-only:sparkles" >}}
88
{{< card link="/docs/plugins/go-plugins/" title="Go Plugin System" icon="puzzle" >}}
99
{{< /cards >}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- /* Modified version of https://github.com/imfing/hextra/blob/v0.10.0/layouts/_partials/shortcodes/badge.html */ -}}
2+
{{- /* This file overrides the badge partial of the theme */ -}}
3+
4+
{{- $content := .content -}}
5+
{{- $type := .type | default "" -}}
6+
{{- $class := .class | default "" -}}
7+
{{- $border := .border | default false -}}
8+
{{- $icon := .icon | default "" -}}
9+
10+
{{- $defaultClass := "hx:text-gray-600 hx:bg-gray-100 hx:dark:bg-neutral-800 hx:dark:text-neutral-200 hx:border-gray-200 hx:dark:border-neutral-700" -}}
11+
12+
{{- $styleClass := newScratch -}}
13+
{{- $styleClass.Set "info" "hx:border-blue-200 hx:bg-blue-100 hx:text-blue-900 hx:dark:border-blue-200/30 hx:dark:bg-blue-900/30 hx:dark:text-blue-200" -}}
14+
{{- $styleClass.Set "warning" "hx:border-yellow-100 hx:bg-yellow-50 hx:text-yellow-900 hx:dark:border-yellow-200/30 hx:dark:bg-yellow-700/30 hx:dark:text-yellow-200" -}}
15+
{{- $styleClass.Set "error" "hx:border-red-200 hx:bg-red-100 hx:text-red-900 hx:dark:border-red-200/30 hx:dark:bg-red-900/30 hx:dark:text-red-200" -}}
16+
17+
{{- $borderClass := cond (eq $border true) "hx:border" "" -}}
18+
{{- $badgeClass := or ($styleClass.Get $type) $defaultClass -}}
19+
20+
{{- $iconOnly := hasPrefix $type "icon-only" -}}
21+
{{- if $iconOnly -}}
22+
{{- $icon = (strings.TrimPrefix "icon-only:" $type) -}}
23+
{{- $borderClass = "" -}}
24+
{{- $defaultClass = "" -}}
25+
{{- $badgeClass = "hx:p-2" -}}
26+
{{- end -}}
27+
28+
<div class="hextra-badge {{ $class }}" {{- if $iconOnly -}}title="{{ $content }}"{{- end -}}>
29+
<div 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 }}">
30+
{{- with $icon -}}{{- partial "utils/icon" (dict "name" . "attributes" "height=12") -}}{{- end -}}
31+
{{- if not $iconOnly -}}{{- $content -}}{{- end -}}
32+
</div>
33+
</div>
34+
{{- /* Strip trailing newline. */ -}}

0 commit comments

Comments
 (0)