Documentation
¶
Overview ¶
Package aesthetic provides design token management for markata-go themes.
Overview ¶
Aesthetics define non-color design tokens including:
- Radius tokens: Border radius values for different UI elements
- Spacing tokens: Spacing scale for consistent layout
- Border tokens: Border width and style definitions
- Shadow tokens: Box shadow definitions for elevation
- Typography tokens: Font families, sizes, and line heights
Aesthetic Presets ¶
Five built-in aesthetic presets are available:
- brutal: Sharp corners, tight spacing, bold borders
- precision: Subtle corners, compact spacing, clean lines
- balanced: Comfortable rounding, normal spacing (default)
- elevated: Generous rounding, layered shadows
- minimal: Maximum whitespace, flat design
Aesthetic Discovery ¶
Aesthetics are discovered in order:
- Project local: ./aesthetics/{name}.toml
- User config: ~/.config/markata-go/aesthetics/{name}.toml
- Built-in: embedded aesthetics
Usage ¶
// Load an aesthetic by name
a, err := aesthetic.LoadAesthetic("modern")
if err != nil {
log.Fatal(err)
}
// Generate CSS custom properties
css := a.GenerateCSS()
// List available aesthetics
names := aesthetic.ListAesthetics()
Relationship to Palettes ¶
Aesthetics complement palettes: palettes define colors, aesthetics define everything else. Together they form a complete theme system.
Index ¶
- Variables
- func BuiltinNames() []string
- func HasBuiltin(name string) bool
- type Aesthetic
- func (a *Aesthetic) Clone() *Aesthetic
- func (a *Aesthetic) GenerateCSS() string
- func (a *Aesthetic) GenerateCSSMinified() string
- func (a *Aesthetic) GenerateCSSWithFormat(format CSSFormat) string
- func (a *Aesthetic) Get(tokenType, tokenKey string) string
- func (a *Aesthetic) GetSpacingScale() float64
- func (a *Aesthetic) GetWithDefault(tokenType, tokenKey, defaultVal string) string
- func (a *Aesthetic) Merge(override *Aesthetic) *Aesthetic
- func (a *Aesthetic) Validate() []error
- type CSSFormat
- type Info
- type LoadError
- type Loader
- type ParseError
- type SpacingTokens
- type Tokens
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAestheticNotFound is returned when an aesthetic cannot be found. ErrAestheticNotFound = errors.New("aesthetic not found") // ErrInvalidAesthetic is returned when an aesthetic file is malformed. ErrInvalidAesthetic = errors.New("invalid aesthetic") )
Common errors returned by the aesthetic package.
var DefaultLoader = NewLoader()
DefaultLoader is the default aesthetic loader instance.
Functions ¶
func BuiltinNames ¶
func BuiltinNames() []string
BuiltinNames returns the names of all built-in aesthetics.
func HasBuiltin ¶
HasBuiltin checks if a built-in aesthetic with the given name exists.
Types ¶
type Aesthetic ¶
type Aesthetic struct {
// Metadata
Name string `json:"name" yaml:"name" toml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty" toml:"description,omitempty"`
// Tokens organized by category
Tokens Tokens `json:"tokens" yaml:"tokens" toml:"tokens"`
// Legacy flat maps for CSS generation compatibility
// These are populated from Tokens when GenerateCSS is called
Typography map[string]string `json:"-" yaml:"-" toml:"-"`
Spacing map[string]string `json:"-" yaml:"-" toml:"-"`
Borders map[string]string `json:"-" yaml:"-" toml:"-"`
Shadows map[string]string `json:"-" yaml:"-" toml:"-"`
// Source information (set after loading)
Source string `json:"-" yaml:"-" toml:"-"` // "built-in", "user", "project"
SourcePath string `json:"-" yaml:"-" toml:"-"` // File path if loaded from file
}
Aesthetic represents a complete design token set with metadata.
func LoadBuiltin ¶
LoadBuiltin loads a built-in aesthetic by name.
func LoadFromFile ¶
LoadFromFile loads an aesthetic from a specific file path.
func NewAesthetic ¶
NewAesthetic creates a new empty aesthetic with initialized maps.
func (*Aesthetic) GenerateCSS ¶
GenerateCSS generates CSS custom properties for the aesthetic.
func (*Aesthetic) GenerateCSSMinified ¶
GenerateCSSMinified generates minified CSS custom properties.
func (*Aesthetic) GenerateCSSWithFormat ¶
GenerateCSSWithFormat generates CSS with the specified format options.
func (*Aesthetic) Get ¶
Get retrieves a token value by type and key. Returns empty string if not found.
func (*Aesthetic) GetSpacingScale ¶
GetSpacingScale returns the spacing scale multiplier. Returns 1.0 if no spacing is configured.
func (*Aesthetic) GetWithDefault ¶
GetWithDefault retrieves a token value, returning defaultVal if not found.
type CSSFormat ¶
type CSSFormat struct {
IncludeTypography bool // Include typography tokens
IncludeSpacing bool // Include spacing tokens
IncludeBorders bool // Include border tokens
IncludeShadows bool // Include shadow tokens
Minify bool // Produce minified output
Prefix string // Custom prefix for CSS variables (e.g., "theme" -> "--theme-radius-sm")
}
CSSFormat controls how CSS is generated.
func DefaultCSSFormat ¶
func DefaultCSSFormat() CSSFormat
DefaultCSSFormat returns the default CSS format options.
type Info ¶
type Info struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Source string `json:"source"` // "built-in", "user", "project"
Path string `json:"path,omitempty"`
}
Info contains summary information about an aesthetic for listing.
func DiscoverBuiltin ¶
func DiscoverBuiltin() []Info
DiscoverBuiltin returns info for all built-in aesthetics.
func ListAesthetics ¶
func ListAesthetics() []Info
ListAesthetics returns info for all available aesthetics (built-in and discovered).
type LoadError ¶
type LoadError struct {
Name string // Aesthetic name that failed to load
Path string // Path attempted (if applicable)
Message string // Human-readable error message
Err error // Underlying error
}
LoadError provides context for aesthetic loading failures.
func NewLoadError ¶
NewLoadError creates a new LoadError.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles aesthetic discovery and loading from multiple sources.
func NewLoader ¶
func NewLoader() *Loader
NewLoader creates a new Loader with default search paths. Search order: built-in, user config, project directory.
func NewLoaderWithPaths ¶
NewLoaderWithPaths creates a new Loader with custom search paths.
func (*Loader) AddPath ¶
AddPath adds a search path to the loader. Paths added later have higher priority.
type ParseError ¶
type ParseError struct {
Path string // File path that failed to parse
Message string // Human-readable error message
Err error // Underlying error
}
ParseError provides context for aesthetic parsing failures.
func NewParseError ¶
func NewParseError(path, message string, err error) *ParseError
NewParseError creates a new ParseError.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type SpacingTokens ¶
type SpacingTokens struct {
Scale float64 `json:"scale" yaml:"scale" toml:"scale"`
}
SpacingTokens holds spacing-related design tokens.
type Tokens ¶
type Tokens struct {
Radius map[string]string `json:"radius,omitempty" yaml:"radius,omitempty" toml:"radius,omitempty"`
Spacing *SpacingTokens `json:"spacing,omitempty" yaml:"spacing,omitempty" toml:"spacing,omitempty"`
Border map[string]string `json:"border,omitempty" yaml:"border,omitempty" toml:"border,omitempty"`
Shadow map[string]string `json:"shadow,omitempty" yaml:"shadow,omitempty" toml:"shadow,omitempty"`
Typography map[string]string `json:"typography,omitempty" yaml:"typography,omitempty" toml:"typography,omitempty"`
}
Tokens holds all design token categories for an aesthetic.
type ValidationError ¶
type ValidationError struct {
Field string // Field that failed validation
Message string // Human-readable error message
}
ValidationError represents an aesthetic validation failure.
func NewValidationError ¶
func NewValidationError(field, message string) *ValidationError
NewValidationError creates a new ValidationError.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string