Skip to content

Commit

Permalink
added icon funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Corné de Jong committed Oct 26, 2024
1 parent 7a599d2 commit bd0a2c2
Show file tree
Hide file tree
Showing 3 changed files with 1,876 additions and 35 deletions.
38 changes: 19 additions & 19 deletions golucide.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
)

var DefaultAttributes = Attributes{
var DefaultIconAttributes = iconAttributes{
Width: 24,
Height: 24,
Fill: "none",
Expand All @@ -14,7 +14,7 @@ var DefaultAttributes = Attributes{
StrokeLineJoin: "round",
}

type Attributes struct {
type iconAttributes struct {
Width int
Height int
Fill string
Expand All @@ -24,59 +24,59 @@ type Attributes struct {
StrokeLineJoin string
}

type Option func(*Attributes)
type iconOption func(*iconAttributes)

func Size(size int) Option {
return func(a *Attributes) {
func Size(size int) iconOption {
return func(a *iconAttributes) {
a.Width = size
a.Height = size
}
}

func SizeHW(width, height int) Option {
return func(a *Attributes) {
func SizeHW(width, height int) iconOption {
return func(a *iconAttributes) {
a.Width = width
a.Height = height
}
}

func StrokeWidth(strokeWidth int) Option {
return func(a *Attributes) {
func StrokeWidth(strokeWidth int) iconOption {
return func(a *iconAttributes) {
a.StrokeWidth = strokeWidth
}
}

func Fill(fill string) Option {
return func(a *Attributes) {
func Fill(fill string) iconOption {
return func(a *iconAttributes) {
a.Fill = fill
}
}

func StrokeColor(stroke string) Option {
return func(a *Attributes) {
func StrokeColor(stroke string) iconOption {
return func(a *iconAttributes) {
a.Stroke = stroke
}
}

func StrokeLineCap(lineCap string) Option {
return func(a *Attributes) {
func StrokeLineCap(lineCap string) iconOption {
return func(a *iconAttributes) {
a.StrokeLineCap = lineCap
}
}

func StrokeLineJoin(lineJoin string) Option {
return func(a *Attributes) {
func StrokeLineJoin(lineJoin string) iconOption {
return func(a *iconAttributes) {
a.StrokeLineJoin = lineJoin
}
}

func GetIcon(iconName string, opts ...Option) string {
func GetIcon(iconName string, opts ...iconOption) string {
template, exists := icons[iconName]
if !exists {
return ""
}

attrs := DefaultAttributes
attrs := DefaultIconAttributes
for _, opt := range opts {
opt(&attrs)
}
Expand Down
Loading

0 comments on commit bd0a2c2

Please sign in to comment.