Files
at-container-registry/pkg/appview/templates/components/star.html
T
2026-01-15 00:17:48 -06:00

31 lines
1.4 KiB
HTML

{{ define "star" }}
{{/*
Star component - displays star icon with count
Required: .IsStarred (bool), .StarCount (int)
Optional: .Interactive (bool), .Handle (string), .Repository (string)
Interactive mode: renders as button with HTMX toggle
Display mode: renders as span (default)
*/}}
{{ if .Interactive }}
<button class="btn btn-sm gap-2 btn-ghost group border border-transparent hover:border-primary{{ if .IsStarred }} border-amber-400!{{ end }}"
id="star-btn"
{{ if .IsStarred }}
hx-delete="/api/stars/{{ .Handle }}/{{ .Repository }}"
{{ else }}
hx-post="/api/stars/{{ .Handle }}/{{ .Repository }}"
{{ end }}
hx-swap="outerHTML"
hx-on::before-request="this.disabled=true"
hx-on::after-request="if(event.detail.xhr.status===401) window.location='/auth/oauth/login'">
<i data-lucide="star" class="size-4 text-amber-400 stroke-amber-400 transition-transform group-hover:scale-110{{ if .IsStarred }} fill-amber-400{{ end }}" id="star-icon"></i>
<span id="star-count">{{ .StarCount }}</span>
</button>
{{ else }}
<span class="flex items-center gap-2 text-base-content/60">
<i data-lucide="star" class="size-[1.1rem] text-amber-400 stroke-amber-400{{ if .IsStarred }} fill-amber-400{{ end }}"></i>
<span class="font-semibold text-base-content">{{ .StarCount }}</span>
</span>
{{ end }}
{{ end }}