{{/* Metric Card Partial - ShadCN-style individual card Usage: {{ partial "metric-card.html" (dict "label" "Open Issues" "value" 42 "subtext" "5 new this week" "info" "Tooltip text") }} Parameters: - label: The metric label - value: The metric value - descriptor: Optional muted descriptor shown at bottom (e.g., ">30 days", "last 7d") - subtext: Optional subtext below the value - info: Optional tooltip text explaining the metric - sparkline: Optional array of values for a mini chart (last 10 data points) - sparklineColor: Optional color for sparkline (default: primary blue) - trend: Optional trend percentage (positive = up, negative = down, 0 = no change) - trendGoodDirection: Optional "up" or "down" to indicate which direction is good (default: "down" for issues/PRs) - link: Optional URL to link to (e.g., GitHub filtered issues/PRs) - total: Optional total to display (e.g., 50) - shown as "/50" after value - percent: Optional percentage to display (e.g., 45.2 for "45.2%") - shown after total - percentLabel: Optional label for the percent tooltip (e.g., "of opened") */}} {{- $hasLink := .link -}} {{- $linkClasses := cond $hasLink "hover:border-base-content/30 hover:shadow-sm transition-all cursor-pointer group" "" -}}
{{- if $hasLink -}} {{/* Corner fold/earmark indicator for clickable cards - grows on hover */}} {{- end -}}
{{ .label }} {{ with .info }}
{{ . }}
{{ end }}
{{- if isset . "trend" -}} {{- $trend := .trend -}} {{- $goodDir := .trendGoodDirection | default "down" -}} {{- if ne $trend 0.0 -}} {{- $isUp := gt $trend 0.0 -}} {{- $isGood := eq $isUp (eq $goodDir "up") -}} {{- $colorClass := cond $isGood "text-success" "text-error" -}} {{- $arrow := cond $isUp "↑" "↓" -}} {{- $absVal := cond $isUp $trend (mul $trend -1) -}} {{ $arrow }} {{ printf "%.2f" $absVal }}% {{- else -}} {{- end -}} {{- else -}} {{- end -}}
{{- if isset . "value" -}} {{- $v := .value -}} {{- if (eq (printf "%T" $v) "float64") -}} {{ lang.FormatNumber 0 $v }} {{- else if (eq (printf "%T" $v) "int") -}} {{ lang.FormatNumber 0 $v }} {{- else -}} {{ $v }} {{- end -}} {{- else -}} — {{- end -}} {{- if and (isset . "total") (isset . "percent") -}} {{- $total := .total -}} {{- $pct := .percent -}} {{- $pctLabel := .percentLabel | default "of total" -}} {{- if gt $total 0 -}} {{ $pctLabel }}/{{ lang.FormatNumber 0 $total }}{{- if and (gt $pct 0.0) (le $pct 100.0) }} ({{ printf "%.0f" $pct }}%){{- end -}} {{- end -}} {{- end -}}
{{- with .sparkline -}} {{- if gt (len .) 1 -}} {{- $color := $.sparklineColor | default "rgb(0, 102, 204)" -}}
{{- end -}} {{- end -}}
{{ with .subtext }}
{{ . }}
{{ end }} {{ with .descriptor }}
{{ . }}
{{ end }}