tag

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChipColors = []string{
	"bg-red-100 text-red-800",
	"bg-orange-100 text-orange-800",
	"bg-amber-100 text-amber-800",
	"bg-yellow-100 text-yellow-800",
	"bg-lime-100 text-lime-800",
	"bg-green-100 text-green-800",
	"bg-emerald-100 text-emerald-800",
	"bg-teal-100 text-teal-800",
	"bg-cyan-100 text-cyan-800",
	"bg-sky-100 text-sky-800",
	"bg-blue-100 text-blue-800",
	"bg-indigo-100 text-indigo-800",
	"bg-violet-100 text-violet-800",
	"bg-purple-100 text-purple-800",
	"bg-fuchsia-100 text-fuchsia-800",
	"bg-pink-100 text-pink-800",
	"bg-rose-100 text-rose-800",
	"bg-slate-100 text-slate-800",
	"bg-gray-100 text-gray-800",
	"bg-zinc-100 text-zinc-800",
}

ChipColors contains predefined colors suitable for chips/badges

View Source
var ColorNames = []string{
	"red",
	"orange",
	"amber",
	"yellow",
	"lime",
	"green",
	"emerald",
	"teal",
	"cyan",
	"sky",
	"blue",
	"indigo",
	"violet",
	"purple",
	"fuchsia",
	"pink",
	"rose",
	"slate",
	"gray",
	"zinc",
}

ColorNames provides user-friendly color names corresponding to ChipColors

Functions

func ColorClassToName

func ColorClassToName(colorClass string) string

ColorClassToName converts a Tailwind color class to a user-friendly name

func ColorNameToClass

func ColorNameToClass(colorName string) string

ColorNameToClass converts a user-friendly color name to a Tailwind color class

func ConvertIDsToNames

func ConvertIDsToNames(ctx context.Context, tagIDs map[string]bool, tagGetter func(context.Context, []string) ([]*Tag, error)) ([]string, error)

ConvertIDsToNames converts tag IDs to tag names using the provided getter function

func GenerateColor

func GenerateColor(tagName string) string

GenerateColor generates a deterministic color for a tag name Uses FNV-1a hash to ensure same tag names always get the same color

func MergeTagIDs

func MergeTagIDs(existingTags, newTags []string) []string

MergeTagIDs merges two slices of tag IDs, removing duplicates

func MergeTags

func MergeTags(existingTags, newTags []string) []string

MergeTags merges two slices of tag strings, removing duplicates

func NewID

func NewID() string

NewID generates a new unique tag ID

func NewTagIDsMap

func NewTagIDsMap(tagIDs []string) map[string]bool

NewTagIDsMap creates a new tag IDs map from a slice

func TagIDsMapToSlice

func TagIDsMapToSlice(tagIDs map[string]bool) []string

TagIDsMapToSlice converts tag IDs map to slice

Types

type IDSet

type IDSet map[string]bool

IDSet represents a set of tag IDs using map for O(1) operations

func NewIDSet

func NewIDSet(tagIDs []string) IDSet

NewIDSet creates a new IDSet from a slice of TagIDs

func (IDSet) Add

func (ts IDSet) Add(tagID string)

Add adds a tag ID to the set

func (IDSet) Copy

func (ts IDSet) Copy() IDSet

Copy creates a copy of the IDSet

func (IDSet) Has

func (ts IDSet) Has(tagID string) bool

Has checks if a tag ID exists in the set

func (IDSet) Remove

func (ts IDSet) Remove(tagID string)

Remove removes a tag ID from the set

func (IDSet) ToSlice

func (ts IDSet) ToSlice() []string

ToSlice converts IDSet to a slice of TagIDs

type Metadata deprecated

type Metadata struct {
	Name      string    `json:"name"`
	Color     string    `json:"color"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Metadata represents metadata about a tag (deprecated, use Tag instead)

Deprecated: Use Tag struct instead for new implementations

type Set

type Set map[string]bool

Set represents a set of tags using map for O(1) operations

func NewSet

func NewSet(tags []string) Set

NewSet creates a new Set from a slice of strings

func (Set) Add

func (ts Set) Add(tag string)

Add adds a tag to the set

func (Set) Copy

func (ts Set) Copy() Set

Copy creates a copy of the Set

func (Set) Has

func (ts Set) Has(tag string) bool

Has checks if a tag exists in the set

func (Set) Remove

func (ts Set) Remove(tag string)

Remove removes a tag from the set

func (Set) ToSlice

func (ts Set) ToSlice() []string

ToSlice converts Set to a slice of strings

type Tag

type Tag struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description string    `json:"description,omitempty"`
	Color       string    `json:"color"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	CreatedBy   string    `json:"created_by,omitempty"`
}

Tag represents a tag entity with ID-based management

Jump to

Keyboard shortcuts

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