badge

package module
v0.0.0-...-b9b997e Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 9 Imported by: 0

README

go-badge GoDoc

go-badge is a library to render shield badges to SVG.

Installation

Using go get

go get github.com/narqo/go-badge

Usage

package main

import (
	"fmt"
	"os"

	"github.com/narqo/go-badge"
)

func main() {
	err := badge.Render("godoc", "reference", "#5272B4", os.Stdout)
	if err != nil {
		panic(err)
	}

	badge, err := badge.RenderBytes("godoc", "reference", "#5272B4")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%s", badge)
}

Hope example/ directory will have more examples in future.

Contribution and Feedback

Contributing is more than welcome. Create an issue if you see any problem in the code or send a PR with fixes if you'd like.

License

MIT


All the kudos should go to the great Shields.io specification project.

Documentation

Index

Constants

View Source
const (
	ColorBrightgreen = Color("brightgreen")
	ColorGreen       = Color("green")
	ColorYellow      = Color("yellow")
	ColorYellowgreen = Color("yellowgreen")
	ColorOrange      = Color("orange")
	ColorRed         = Color("red")
	ColorBlue        = Color("blue")
	ColorGrey        = Color("grey")
	ColorGray        = Color("gray")
	ColorLightgrey   = Color("lightgrey")
	ColorLightgray   = Color("lightgray")
)

Standard colors.

View Source
const VersionString = "v0.3"

Variables

View Source
var ColorScheme = map[string]string{
	"brightgreen": "#4c1",
	"green":       "#97ca00",
	"yellow":      "#dfb317",
	"yellowgreen": "#a4a61d",
	"orange":      "#fe7d37",
	"red":         "#e05d44",
	"blue":        "#007ec6",
	"grey":        "#555",
	"gray":        "#555",
	"lightgrey":   "#9f9f9f",
	"lightgray":   "#9f9f9f",
}

ColorScheme contains named colors that could be used to render the badge.

Functions

func Render

func Render(subject, status string, color Color, w io.Writer) error

Render renders a badge of the given color, with given subject and status to w.

func RenderBytes

func RenderBytes(subject, status string, color Color) ([]byte, error)

RenderBytes renders a badge of the given color, with given subject and status to bytes.

Types

type Color

type Color string

Color represents color of the badge.

func (Color) String

func (c Color) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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