badge

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorLabel  = "#555"
	ColorGreen  = "#00D084"
	ColorBlue   = "#3B82F6"
	ColorYellow = "#F59E0B"
	ColorRed    = "#EF4444"
	ColorPurple = "#8B5CF6"
	ColorGray   = "#6B7280"
	ColorTeal   = "#14B8A6"
	ColorIndigo = "#6366F1"
)

Variables

This section is empty.

Functions

func FormatCompact

func FormatCompact(value1 float64, label1 string, value2 int, label2 string) string

FormatCompact creates a compact representation like "1.2k / 42".

func FormatNumber

func FormatNumber(n float64) string

FormatNumber formats a number with k/M/B suffixes for compact display.

func GetInstancesColor

func GetInstancesColor(count int) string

func GetMetricColor

func GetMetricColor(value float64) string

Types

type Badge

type Badge struct {
	Label      string
	Value      string
	Color      string // Hex color for value side
	LabelColor string // Hex color for label side (default: ColorLabel)
}

Badge represents a shield-style badge with label and value.

func NewBadge

func NewBadge(label, value, color string) *Badge

NewBadge creates a new badge with the given parameters.

func (*Badge) ToSVG

func (b *Badge) ToSVG() string

ToSVG generates an SVG badge in shields.io flat-square style.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL