sprite

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Definition

type Definition struct {
	Icon    svg.Icon
	ViewBox string
	Body    string
}

Definition holds the data needed to build a <symbol>.

func Define

func Define(icon svg.Icon, viewBox string, body ...Node) Definition

Define creates a reusable icon definition.

type Node

type Node string

Node is internal typed markup for a symbol's body.

func Path

func Path(d string) Node

Path renders <path fill="currentColor" d="<d>"/>.

func Raw

func Raw(s string) Node

Raw is an escape hatch for markup that Path does not express.

type Sprite

type Sprite struct {
	// contains filtered or unexported fields
}

Sprite holds SVG icon definitions for server-side sprite sheet injection.

func NewSprite

func NewSprite(icons ...Definition) *Sprite

NewSprite constructs a *Sprite from typed icons.

func (*Sprite) AddFile added in v0.1.3

func (s *Sprite) AddFile(id, svgFile string) error

AddFile adds a whole .svg file (as read from disk) to the sprite as a <symbol>. The viewBox is taken from the file's root <svg> element, and only its inner markup becomes the symbol body — keeping the root tag would nest an <svg> inside the <symbol>, which is not valid sprite markup.

A file with no viewBox is rejected: nothing can recover the coordinate system the drawing was authored in, and defaulting to one clips or misaligns it.

func (*Sprite) AddRaw

func (s *Sprite) AddRaw(id, content, viewBox string)

AddRaw adds a raw symbol to the sprite. Used for assetmin's raw .svg file/favicon path.

func (*Sprite) Append

func (s *Sprite) Append() model.Fielder

func (*Sprite) At

func (s *Sprite) At(i int) model.Fielder

func (*Sprite) DecodeFields

func (s *Sprite) DecodeFields(r model.FieldReader)

func (*Sprite) EncodeFields

func (s *Sprite) EncodeFields(w model.FieldWriter)

func (*Sprite) Icons added in v0.1.8

func (s *Sprite) Icons() []Definition

Icons returns a copy of the sprite's typed icon definitions. Callers that need to inspect or recombine icons (e.g. assetmin merging per-module sprites) read this instead of round-tripping through String().

func (*Sprite) IsNil

func (s *Sprite) IsNil() bool

func (*Sprite) Len

func (s *Sprite) Len() int

func (*Sprite) MarshalJSON

func (s *Sprite) MarshalJSON() ([]byte, error)

func (*Sprite) Merge

func (s *Sprite) Merge(other *Sprite) *Sprite

Merge adds all icons from other into s.

func (*Sprite) Pointers

func (s *Sprite) Pointers() []any

func (*Sprite) Schema

func (s *Sprite) Schema() []model.Field

func (*Sprite) String

func (s *Sprite) String() string

String renders the sprite as inline SVG with all <symbol> elements.

func (*Sprite) UnmarshalJSON

func (s *Sprite) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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