badges

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ThemeDefault = "superplane"

ThemeDefault renders when the URL asks for no theme, or for a name that this package does not know.

Variables

View Source
var ColorParams = []string{"accent", "manual", "text", "muted", "bg", "border"}

ColorParams maps a URL parameter to the palette color it replaces. The settings page and any hand-written README URL use these names.

Functions

func NormalizeColor

func NormalizeColor(raw string) string

NormalizeColor returns a "#rrggbb" color, or an empty string when the value is not a six-digit hex color. The caller treats empty as "keep the color the theme sets".

func NormalizeTheme

func NormalizeTheme(raw string) string

NormalizeTheme maps a URL value to a known theme name. An unknown name falls back to the default, so a typo still renders a badge.

func Render

func Render(in Input) (string, error)

Render returns an SVG document for the requested size.

func ThemeNames

func ThemeNames() []string

ThemeNames returns the theme names a URL can ask for, default first.

Types

type Colors

type Colors struct {
	Accent     string
	Manual     string
	Text       string
	Subtle     string
	Background string
	Border     string
}

Colors replaces single theme colors. Every empty field keeps the color the theme sets.

func ColorsFromQuery

func ColorsFromQuery(query url.Values) Colors

ColorsFromQuery reads the color parameters. It drops anything that is not a six-digit hex color, so a typo keeps the theme color.

type DayPoint

type DayPoint struct {
	Date             time.Time
	SuperplaneMerged int
	PeopleMerged     int
}

DayPoint is one day of merged pull requests. Manual work is PeopleMerged.

type Input

type Input struct {
	PeriodDays               int
	SuperplaneMerged         int
	PeopleMerged             int
	SuperplaneWaste          int
	PreviousSuperplaneMerged int
	PreviousPeopleMerged     int
	HasPrevious              bool
	ShareKnown               bool
	CostCents                *int64
	Days                     []DayPoint
	Updated                  time.Time
	Size                     Size
	// Theme names a palette. An empty or unknown name uses ThemeDefault.
	Theme string
	// Colors replaces single colors from that theme.
	Colors Colors
}

Input is everything the SVG needs. CostCents is nil when the cost switch is off. The renderer never reads a URL flag.

Layout follows dark README stat cards (Repobeats-style): rounded card, large share, metric row, and a quiet daily chart. Series colors stay the Velocity chart colors.

type Size

type Size string

Size is the badge layout. Small is a shields-style strip. Large is a card. Wide is a full-width card with a daily chart.

const (
	SizeSmall Size = "small"
	SizeLarge Size = "large"
	SizeWide  Size = "wide"
)

Jump to

Keyboard shortcuts

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