Documentation
¶
Overview ¶
Package dss provides Go types for the Design System Specification.
Index ¶
- Variables
- func GenerateAccessibilitySchema() *jsonschema.Schema
- func GenerateComponentSchema() *jsonschema.Schema
- func GenerateFoundationsSchema() *jsonschema.Schema
- func GenerateGovernanceSchema() *jsonschema.Schema
- func GenerateMetaSchema() *jsonschema.Schema
- func GeneratePatternSchema() *jsonschema.Schema
- func GenerateSchema() *jsonschema.Schema
- func GenerateTemplateSchema() *jsonschema.Schema
- func IsValidSemantic(semantic string) bool
- func SaveDesignSystem(ds *DesignSystem, path string) error
- func TotalErrors(reports []*ContractReport) int
- func TotalWarnings(reports []*ContractReport) int
- func WriteBindings(w io.Writer, bindings []GeneratedBinding) error
- type Accessibility
- type AccessibilityGuideline
- type BindingFormat
- type BindingOptions
- type BorderRadiusToken
- type BorderWidthToken
- type Breakpoint
- type CSSGeneratorOptions
- type ColorContrastRequirements
- type ColorToken
- type Component
- type ComponentA11y
- type ComponentEvent
- type Constraints
- type Content
- type ContractIssue
- type ContractReport
- type Contrast
- type ContributionPolicy
- type ContributionTemplate
- type ContributionWorkflow
- type D2Options
- type DecisionProcess
- type DeprecatedItem
- type DeprecationPolicy
- type DesignSystem
- func (ds *DesignSystem) GenerateCSS(opts CSSGeneratorOptions) (string, error)
- func (ds *DesignSystem) GenerateD2(opts D2Options) (string, error)
- func (ds *DesignSystem) GenerateD2ComponentDiagram(componentID string, opts D2Options) (string, error)
- func (ds *DesignSystem) GenerateDocs(opts DocsOptions) (*DocsOutput, error)
- func (ds *DesignSystem) GenerateLLMPrompt(opts LLMPromptOptions) (string, error)
- func (ds *DesignSystem) GenerateMermaid(opts MermaidOptions) (string, error)
- func (ds *DesignSystem) GenerateMermaidComponentDiagram(componentID string, opts MermaidOptions) (string, error)
- func (ds *DesignSystem) GenerateMermaidTokenDiagram(opts MermaidOptions) (string, error)
- func (ds *DesignSystem) GenerateReactTypes(opts ReactGeneratorOptions) (string, error)
- func (ds *DesignSystem) GenerateW3CTokens(opts W3CTokensOptions) (string, error)
- func (ds *DesignSystem) Validate() error
- type DocsOptions
- type DocsOutput
- type DurationToken
- type EasingToken
- type ElevationToken
- type EventDetailField
- type FontFamily
- type FontSize
- type FontWeight
- type Foundations
- type GeneratedBinding
- type Governance
- type GridSystem
- type KeyboardInteraction
- type KeyboardRequirements
- type LLMContext
- type LLMPromptOptions
- type LetterSpacing
- type LineHeight
- type Maintainer
- type MermaidOptions
- type Meta
- type MicrocopyGuideline
- type MicrocopyVariable
- type MotionRequirements
- type MotionSystem
- type OpacityToken
- type OwnershipRecord
- type Pattern
- type PatternA11y
- type PatternComponent
- type PatternLayout
- type PatternVariation
- type Principle
- type PrincipleExample
- type Prop
- type PropConstraints
- type ReactGeneratorOptions
- type ResponsiveLayout
- type ResponsiveTemplate
- type ScreenReaderRequirements
- type Slot
- type SpacingScale
- type SpacingToken
- type State
- type SupportPolicy
- type SupportedVersion
- type Template
- type TemplateGrid
- type TemplateRegion
- type TemplateRegionChange
- type TermDefinition
- type Terminology
- type TestingRequirement
- type ThemeBindings
- type ThemeToken
- type ThemingContract
- type TokenBindingResult
- type TokenMapping
- type TokenOverride
- type ToneGuideline
- type TouchTargetRequirements
- type TypeStyle
- type Typography
- type ValidationError
- type Variant
- type VersioningPolicy
- type VoiceAttribute
- type VoiceExample
- type VoiceGuidelines
- type W3CFontFamily
- type W3CToken
- type W3CTokenFile
- type W3CTokensOptions
- type WithLLMContext
- type WorkflowStep
- type WritingStyle
- type ZIndexToken
Constants ¶
This section is empty.
Variables ¶
var ValidSemantics = []string{
"primary",
"secondary",
"accent",
"danger",
"warning",
"success",
"info",
"neutral",
"surface",
"background",
"text",
"text-muted",
"text-inverse",
"border",
"focus",
"disabled",
"shadow",
}
ValidSemantics lists the allowed semantic values for ThemeToken.Semantic.
Functions ¶
func GenerateAccessibilitySchema ¶
func GenerateAccessibilitySchema() *jsonschema.Schema
GenerateAccessibilitySchema generates a JSON Schema for the Accessibility type.
func GenerateComponentSchema ¶
func GenerateComponentSchema() *jsonschema.Schema
GenerateComponentSchema generates a JSON Schema for the Component type.
func GenerateFoundationsSchema ¶
func GenerateFoundationsSchema() *jsonschema.Schema
GenerateFoundationsSchema generates a JSON Schema for the Foundations type.
func GenerateGovernanceSchema ¶
func GenerateGovernanceSchema() *jsonschema.Schema
GenerateGovernanceSchema generates a JSON Schema for the Governance type.
func GenerateMetaSchema ¶
func GenerateMetaSchema() *jsonschema.Schema
GenerateMetaSchema generates a JSON Schema for the Meta type.
func GeneratePatternSchema ¶
func GeneratePatternSchema() *jsonschema.Schema
GeneratePatternSchema generates a JSON Schema for the Pattern type.
func GenerateSchema ¶
func GenerateSchema() *jsonschema.Schema
GenerateSchema generates a JSON Schema for the DesignSystem type.
func GenerateTemplateSchema ¶
func GenerateTemplateSchema() *jsonschema.Schema
GenerateTemplateSchema generates a JSON Schema for the Template type.
func IsValidSemantic ¶ added in v0.3.0
IsValidSemantic checks if a semantic value is in the allowed set.
func SaveDesignSystem ¶
func SaveDesignSystem(ds *DesignSystem, path string) error
SaveDesignSystem saves a design system to a JSON file.
func TotalErrors ¶ added in v0.3.0
func TotalErrors(reports []*ContractReport) int
TotalErrors returns the total number of errors across all reports.
func TotalWarnings ¶ added in v0.3.0
func TotalWarnings(reports []*ContractReport) int
TotalWarnings returns the total number of warnings across all reports.
func WriteBindings ¶ added in v0.3.0
func WriteBindings(w io.Writer, bindings []GeneratedBinding) error
WriteBindings writes all generated bindings to a writer.
Types ¶
type Accessibility ¶
type Accessibility struct {
// WCAGLevel is the target WCAG conformance level (A, AA, AAA).
WCAGLevel string `json:"wcagLevel" jsonschema:"enum=A,enum=AA,enum=AAA"`
// WCAGVersion is the WCAG version (e.g., "2.1", "2.2").
WCAGVersion string `json:"wcagVersion,omitempty"`
// ColorContrast defines color contrast requirements.
ColorContrast *ColorContrastRequirements `json:"colorContrast,omitempty"`
// Keyboard defines keyboard accessibility requirements.
Keyboard *KeyboardRequirements `json:"keyboard,omitempty"`
// ScreenReader defines screen reader support requirements.
ScreenReader *ScreenReaderRequirements `json:"screenReader,omitempty"`
// Motion defines motion and animation requirements.
Motion *MotionRequirements `json:"motion,omitempty"`
// TouchTarget defines touch target size requirements.
TouchTarget *TouchTargetRequirements `json:"touchTarget,omitempty"`
// Guidelines provides additional accessibility guidelines.
Guidelines []AccessibilityGuideline `json:"guidelines,omitempty"`
// TestingRequirements describes required accessibility testing.
TestingRequirements []TestingRequirement `json:"testingRequirements,omitempty"`
}
Accessibility defines system-wide accessibility requirements and guidelines.
type AccessibilityGuideline ¶
type AccessibilityGuideline struct {
// ID is a unique identifier.
ID string `json:"id"`
// Title is a short title for the guideline.
Title string `json:"title"`
// Description explains the guideline.
Description string `json:"description"`
// WCAGCriteria lists related WCAG success criteria.
WCAGCriteria []string `json:"wcagCriteria,omitempty"`
// Examples demonstrate the guideline.
Examples []string `json:"examples,omitempty"`
}
AccessibilityGuideline provides additional accessibility guidance.
type BindingFormat ¶ added in v0.3.0
type BindingFormat string
BindingFormat specifies the output format for generated bindings.
const ( FormatCSS BindingFormat = "css" FormatTypeScript BindingFormat = "typescript" FormatSCSS BindingFormat = "scss" )
type BindingOptions ¶ added in v0.3.0
type BindingOptions struct {
// Format specifies the output format.
Format BindingFormat
// SpecDir is the directory containing the design system spec.
// Used to resolve local component references.
SpecDir string
// DefaultStrategy is the fallback strategy when not specified in bindings.
DefaultStrategy string
}
BindingOptions configures binding generation.
type BorderRadiusToken ¶
type BorderRadiusToken struct {
// ID is a unique identifier (e.g., "none", "sm", "md", "lg", "full").
ID string `json:"id"`
// Value is the border radius with unit.
Value string `json:"value"`
}
BorderRadiusToken represents a border radius value.
type BorderWidthToken ¶
type BorderWidthToken struct {
// ID is a unique identifier (e.g., "none", "thin", "thick").
ID string `json:"id"`
// Value is the border width with unit.
Value string `json:"value"`
}
BorderWidthToken represents a border width value.
type Breakpoint ¶
type Breakpoint struct {
// ID is a unique identifier (e.g., "sm", "md", "lg", "xl").
ID string `json:"id"`
// MinWidth is the minimum viewport width for this breakpoint.
MinWidth string `json:"minWidth"`
// MaxWidth is the maximum viewport width (optional).
MaxWidth string `json:"maxWidth,omitempty"`
// Columns overrides the grid columns at this breakpoint.
Columns int `json:"columns,omitempty"`
}
Breakpoint defines a responsive breakpoint.
type CSSGeneratorOptions ¶
type CSSGeneratorOptions struct {
// Format specifies output format: "tailwind4" (default), "css-vars", "scss"
Format string
// Prefix for CSS variable names (e.g., "pm" → "--pm-color-primary")
Prefix string
// IncludeComments adds usage descriptions as CSS comments
IncludeComments bool
// IncludeDarkMode generates dark mode variants
IncludeDarkMode bool
}
CSSGeneratorOptions configures CSS output format.
func DefaultCSSOptions ¶
func DefaultCSSOptions() CSSGeneratorOptions
DefaultCSSOptions returns sensible defaults for CSS generation.
type ColorContrastRequirements ¶
type ColorContrastRequirements struct {
// NormalTextRatio is the minimum ratio for normal text.
NormalTextRatio float64 `json:"normalTextRatio"`
// LargeTextRatio is the minimum ratio for large text.
LargeTextRatio float64 `json:"largeTextRatio"`
// NonTextRatio is the minimum ratio for non-text elements.
NonTextRatio float64 `json:"nonTextRatio,omitempty"`
// LargeTextThreshold defines what counts as large text (in pixels).
LargeTextThreshold int `json:"largeTextThreshold,omitempty"`
}
ColorContrastRequirements defines contrast ratio requirements.
type ColorToken ¶
type ColorToken struct {
// ID is a unique identifier (e.g., "primary-500", "danger-base").
ID string `json:"id"`
// Value is the color value in hex, rgb, rgba, or hsl format.
Value string `json:"value"`
// Semantic indicates the color's purpose (primary, secondary, danger, etc.).
Semantic string `json:"semantic,omitempty"`
// Usage describes when and how to use this color (LLM optimization).
Usage string `json:"usage,omitempty"`
// Contrast provides accessibility contrast information.
Contrast *Contrast `json:"contrast,omitempty"`
// LightModeValue is an alternate value for light mode (if different).
LightModeValue string `json:"lightModeValue,omitempty"`
// DarkModeValue is an alternate value for dark mode.
DarkModeValue string `json:"darkModeValue,omitempty"`
}
ColorToken represents a single color in the design system.
type Component ¶
type Component struct {
// ID is a unique identifier (e.g., "button", "input", "modal").
ID string `json:"id"`
// Name is a display name for the component.
Name string `json:"name"`
// Description provides an overview of the component's purpose.
Description string `json:"description,omitempty"`
// Category groups related components (e.g., "inputs", "navigation", "feedback").
Category string `json:"category,omitempty"`
// Variants define different visual or behavioral versions.
Variants []Variant `json:"variants,omitempty"`
// States define interactive states (hover, focus, disabled, etc.).
States []State `json:"states,omitempty"`
// Props define configurable properties/attributes.
Props []Prop `json:"props,omitempty"`
// Events define custom events emitted by the component.
Events []ComponentEvent `json:"events,omitempty"`
// Slots define content insertion points for composition.
Slots []Slot `json:"slots,omitempty"`
// Uses lists component IDs this component depends on.
Uses []string `json:"uses,omitempty"`
// TokensUsed references foundation token IDs used by this component.
TokensUsed []string `json:"tokensUsed,omitempty"`
// Constraints define usage limitations and requirements.
Constraints *Constraints `json:"constraints,omitempty"`
// ThemingContract defines the external theming API for this component.
ThemingContract *ThemingContract `json:"themingContract,omitempty"`
// Accessibility defines a11y requirements for this component.
Accessibility *ComponentA11y `json:"accessibility,omitempty"`
// LLM provides optimization fields for AI code generation.
LLM *LLMContext `json:"llm,omitempty"`
// DocumentationURL links to detailed documentation.
DocumentationURL string `json:"documentationUrl,omitempty" jsonschema:"format=uri"`
// FigmaURL links to the Figma component.
FigmaURL string `json:"figmaUrl,omitempty" jsonschema:"format=uri"`
}
Component represents a reusable UI element in the design system.
func (*Component) GenerateTypes ¶
func (c *Component) GenerateTypes(opts ReactGeneratorOptions) string
GenerateComponentTypes generates TypeScript for a single component.
type ComponentA11y ¶
type ComponentA11y struct {
// Role is the ARIA role for the component.
Role string `json:"role,omitempty"`
// RequiredAttributes lists required ARIA attributes.
RequiredAttributes []string `json:"requiredAttributes,omitempty"`
// KeyboardSupport describes keyboard interaction requirements.
KeyboardSupport []KeyboardInteraction `json:"keyboardSupport,omitempty"`
// ScreenReaderNotes provides guidance for screen reader users.
ScreenReaderNotes string `json:"screenReaderNotes,omitempty"`
// FocusManagement describes focus behavior.
FocusManagement string `json:"focusManagement,omitempty"`
}
ComponentA11y defines accessibility requirements for a component.
type ComponentEvent ¶ added in v0.3.0
type ComponentEvent struct {
// Name is the event name (e.g., "change", "submit", "close").
Name string `json:"name"`
// Description explains when this event is emitted.
Description string `json:"description,omitempty"`
// Bubbles indicates whether the event bubbles up the DOM tree.
Bubbles bool `json:"bubbles,omitempty"`
// Detail describes the event detail payload fields.
Detail []EventDetailField `json:"detail,omitempty"`
}
ComponentEvent represents a custom event emitted by a component.
type Constraints ¶
type Constraints struct {
// MinWidth is the minimum recommended width.
MinWidth string `json:"minWidth,omitempty"`
// MaxWidth is the maximum recommended width.
MaxWidth string `json:"maxWidth,omitempty"`
// MaxChildren limits the number of child elements.
MaxChildren int `json:"maxChildren,omitempty"`
// RequiredParent specifies a required parent component.
RequiredParent string `json:"requiredParent,omitempty"`
// ForbiddenChildren lists components that cannot be nested inside.
ForbiddenChildren []string `json:"forbiddenChildren,omitempty"`
// ResponsiveBehavior describes how the component adapts.
ResponsiveBehavior string `json:"responsiveBehavior,omitempty"`
}
Constraints define usage limitations for a component.
type Content ¶
type Content struct {
// Voice describes the brand's personality and communication style.
Voice *VoiceGuidelines `json:"voice,omitempty"`
// Tone provides guidance on adapting voice to different contexts.
Tone []ToneGuideline `json:"tone,omitempty"`
// Terminology defines preferred and avoided terms.
Terminology *Terminology `json:"terminology,omitempty"`
// Microcopy provides templates for common UI text.
Microcopy []MicrocopyGuideline `json:"microcopy,omitempty"`
// WritingStyle provides general writing guidelines.
WritingStyle *WritingStyle `json:"writingStyle,omitempty"`
}
Content defines voice, tone, and content guidelines.
type ContractIssue ¶ added in v0.3.0
type ContractIssue struct {
// Field is the JSON path to the problematic field.
Field string `json:"field"`
// Message describes the issue.
Message string `json:"message"`
// TokenID is the affected token ID, if applicable.
TokenID string `json:"tokenId,omitempty"`
}
ContractIssue represents a validation error or warning.
type ContractReport ¶ added in v0.3.0
type ContractReport struct {
// ComponentID is the ID of the validated component.
ComponentID string `json:"componentId"`
// Passed indicates whether validation passed without errors.
Passed bool `json:"passed"`
// Errors are critical issues that must be fixed.
Errors []ContractIssue `json:"errors,omitempty"`
// Warnings are non-critical issues that should be addressed.
Warnings []ContractIssue `json:"warnings,omitempty"`
}
ContractReport contains the results of validating a theming contract.
func ValidateAllContracts ¶ added in v0.3.0
func ValidateAllContracts(ds *DesignSystem) []*ContractReport
ValidateAllContracts validates all components' theming contracts in a design system.
func ValidateContract ¶ added in v0.3.0
func ValidateContract(component *Component) *ContractReport
ValidateContract validates a component's theming contract for completeness and correctness.
type Contrast ¶
type Contrast struct {
// OnLight is the recommended text color when this color is on a light background.
OnLight string `json:"onLight,omitempty"`
// OnDark is the recommended text color when this color is on a dark background.
OnDark string `json:"onDark,omitempty"`
// Ratio is the contrast ratio against the primary background.
Ratio float64 `json:"ratio,omitempty"`
// WCAGLevel indicates the WCAG compliance level (AA, AAA).
WCAGLevel string `json:"wcagLevel,omitempty" jsonschema:"enum=AA,enum=AAA"`
}
Contrast provides WCAG contrast ratio information.
type ContributionPolicy ¶
type ContributionPolicy struct {
// Description provides an overview of the contribution process.
Description string `json:"description,omitempty"`
// Guidelines lists contribution guidelines.
Guidelines []string `json:"guidelines,omitempty"`
// Workflow describes the contribution workflow.
Workflow *ContributionWorkflow `json:"workflow,omitempty"`
// Templates provides PR/issue templates.
Templates []ContributionTemplate `json:"templates,omitempty"`
// CodeOfConductURL links to the code of conduct.
CodeOfConductURL string `json:"codeOfConductUrl,omitempty" jsonschema:"format=uri"`
}
ContributionPolicy describes contribution guidelines.
type ContributionTemplate ¶
type ContributionTemplate struct {
// Type is the template type (pr, issue, rfc).
Type string `json:"type"`
// Name is the template name.
Name string `json:"name"`
// URL links to the template file.
URL string `json:"url,omitempty" jsonschema:"format=uri"`
}
ContributionTemplate provides a template for contributions.
type ContributionWorkflow ¶
type ContributionWorkflow struct {
// Steps lists the contribution steps.
Steps []WorkflowStep `json:"steps"`
// RequiredReviewers lists required reviewer roles.
RequiredReviewers []string `json:"requiredReviewers,omitempty"`
// AutomatedChecks lists automated checks that must pass.
AutomatedChecks []string `json:"automatedChecks,omitempty"`
}
ContributionWorkflow describes the steps for contributing.
type D2Options ¶ added in v0.3.0
type D2Options struct {
// Direction: "right", "down", "left", "up"
Direction string
// ShowTokens includes token relationships
ShowTokens bool
// ShowEvents includes event flow
ShowEvents bool
// ShowSlots includes slot composition
ShowSlots bool
// ShowProps includes property lists
ShowProps bool
// GroupByCategory groups components by category
GroupByCategory bool
// Theme: "default", "neutral", "earth", "terminal", etc.
Theme string
// Sketch mode for hand-drawn look
Sketch bool
}
D2Options configures D2 diagram output.
func DefaultD2Options ¶ added in v0.3.0
func DefaultD2Options() D2Options
DefaultD2Options returns sensible defaults.
type DecisionProcess ¶
type DecisionProcess struct {
// Description provides an overview of the decision process.
Description string `json:"description,omitempty"`
// RFCRequired indicates whether RFCs are required for changes.
RFCRequired bool `json:"rfcRequired,omitempty"`
// ApprovalRequired lists who must approve changes.
ApprovalRequired []string `json:"approvalRequired,omitempty"`
// DecisionRecordLocation is where decisions are documented.
DecisionRecordLocation string `json:"decisionRecordLocation,omitempty"`
}
DecisionProcess describes how design decisions are made.
type DeprecatedItem ¶
type DeprecatedItem struct {
// Type is the item type (component, token, pattern).
Type string `json:"type"`
// ID is the item identifier.
ID string `json:"id"`
// DeprecatedSince is when the item was deprecated.
DeprecatedSince string `json:"deprecatedSince"`
// RemovalDate is when the item will be removed.
RemovalDate string `json:"removalDate,omitempty"`
// Replacement is the ID of the replacement item.
Replacement string `json:"replacement,omitempty"`
// MigrationGuideURL links to migration documentation.
MigrationGuideURL string `json:"migrationGuideUrl,omitempty" jsonschema:"format=uri"`
// Reason explains why the item was deprecated.
Reason string `json:"reason,omitempty"`
}
DeprecatedItem describes a deprecated item in the design system.
type DeprecationPolicy ¶
type DeprecationPolicy struct {
// WarningPeriod is the minimum time items remain deprecated before removal.
WarningPeriod string `json:"warningPeriod"`
// NotificationChannels lists how deprecations are communicated.
NotificationChannels []string `json:"notificationChannels,omitempty"`
// MigrationGuideRequired indicates whether migration guides are required.
MigrationGuideRequired bool `json:"migrationGuideRequired,omitempty"`
// DeprecatedItems lists currently deprecated items.
DeprecatedItems []DeprecatedItem `json:"deprecatedItems,omitempty"`
}
DeprecationPolicy describes how items are deprecated.
type DesignSystem ¶
type DesignSystem struct {
// Meta contains system-level metadata.
Meta Meta `json:"meta"`
// Principles defines design philosophy and brand values.
Principles []Principle `json:"principles,omitempty"`
// Foundations contains design tokens (colors, typography, spacing, etc.).
Foundations Foundations `json:"foundations"`
// Components defines reusable UI elements.
Components []Component `json:"components,omitempty"`
// Patterns defines multi-component UX solutions.
Patterns []Pattern `json:"patterns,omitempty"`
// Templates defines page-level layouts.
Templates []Template `json:"templates,omitempty"`
// Content defines voice, tone, and content guidelines.
Content *Content `json:"content,omitempty"`
// Accessibility defines system-wide accessibility requirements.
Accessibility *Accessibility `json:"accessibility,omitempty"`
// Governance defines versioning, contribution, and deprecation policies.
Governance *Governance `json:"governance,omitempty"`
// ThemeBindings maps application tokens to component theming contracts.
ThemeBindings []ThemeBindings `json:"themeBindings,omitempty"`
}
DesignSystem is the root type representing a complete design system specification.
func LoadDesignSystem ¶
func LoadDesignSystem(path string) (*DesignSystem, error)
LoadDesignSystem loads a design system from a directory or single file.
func (*DesignSystem) GenerateCSS ¶
func (ds *DesignSystem) GenerateCSS(opts CSSGeneratorOptions) (string, error)
GenerateCSS generates CSS custom properties from the design system foundations.
func (*DesignSystem) GenerateD2 ¶ added in v0.3.0
func (ds *DesignSystem) GenerateD2(opts D2Options) (string, error)
GenerateD2 generates a D2 diagram showing component relationships. D2 is a modern diagram scripting language: https://d2lang.com/
func (*DesignSystem) GenerateD2ComponentDiagram ¶ added in v0.3.0
func (ds *DesignSystem) GenerateD2ComponentDiagram(componentID string, opts D2Options) (string, error)
GenerateD2ComponentDiagram generates a focused D2 diagram for a single component.
func (*DesignSystem) GenerateDocs ¶ added in v0.3.0
func (ds *DesignSystem) GenerateDocs(opts DocsOptions) (*DocsOutput, error)
GenerateDocs generates complete MkDocs-compatible documentation.
func (*DesignSystem) GenerateLLMPrompt ¶
func (ds *DesignSystem) GenerateLLMPrompt(opts LLMPromptOptions) (string, error)
GenerateLLMPrompt generates a Claude-friendly context prompt from the design system.
func (*DesignSystem) GenerateMermaid ¶ added in v0.3.0
func (ds *DesignSystem) GenerateMermaid(opts MermaidOptions) (string, error)
GenerateMermaid generates a Mermaid diagram showing component relationships.
func (*DesignSystem) GenerateMermaidComponentDiagram ¶ added in v0.3.0
func (ds *DesignSystem) GenerateMermaidComponentDiagram(componentID string, opts MermaidOptions) (string, error)
GenerateMermaidComponentDiagram generates a focused diagram for a single component.
func (*DesignSystem) GenerateMermaidTokenDiagram ¶ added in v0.3.0
func (ds *DesignSystem) GenerateMermaidTokenDiagram(opts MermaidOptions) (string, error)
GenerateMermaidTokenDiagram generates a diagram showing token usage by components.
func (*DesignSystem) GenerateReactTypes ¶
func (ds *DesignSystem) GenerateReactTypes(opts ReactGeneratorOptions) (string, error)
GenerateReactTypes generates TypeScript interfaces for all components.
func (*DesignSystem) GenerateW3CTokens ¶ added in v0.3.0
func (ds *DesignSystem) GenerateW3CTokens(opts W3CTokensOptions) (string, error)
GenerateW3CTokens generates W3C Design Tokens Community Group format. See: https://design-tokens.github.io/community-group/format/
func (*DesignSystem) Validate ¶
func (ds *DesignSystem) Validate() error
Validate performs basic validation on the design system.
type DocsOptions ¶ added in v0.3.0
type DocsOptions struct {
// OutputDir is the base directory for generated docs
OutputDir string
// ProjectName for titles and headers
ProjectName string
// ProjectURL for external links (e.g., GitHub repo)
ProjectURL string
// IncludeMermaid embeds Mermaid diagrams inline
IncludeMermaid bool
// IncludeD2 generates D2 diagram files
IncludeD2 bool
// IncludeTokens generates W3C tokens file
IncludeTokens bool
// MkDocsCompatible adds MkDocs-specific formatting (admonitions, etc.)
MkDocsCompatible bool
}
DocsOptions configures documentation output.
func DefaultDocsOptions ¶ added in v0.3.0
func DefaultDocsOptions() DocsOptions
DefaultDocsOptions returns sensible defaults.
type DocsOutput ¶ added in v0.3.0
DocsOutput contains all generated documentation files.
type DurationToken ¶
type DurationToken struct {
// ID is a unique identifier (e.g., "fast", "normal", "slow").
ID string `json:"id"`
// Value is the duration in milliseconds or CSS format.
Value string `json:"value"`
// Usage describes when to use this duration.
Usage string `json:"usage,omitempty"`
}
DurationToken represents an animation duration.
type EasingToken ¶
type EasingToken struct {
// ID is a unique identifier (e.g., "easeIn", "easeOut", "spring").
ID string `json:"id"`
// Value is the CSS timing function or cubic-bezier value.
Value string `json:"value"`
// Usage describes when to use this easing.
Usage string `json:"usage,omitempty"`
}
EasingToken represents an easing function.
type ElevationToken ¶
type ElevationToken struct {
// ID is a unique identifier (e.g., "sm", "md", "lg", "xl").
ID string `json:"id"`
// Value is the CSS box-shadow value.
Value string `json:"value"`
// Usage describes when to use this elevation level.
Usage string `json:"usage,omitempty"`
}
ElevationToken represents a shadow/depth level.
type EventDetailField ¶ added in v0.3.0
type EventDetailField struct {
// Name is the field name.
Name string `json:"name"`
// Type is the data type.
Type string `json:"type"`
// Description explains the field's purpose.
Description string `json:"description,omitempty"`
}
EventDetailField describes a field in an event's detail payload.
type FontFamily ¶
type FontFamily struct {
// ID is a unique identifier (e.g., "sans", "serif", "mono").
ID string `json:"id"`
// Name is a display name for the font family.
Name string `json:"name"`
// Stack is the CSS font-family fallback stack (e.g., "'Inter', system-ui, sans-serif").
// This is the preferred field for font family values.
Stack string `json:"stack,omitempty"`
// Value is an alias for Stack (deprecated, use Stack instead).
Value string `json:"value,omitempty"`
// Weights lists available font weights (e.g., [400, 500, 600, 700]).
Weights []int `json:"weights,omitempty"`
// Source is the URL to load the font (e.g., Google Fonts URL).
Source string `json:"source,omitempty"`
// Usage describes when to use this font family.
Usage string `json:"usage,omitempty"`
}
FontFamily represents a font stack.
type FontSize ¶
type FontSize struct {
// ID is a unique identifier (e.g., "xs", "sm", "base", "lg").
ID string `json:"id"`
// Value is the size value with unit (e.g., "1rem", "16px").
Value string `json:"value"`
// PixelValue is the equivalent pixel value for reference.
PixelValue int `json:"pixelValue,omitempty"`
}
FontSize represents a font size token.
type FontWeight ¶
type FontWeight struct {
// ID is a unique identifier (e.g., "normal", "medium", "bold").
ID string `json:"id"`
// Value is the numeric weight (100-900).
Value int `json:"value" jsonschema:"minimum=100,maximum=900"`
}
FontWeight represents a font weight token.
type Foundations ¶
type Foundations struct {
// Colors defines the color palette and semantic color tokens.
Colors []ColorToken `json:"colors,omitempty"`
// Typography defines font families, sizes, weights, and type scale.
Typography *Typography `json:"typography,omitempty"`
// Spacing defines the spacing scale for margins, padding, and gaps.
Spacing *SpacingScale `json:"spacing,omitempty"`
// Elevation defines shadow/depth tokens for layering.
Elevation []ElevationToken `json:"elevation,omitempty"`
// Motion defines animation and transition tokens.
Motion *MotionSystem `json:"motion,omitempty"`
// Grid defines the layout grid system.
Grid *GridSystem `json:"grid,omitempty"`
// Breakpoints defines responsive breakpoints.
Breakpoints []Breakpoint `json:"breakpoints,omitempty"`
// BorderRadius defines corner radius tokens.
BorderRadius []BorderRadiusToken `json:"borderRadius,omitempty"`
// BorderWidth defines border width tokens.
BorderWidth []BorderWidthToken `json:"borderWidth,omitempty"`
// Opacity defines opacity scale tokens.
Opacity []OpacityToken `json:"opacity,omitempty"`
// ZIndex defines z-index layer tokens.
ZIndex []ZIndexToken `json:"zIndex,omitempty"`
}
Foundations contains all design tokens for the system.
type GeneratedBinding ¶ added in v0.3.0
type GeneratedBinding struct {
// Component is the component ID.
Component string
// CSS is the generated CSS/SCSS content.
CSS string
// Warnings are non-fatal issues encountered during generation.
Warnings []string
}
GeneratedBinding represents the output for a single component's theme bindings.
func GenerateBindings ¶ added in v0.3.0
func GenerateBindings(ds *DesignSystem, opts BindingOptions) ([]GeneratedBinding, error)
GenerateBindings generates theme bindings for all configured components.
type Governance ¶
type Governance struct {
// Versioning describes the versioning strategy.
Versioning *VersioningPolicy `json:"versioning,omitempty"`
// Contribution describes how to contribute to the design system.
Contribution *ContributionPolicy `json:"contribution,omitempty"`
// Deprecation describes how items are deprecated and removed.
Deprecation *DeprecationPolicy `json:"deprecation,omitempty"`
// DecisionProcess describes how design decisions are made.
DecisionProcess *DecisionProcess `json:"decisionProcess,omitempty"`
// Ownership describes who owns different parts of the system.
Ownership []OwnershipRecord `json:"ownership,omitempty"`
// SupportPolicy describes support commitments.
SupportPolicy *SupportPolicy `json:"supportPolicy,omitempty"`
}
Governance defines versioning, contribution, and deprecation policies.
type GridSystem ¶
type GridSystem struct {
// Columns is the number of columns (e.g., 12).
Columns int `json:"columns"`
// GutterWidth is the space between columns.
GutterWidth string `json:"gutterWidth"`
// MarginWidth is the outer margin.
MarginWidth string `json:"marginWidth"`
// MaxWidth is the maximum container width.
MaxWidth string `json:"maxWidth,omitempty"`
}
GridSystem defines the layout grid.
type KeyboardInteraction ¶
type KeyboardInteraction struct {
// Key is the key or key combination.
Key string `json:"key"`
// Action describes what happens when pressed.
Action string `json:"action"`
}
KeyboardInteraction describes a keyboard shortcut or interaction.
type KeyboardRequirements ¶
type KeyboardRequirements struct {
// FocusVisible requires visible focus indicators.
FocusVisible bool `json:"focusVisible"`
// FocusOrder requires logical focus order.
FocusOrder bool `json:"focusOrder"`
// NoKeyboardTrap prevents keyboard traps.
NoKeyboardTrap bool `json:"noKeyboardTrap"`
// SkipLinks requires skip navigation links.
SkipLinks bool `json:"skipLinks,omitempty"`
// FocusIndicatorMinSize minimum size for focus indicators (in CSS pixels).
FocusIndicatorMinSize int `json:"focusIndicatorMinSize,omitempty"`
// ShortcutConflicts lists keyboard shortcuts to avoid.
ShortcutConflicts []string `json:"shortcutConflicts,omitempty"`
}
KeyboardRequirements defines keyboard accessibility standards.
type LLMContext ¶
type LLMContext struct {
// Intent describes the primary purpose of this element.
// Example: "Primary action button for form submissions and important CTAs"
Intent string `json:"intent,omitempty"`
// AllowedContexts lists situations where this element should be used.
// Example: ["form-submit", "modal-confirm", "primary-cta"]
AllowedContexts []string `json:"allowedContexts,omitempty"`
// ForbiddenContexts lists situations where this element should NOT be used.
// Example: ["destructive-action", "navigation", "inline-text"]
ForbiddenContexts []string `json:"forbiddenContexts,omitempty"`
// Dependencies lists other elements this one requires.
// Example: ["form", "icon-library"]
Dependencies []string `json:"dependencies,omitempty"`
// ExampleUsage provides code snippets or descriptions of correct usage.
// Example: ["<Button variant='primary'>Submit</Button>"]
ExampleUsage []string `json:"exampleUsage,omitempty"`
// AntiPatterns describes common mistakes to avoid.
// Example: ["Don't use for destructive actions", "Avoid multiple primary buttons"]
AntiPatterns []string `json:"antiPatterns,omitempty"`
// SemanticMeaning describes the user-facing meaning of this element.
// Example: "Signals the main action users should take"
SemanticMeaning string `json:"semanticMeaning,omitempty"`
// RelatedElements lists related elements for context.
// Example: ["button-secondary", "button-outline", "link"]
RelatedElements []string `json:"relatedElements,omitempty"`
// PriorityScore indicates relative importance (1-100).
// Higher scores mean this element should be preferred when multiple options exist.
PriorityScore int `json:"priorityScore,omitempty" jsonschema:"minimum=1,maximum=100"`
// Tags are freeform labels for categorization and search.
Tags []string `json:"tags,omitempty"`
}
LLMContext provides structured metadata for LLM reasoning and code generation. These fields help LLMs understand when and how to use design system elements.
type LLMPromptOptions ¶
type LLMPromptOptions struct {
// Format: "markdown" (default), "xml", "json"
Format string
// IncludeFoundations includes color/spacing/typography guidance
IncludeFoundations bool
// IncludeComponents includes component usage guidelines
IncludeComponents bool
// IncludePatterns includes pattern recommendations
IncludePatterns bool
// IncludeAccessibility includes a11y requirements
IncludeAccessibility bool
// IncludeAntiPatterns emphasizes what NOT to do
IncludeAntiPatterns bool
// MaxExamples limits code examples per component (0 = all)
MaxExamples int
}
LLMPromptOptions configures the LLM context prompt generation.
func DefaultLLMPromptOptions ¶
func DefaultLLMPromptOptions() LLMPromptOptions
DefaultLLMPromptOptions returns comprehensive defaults.
type LetterSpacing ¶
type LetterSpacing struct {
// ID is a unique identifier.
ID string `json:"id"`
// Value is the letter spacing value (e.g., "-0.02em", "0.05em").
Value string `json:"value"`
}
LetterSpacing represents a letter spacing token.
type LineHeight ¶
type LineHeight struct {
// ID is a unique identifier (e.g., "tight", "normal", "relaxed").
ID string `json:"id"`
// Value is the line height value (unitless or with unit).
Value string `json:"value"`
}
LineHeight represents a line height token.
type Maintainer ¶
type Maintainer struct {
// Name of the maintainer or team.
Name string `json:"name"`
// Email contact for the maintainer.
Email string `json:"email,omitempty" jsonschema:"format=email"`
// URL to the maintainer's profile or team page.
URL string `json:"url,omitempty" jsonschema:"format=uri"`
}
Maintainer represents a person or team responsible for the design system.
type MermaidOptions ¶ added in v0.3.0
type MermaidOptions struct {
// DiagramType: "graph", "flowchart", "classDiagram"
DiagramType string
// Direction: "TD" (top-down), "LR" (left-right), "BT", "RL"
Direction string
// ShowTokens includes token relationships
ShowTokens bool
// ShowEvents includes event flow arrows
ShowEvents bool
// ShowSlots includes slot composition
ShowSlots bool
// GroupByCategory groups components by their category
GroupByCategory bool
// Theme: "default", "dark", "forest", "neutral"
Theme string
}
MermaidOptions configures Mermaid diagram output.
func DefaultMermaidOptions ¶ added in v0.3.0
func DefaultMermaidOptions() MermaidOptions
DefaultMermaidOptions returns sensible defaults.
type Meta ¶
type Meta struct {
// Name is the design system name (e.g., "Material Design", "Carbon").
Name string `json:"name"`
// Version follows semantic versioning (e.g., "1.0.0").
Version string `json:"version"`
// Description provides a brief overview of the design system.
Description string `json:"description,omitempty"`
// MaturityLevel indicates system maturity (1=experimental, 5=stable).
MaturityLevel int `json:"maturityLevel,omitempty" jsonschema:"minimum=1,maximum=5"`
// Repository is the URL to the source repository.
Repository string `json:"repository,omitempty" jsonschema:"format=uri"`
// Documentation is the URL to the documentation site.
Documentation string `json:"documentation,omitempty" jsonschema:"format=uri"`
// Maintainers lists the people or teams responsible for the system.
Maintainers []Maintainer `json:"maintainers,omitempty"`
// License specifies the license under which the system is distributed.
License string `json:"license,omitempty"`
}
Meta contains system-level metadata for a design system.
type MicrocopyGuideline ¶
type MicrocopyGuideline struct {
// ID is a unique identifier.
ID string `json:"id"`
// Context describes when this microcopy applies.
Context string `json:"context"`
// Template is the text template (may include placeholders).
Template string `json:"template"`
// Variables lists placeholder variables in the template.
Variables []MicrocopyVariable `json:"variables,omitempty"`
// Examples show the template filled in.
Examples []string `json:"examples,omitempty"`
// Notes provides additional guidance.
Notes string `json:"notes,omitempty"`
}
MicrocopyGuideline provides templates for common UI text patterns.
type MicrocopyVariable ¶
type MicrocopyVariable struct {
// Name is the variable name.
Name string `json:"name"`
// Description explains what value to use.
Description string `json:"description"`
// Examples show sample values.
Examples []string `json:"examples,omitempty"`
}
MicrocopyVariable describes a placeholder in a microcopy template.
type MotionRequirements ¶
type MotionRequirements struct {
// ReducedMotion requires respecting prefers-reduced-motion.
ReducedMotion bool `json:"reducedMotion"`
// NoAutoPlay prevents auto-playing animations longer than 5 seconds.
NoAutoPlay bool `json:"noAutoPlay,omitempty"`
// PauseControl requires pause/stop controls for animations.
PauseControl bool `json:"pauseControl,omitempty"`
// FlashingThreshold maximum flashes per second (must be <=3).
FlashingThreshold int `json:"flashingThreshold,omitempty" jsonschema:"maximum=3"`
}
MotionRequirements defines motion and animation standards.
type MotionSystem ¶
type MotionSystem struct {
// Durations defines timing duration tokens.
Durations []DurationToken `json:"durations"`
// Easings defines easing function tokens.
Easings []EasingToken `json:"easings"`
}
MotionSystem defines animation and transition tokens.
type OpacityToken ¶
type OpacityToken struct {
// ID is a unique identifier (e.g., "0", "50", "100").
ID string `json:"id"`
// Value is the opacity value (0-1 or percentage).
Value string `json:"value"`
}
OpacityToken represents an opacity level.
type OwnershipRecord ¶
type OwnershipRecord struct {
// Area is the area owned (e.g., "foundations", "components/forms").
Area string `json:"area"`
// Team is the owning team.
Team string `json:"team"`
// ContactEmail is the contact email for the team.
ContactEmail string `json:"contactEmail,omitempty" jsonschema:"format=email"`
// SlackChannel is the team's Slack channel.
SlackChannel string `json:"slackChannel,omitempty"`
}
OwnershipRecord describes ownership of a part of the design system.
type Pattern ¶
type Pattern struct {
// ID is a unique identifier (e.g., "form-validation", "data-table", "modal-flow").
ID string `json:"id"`
// Name is a display name for the pattern.
Name string `json:"name"`
// Description explains the pattern's purpose and when to use it.
Description string `json:"description"`
// Category groups related patterns (e.g., "forms", "navigation", "data-display").
Category string `json:"category,omitempty"`
// Components lists the component IDs that make up this pattern.
Components []PatternComponent `json:"components"`
// Layout describes how components are arranged.
Layout *PatternLayout `json:"layout,omitempty"`
// Behavior describes the interaction flow.
Behavior string `json:"behavior,omitempty"`
// Variations lists different configurations of the pattern.
Variations []PatternVariation `json:"variations,omitempty"`
// Accessibility defines a11y requirements for the pattern.
Accessibility *PatternA11y `json:"accessibility,omitempty"`
// LLM provides optimization fields for AI code generation.
LLM *LLMContext `json:"llm,omitempty"`
// DocumentationURL links to detailed documentation.
DocumentationURL string `json:"documentationUrl,omitempty" jsonschema:"format=uri"`
}
Pattern represents a multi-component UX solution for common scenarios.
type PatternA11y ¶
type PatternA11y struct {
// LandmarkRole is the ARIA landmark for the pattern region.
LandmarkRole string `json:"landmarkRole,omitempty"`
// FocusOrder describes the expected tab order.
FocusOrder []string `json:"focusOrder,omitempty"`
// LiveRegions lists components that should announce changes.
LiveRegions []string `json:"liveRegions,omitempty"`
// Notes provides additional accessibility guidance.
Notes string `json:"notes,omitempty"`
}
PatternA11y defines accessibility requirements for a pattern.
type PatternComponent ¶
type PatternComponent struct {
// ComponentID references a component from the components list.
ComponentID string `json:"componentId"`
// Role describes the component's role in this pattern.
Role string `json:"role,omitempty"`
// Required indicates whether this component is essential.
Required bool `json:"required,omitempty"`
// Quantity specifies how many instances (e.g., "1", "1+", "0-1").
Quantity string `json:"quantity,omitempty"`
// Configuration provides default props for this usage.
Configuration map[string]interface{} `json:"configuration,omitempty"`
}
PatternComponent references a component used in a pattern.
type PatternLayout ¶
type PatternLayout struct {
// Type is the layout strategy (flex, grid, stack, etc.).
Type string `json:"type"`
// Direction is the primary axis (row, column).
Direction string `json:"direction,omitempty"`
// Alignment describes cross-axis alignment.
Alignment string `json:"alignment,omitempty"`
// Spacing references a spacing token for gaps.
Spacing string `json:"spacing,omitempty"`
// Responsive describes breakpoint-specific changes.
Responsive []ResponsiveLayout `json:"responsive,omitempty"`
}
PatternLayout describes the spatial arrangement of components.
type PatternVariation ¶
type PatternVariation struct {
// ID is a unique identifier for the variation.
ID string `json:"id"`
// Name is a display name.
Name string `json:"name"`
// Description explains when to use this variation.
Description string `json:"description,omitempty"`
// ComponentChanges lists component differences from the base pattern.
ComponentChanges []PatternComponent `json:"componentChanges,omitempty"`
// LayoutChanges describes layout differences.
LayoutChanges *PatternLayout `json:"layoutChanges,omitempty"`
}
PatternVariation describes an alternative configuration of a pattern.
type Principle ¶
type Principle struct {
// ID is a unique identifier for the principle.
ID string `json:"id"`
// Name is a short, memorable title for the principle.
Name string `json:"name"`
// Description explains the principle in detail.
Description string `json:"description"`
// Rationale explains why this principle matters.
Rationale string `json:"rationale,omitempty"`
// Examples demonstrate the principle in practice.
Examples []PrincipleExample `json:"examples,omitempty"`
// Order determines display ordering (lower = first).
Order int `json:"order,omitempty"`
}
Principle represents a design philosophy or brand value that guides decisions.
type PrincipleExample ¶
type PrincipleExample struct {
// Title summarizes the example.
Title string `json:"title"`
// Description provides detail about how the principle applies.
Description string `json:"description"`
// ImageURL points to a visual demonstration.
ImageURL string `json:"imageUrl,omitempty" jsonschema:"format=uri"`
// Good indicates whether this is a positive or negative example.
Good bool `json:"good"`
}
PrincipleExample illustrates a principle with a concrete case.
type Prop ¶
type Prop struct {
// Name is the prop name as used in code.
Name string `json:"name"`
// Type is the data type (string, number, boolean, enum, etc.).
Type string `json:"type"`
// Description explains what the prop controls.
Description string `json:"description,omitempty"`
// Required indicates whether the prop must be provided.
Required bool `json:"required,omitempty"`
// Default is the default value if not specified.
Default interface{} `json:"default,omitempty"`
// EnumValues lists allowed values for enum types.
EnumValues []string `json:"enumValues,omitempty"`
// Constraints defines validation constraints for this prop.
Constraints *PropConstraints `json:"constraints,omitempty"`
}
Prop represents a configurable property of a component.
type PropConstraints ¶ added in v0.3.0
type PropConstraints struct {
// Min is the minimum value (for numbers) or length (for strings).
Min *float64 `json:"min,omitempty"`
// Max is the maximum value (for numbers) or length (for strings).
Max *float64 `json:"max,omitempty"`
// Pattern is a regex pattern the value must match.
Pattern string `json:"pattern,omitempty"`
}
PropConstraints defines validation constraints for a property.
type ReactGeneratorOptions ¶
type ReactGeneratorOptions struct {
// IncludeJSDoc adds JSDoc comments from descriptions
IncludeJSDoc bool
// ExportStyle: "named" (export interface), "default" (export default)
ExportStyle string
// IncludeVariantUnions generates union types for variants
IncludeVariantUnions bool
// BasePropsInterface name to extend (e.g., "HTMLAttributes<HTMLButtonElement>")
BasePropsInterface string
}
ReactGeneratorOptions configures TypeScript output.
func DefaultReactOptions ¶
func DefaultReactOptions() ReactGeneratorOptions
DefaultReactOptions returns sensible defaults.
type ResponsiveLayout ¶
type ResponsiveLayout struct {
// Breakpoint references a breakpoint ID.
Breakpoint string `json:"breakpoint"`
// Changes describes what changes at this breakpoint.
Changes map[string]string `json:"changes"`
}
ResponsiveLayout describes layout changes at specific breakpoints.
type ResponsiveTemplate ¶
type ResponsiveTemplate struct {
// Breakpoint references a breakpoint ID.
Breakpoint string `json:"breakpoint"`
// GridChanges describes grid changes at this breakpoint.
GridChanges *TemplateGrid `json:"gridChanges,omitempty"`
// HiddenRegions lists region IDs to hide at this breakpoint.
HiddenRegions []string `json:"hiddenRegions,omitempty"`
// RegionChanges lists region modifications at this breakpoint.
RegionChanges []TemplateRegionChange `json:"regionChanges,omitempty"`
}
ResponsiveTemplate describes template changes at specific breakpoints.
type ScreenReaderRequirements ¶
type ScreenReaderRequirements struct {
// SemanticHTML requires semantic HTML elements.
SemanticHTML bool `json:"semanticHtml"`
// ARIALabels requires ARIA labels for interactive elements.
ARIALabels bool `json:"ariaLabels"`
// LiveRegions requires live regions for dynamic content.
LiveRegions bool `json:"liveRegions,omitempty"`
// HeadingStructure requires proper heading hierarchy.
HeadingStructure bool `json:"headingStructure,omitempty"`
// SupportedReaders lists screen readers to test with.
SupportedReaders []string `json:"supportedReaders,omitempty"`
}
ScreenReaderRequirements defines screen reader support standards.
type Slot ¶
type Slot struct {
// Name is the slot name.
Name string `json:"name"`
// Description explains what content belongs in this slot.
Description string `json:"description,omitempty"`
// Required indicates whether content must be provided.
Required bool `json:"required,omitempty"`
// AllowedComponents lists component IDs that can be inserted.
AllowedComponents []string `json:"allowedComponents,omitempty"`
}
Slot represents a content insertion point for component composition.
type SpacingScale ¶
type SpacingScale struct {
// BaseUnit is the fundamental spacing unit (e.g., "4px", "0.25rem").
BaseUnit string `json:"baseUnit"`
// Scale defines the spacing tokens.
Scale []SpacingToken `json:"scale"`
}
SpacingScale defines the spacing system.
type SpacingToken ¶
type SpacingToken struct {
// ID is a unique identifier (e.g., "0", "1", "2", "4", "8").
ID string `json:"id"`
// Value is the spacing value with unit.
Value string `json:"value"`
// PixelValue is the equivalent pixel value for reference.
PixelValue int `json:"pixelValue,omitempty"`
}
SpacingToken represents a single spacing value.
type State ¶
type State struct {
// ID is a unique identifier (hover, active, focus, disabled, error, loading).
ID string `json:"id"`
// Name is a display name for the state.
Name string `json:"name,omitempty"`
// Description explains when this state applies.
Description string `json:"description,omitempty"`
// TokenOverrides lists tokens that change in this state.
TokenOverrides []TokenOverride `json:"tokenOverrides,omitempty"`
}
State represents an interactive state of a component.
type SupportPolicy ¶
type SupportPolicy struct {
// Description provides an overview of support.
Description string `json:"description,omitempty"`
// SupportedVersions lists which versions are currently supported.
SupportedVersions []SupportedVersion `json:"supportedVersions,omitempty"`
// SupportChannels lists how to get support.
SupportChannels []string `json:"supportChannels,omitempty"`
// ResponseTimeTargets describes expected response times.
ResponseTimeTargets map[string]string `json:"responseTimeTargets,omitempty"`
}
SupportPolicy describes support commitments.
type SupportedVersion ¶
type SupportedVersion struct {
// Version is the version number.
Version string `json:"version"`
// Status is the support status (active, maintenance, end-of-life).
Status string `json:"status"`
// EndOfLifeDate is when support ends.
EndOfLifeDate string `json:"endOfLifeDate,omitempty"`
}
SupportedVersion describes a supported version.
type Template ¶
type Template struct {
// ID is a unique identifier (e.g., "dashboard", "settings", "auth").
ID string `json:"id"`
// Name is a display name for the template.
Name string `json:"name"`
// Description explains the template's purpose and when to use it.
Description string `json:"description"`
// Category groups related templates (e.g., "admin", "marketing", "app").
Category string `json:"category,omitempty"`
// Regions defines the major layout regions.
Regions []TemplateRegion `json:"regions"`
// Grid describes the overall grid configuration.
Grid *TemplateGrid `json:"grid,omitempty"`
// Patterns lists pattern IDs commonly used in this template.
Patterns []string `json:"patterns,omitempty"`
// Responsive describes breakpoint-specific adaptations.
Responsive []ResponsiveTemplate `json:"responsive,omitempty"`
// LLM provides optimization fields for AI code generation.
LLM *LLMContext `json:"llm,omitempty"`
// DocumentationURL links to detailed documentation.
DocumentationURL string `json:"documentationUrl,omitempty" jsonschema:"format=uri"`
// PreviewURL links to a visual preview.
PreviewURL string `json:"previewUrl,omitempty" jsonschema:"format=uri"`
}
Template represents a page-level layout structure.
type TemplateGrid ¶
type TemplateGrid struct {
// Areas is the CSS grid-template-areas value.
Areas string `json:"areas,omitempty"`
// Columns is the CSS grid-template-columns value.
Columns string `json:"columns,omitempty"`
// Rows is the CSS grid-template-rows value.
Rows string `json:"rows,omitempty"`
// Gap references a spacing token for grid gaps.
Gap string `json:"gap,omitempty"`
}
TemplateGrid defines the grid configuration for a template.
type TemplateRegion ¶
type TemplateRegion struct {
// ID is a unique identifier for the region.
ID string `json:"id"`
// Name is a display name (e.g., "Header", "Sidebar", "Main Content").
Name string `json:"name"`
// Role describes the semantic role of this region.
Role string `json:"role,omitempty"`
// Required indicates whether this region must be present.
Required bool `json:"required,omitempty"`
// GridArea specifies the CSS grid area name.
GridArea string `json:"gridArea,omitempty"`
// MinHeight specifies minimum height.
MinHeight string `json:"minHeight,omitempty"`
// MaxHeight specifies maximum height.
MaxHeight string `json:"maxHeight,omitempty"`
// Sticky indicates whether the region should stick on scroll.
Sticky bool `json:"sticky,omitempty"`
// AllowedPatterns lists pattern IDs that can be placed here.
AllowedPatterns []string `json:"allowedPatterns,omitempty"`
// AllowedComponents lists component IDs that can be placed here.
AllowedComponents []string `json:"allowedComponents,omitempty"`
}
TemplateRegion defines a major section of a page template.
type TemplateRegionChange ¶
type TemplateRegionChange struct {
// RegionID references the region being changed.
RegionID string `json:"regionId"`
// Changes maps property names to new values.
Changes map[string]string `json:"changes"`
}
TemplateRegionChange describes a region change at a breakpoint.
type TermDefinition ¶
type TermDefinition struct {
// Term is the word or phrase.
Term string `json:"term"`
// Definition explains the term.
Definition string `json:"definition,omitempty"`
// Usage explains when and how to use (or avoid) the term.
Usage string `json:"usage,omitempty"`
// Alternatives lists alternative terms to use instead (for avoided terms).
Alternatives []string `json:"alternatives,omitempty"`
}
TermDefinition defines a term and its usage.
type Terminology ¶
type Terminology struct {
// PreferredTerms lists terms to use.
PreferredTerms []TermDefinition `json:"preferredTerms,omitempty"`
// AvoidedTerms lists terms to avoid.
AvoidedTerms []TermDefinition `json:"avoidedTerms,omitempty"`
// Glossary provides definitions for domain-specific terms.
Glossary []TermDefinition `json:"glossary,omitempty"`
}
Terminology defines preferred and avoided terms.
type TestingRequirement ¶
type TestingRequirement struct {
// Type is the testing type (automated, manual, assistive-tech).
Type string `json:"type"`
// Tools lists required testing tools.
Tools []string `json:"tools,omitempty"`
// Frequency describes how often testing should occur.
Frequency string `json:"frequency,omitempty"`
// Coverage describes what should be tested.
Coverage string `json:"coverage,omitempty"`
}
TestingRequirement describes an accessibility testing requirement.
type ThemeBindings ¶ added in v0.3.0
type ThemeBindings struct {
// Component is the ID of the component being themed (e.g., "button", "card").
Component string `json:"component"`
// SpecURL is an optional URL to fetch the component's spec (for external components).
// Can be a local file path or HTTP URL.
SpecURL string `json:"specUrl,omitempty" jsonschema:"format=uri"`
// ThemeMode specifies which mode these bindings apply to: "light", "dark", or empty for both.
ThemeMode string `json:"themeMode,omitempty" jsonschema:"enum=light,enum=dark"`
// Strategy defines how to handle unmapped tokens.
// - "explicit": Only use defined mappings, skip unmapped tokens
// - "semantic": Auto-map by semantic field, fall back to defaults
// - "inherit": Use component defaults for all unmapped tokens
Strategy string `json:"strategy,omitempty" jsonschema:"enum=explicit,enum=semantic,enum=inherit"`
// Mappings defines explicit token-to-token mappings.
Mappings []TokenMapping `json:"mappings"`
}
ThemeBindings maps application design tokens to a component's theming contract.
type ThemeToken ¶ added in v0.3.0
type ThemeToken struct {
// ID is a unique identifier for the token within the component (e.g., "background", "text-color").
ID string `json:"id"`
// CSSProperty is the full CSS custom property name (e.g., "--btn-background").
CSSProperty string `json:"cssProperty"`
// Semantic indicates the token's semantic purpose for auto-mapping.
// Common values: "primary", "secondary", "accent", "danger", "warning", "success",
// "neutral", "surface", "text", "text-muted", "border".
Semantic string `json:"semantic,omitempty"`
// Description explains what this token controls.
Description string `json:"description,omitempty"`
// DefaultLight is the default value for light mode.
DefaultLight string `json:"defaultLight,omitempty"`
// DefaultDark is the default value for dark mode.
DefaultDark string `json:"defaultDark,omitempty"`
}
ThemeToken represents a single customizable token in a theming contract.
type ThemingContract ¶ added in v0.3.0
type ThemingContract struct {
// Prefix is the CSS custom property prefix for this component (e.g., "--btn", "--card").
Prefix string `json:"prefix"`
// Description provides context about the component's theming approach.
Description string `json:"description,omitempty"`
// Tokens lists all customizable theme tokens for the component.
Tokens []ThemeToken `json:"tokens"`
}
ThemingContract defines the theming interface for a component. It specifies which CSS custom properties can be customized and their semantic meaning.
type TokenBindingResult ¶ added in v0.3.0
type TokenBindingResult struct {
CSSProperty string
Value string
Transform string
Source string // "explicit", "semantic", "inherit"
}
TokenBindingResult represents a resolved token mapping.
type TokenMapping ¶ added in v0.3.0
type TokenMapping struct {
// From is the application's token (e.g., "brand-primary-500", "colors.primary").
From string `json:"from"`
// To is the component's token ID (e.g., "background", "text-color").
To string `json:"to"`
// Transform is an optional CSS function to apply (e.g., "rgb", "hsl", "lighten(10%)").
Transform string `json:"transform,omitempty"`
}
TokenMapping maps an application design token to a component token.
type TokenOverride ¶
type TokenOverride struct {
// TokenID references the token being overridden.
TokenID string `json:"tokenId"`
// Value is the override value.
Value string `json:"value"`
}
TokenOverride specifies a token value that differs for a variant.
type ToneGuideline ¶
type ToneGuideline struct {
// Context describes the situation (e.g., "error messages", "success states").
Context string `json:"context"`
// Description explains how to adapt tone.
Description string `json:"description"`
// Attributes lists tone characteristics for this context.
Attributes []string `json:"attributes,omitempty"`
// Examples demonstrate appropriate tone.
Examples []string `json:"examples,omitempty"`
}
ToneGuideline provides guidance for specific contexts.
type TouchTargetRequirements ¶
type TouchTargetRequirements struct {
// MinSize is the minimum touch target size (e.g., "44px").
MinSize string `json:"minSize"`
// MinSpacing is the minimum spacing between targets.
MinSpacing string `json:"minSpacing,omitempty"`
}
TouchTargetRequirements defines touch target size standards.
type TypeStyle ¶
type TypeStyle struct {
// ID is a unique identifier (e.g., "h1", "body-lg", "caption").
ID string `json:"id"`
// Name is a display name for the style.
Name string `json:"name"`
// FontFamily references a FontFamily ID.
FontFamily string `json:"fontFamily"`
// FontSize references a FontSize ID.
FontSize string `json:"fontSize"`
// FontWeight references a FontWeight ID.
FontWeight string `json:"fontWeight"`
// LineHeight references a LineHeight ID.
LineHeight string `json:"lineHeight"`
// LetterSpacing references a LetterSpacing ID.
LetterSpacing string `json:"letterSpacing,omitempty"`
// Usage describes when to use this type style (LLM optimization).
Usage string `json:"usage,omitempty"`
}
TypeStyle defines a complete typographic style combining multiple tokens.
type Typography ¶
type Typography struct {
// FontFamilies lists available font stacks.
FontFamilies []FontFamily `json:"fontFamilies"`
// FontSizes defines the font size scale.
FontSizes []FontSize `json:"fontSizes"`
// FontWeights defines available font weights.
FontWeights []FontWeight `json:"fontWeights"`
// LineHeights defines line height scale.
LineHeights []LineHeight `json:"lineHeights"`
// LetterSpacings defines letter spacing scale.
LetterSpacings []LetterSpacing `json:"letterSpacings,omitempty"`
// TypeScale defines complete type styles (heading, body, etc.).
TypeScale []TypeStyle `json:"typeScale,omitempty"`
}
Typography defines the type system.
type ValidationError ¶
ValidationError represents a validation error.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type Variant ¶
type Variant struct {
// ID is a unique identifier for the variant.
ID string `json:"id"`
// Name is a display name (e.g., "Primary", "Secondary", "Outline").
Name string `json:"name"`
// Description explains when to use this variant.
Description string `json:"description,omitempty"`
// IsDefault indicates this is the default variant.
IsDefault bool `json:"isDefault,omitempty"`
// TokenOverrides lists tokens that differ from the base component.
TokenOverrides []TokenOverride `json:"tokenOverrides,omitempty"`
}
Variant represents a visual or behavioral variant of a component.
type VersioningPolicy ¶
type VersioningPolicy struct {
// Strategy is the versioning approach (semver, calver, etc.).
Strategy string `json:"strategy"`
// Description explains the versioning policy.
Description string `json:"description,omitempty"`
// BreakingChangePolicy explains when breaking changes are allowed.
BreakingChangePolicy string `json:"breakingChangePolicy,omitempty"`
// ReleaseSchedule describes the release cadence.
ReleaseSchedule string `json:"releaseSchedule,omitempty"`
// ChangelogLocation is the URL or path to the changelog.
ChangelogLocation string `json:"changelogLocation,omitempty"`
}
VersioningPolicy describes the versioning strategy.
type VoiceAttribute ¶
type VoiceAttribute struct {
// Name is the attribute name (e.g., "Friendly", "Professional").
Name string `json:"name"`
// Description explains the attribute.
Description string `json:"description"`
// DoExamples show correct usage.
DoExamples []string `json:"doExamples,omitempty"`
// DontExamples show incorrect usage.
DontExamples []string `json:"dontExamples,omitempty"`
}
VoiceAttribute describes a characteristic of the brand voice.
type VoiceExample ¶
type VoiceExample struct {
// Context describes when this example applies.
Context string `json:"context"`
// Example is the sample text.
Example string `json:"example"`
}
VoiceExample demonstrates the brand voice.
type VoiceGuidelines ¶
type VoiceGuidelines struct {
// Description provides an overview of the voice.
Description string `json:"description"`
// Attributes lists key voice characteristics.
Attributes []VoiceAttribute `json:"attributes"`
// Examples demonstrate the voice in action.
Examples []VoiceExample `json:"examples,omitempty"`
}
VoiceGuidelines describes the brand's communication personality.
type W3CFontFamily ¶ added in v0.3.0
type W3CFontFamily struct {
Value interface{} `json:"$value"`
Type string `json:"$type,omitempty"`
Description string `json:"$description,omitempty"`
Extensions map[string]interface{} `json:"$extensions,omitempty"`
}
W3CFontFamily represents a W3C font family token group.
type W3CToken ¶ added in v0.3.0
type W3CToken struct {
Value interface{} `json:"$value"`
Type string `json:"$type,omitempty"`
Description string `json:"$description,omitempty"`
Extensions map[string]interface{} `json:"$extensions,omitempty"`
}
W3CToken represents a single W3C Design Token.
type W3CTokenFile ¶ added in v0.3.0
type W3CTokenFile struct {
Schema string `json:"$schema,omitempty"`
Color map[string]*W3CToken `json:"color,omitempty"`
Space map[string]*W3CToken `json:"space,omitempty"`
Size map[string]*W3CToken `json:"size,omitempty"`
Radius map[string]*W3CToken `json:"radius,omitempty"`
Shadow map[string]*W3CToken `json:"shadow,omitempty"`
Font map[string]interface{} `json:"font,omitempty"`
Motion map[string]interface{} `json:"motion,omitempty"`
ZIndex map[string]*W3CToken `json:"zIndex,omitempty"`
}
W3CTokenFile represents the root of a W3C Design Tokens file.
type W3CTokensOptions ¶ added in v0.3.0
type W3CTokensOptions struct {
// Prefix for token names (e.g., "mde" → "mde.color.primary")
Prefix string
// IncludeDescriptions adds $description to tokens
IncludeDescriptions bool
// IncludeExtensions adds $extensions with DSS metadata
IncludeExtensions bool
}
W3CTokensOptions configures W3C Design Tokens output.
func DefaultW3CTokensOptions ¶ added in v0.3.0
func DefaultW3CTokensOptions() W3CTokensOptions
DefaultW3CTokensOptions returns sensible defaults.
type WithLLMContext ¶
type WithLLMContext interface {
// GetLLMContext returns the LLM context for this element.
GetLLMContext() *LLMContext
}
WithLLMContext is an interface for types that have LLM optimization metadata.
type WorkflowStep ¶
type WorkflowStep struct {
// Order is the step number.
Order int `json:"order"`
// Name is the step name.
Name string `json:"name"`
// Description explains what happens in this step.
Description string `json:"description"`
// Assignee describes who is responsible for this step.
Assignee string `json:"assignee,omitempty"`
}
WorkflowStep describes a step in the contribution workflow.
type WritingStyle ¶
type WritingStyle struct {
// Capitalization describes capitalization rules.
Capitalization string `json:"capitalization,omitempty"`
// Punctuation describes punctuation guidelines.
Punctuation string `json:"punctuation,omitempty"`
// Contractions indicates whether contractions are allowed.
Contractions string `json:"contractions,omitempty"`
// Numbers describes how to format numbers.
Numbers string `json:"numbers,omitempty"`
// DateTimeFormat describes date/time formatting.
DateTimeFormat string `json:"dateTimeFormat,omitempty"`
// ActiveVoice indicates preference for active voice.
ActiveVoice bool `json:"activeVoice,omitempty"`
// MaxSentenceLength is the recommended max sentence length.
MaxSentenceLength int `json:"maxSentenceLength,omitempty"`
}
WritingStyle provides general writing guidelines.
type ZIndexToken ¶
type ZIndexToken struct {
// ID is a unique identifier (e.g., "base", "dropdown", "modal", "toast").
ID string `json:"id"`
// Value is the z-index number.
Value int `json:"value"`
// Usage describes when to use this layer.
Usage string `json:"usage,omitempty"`
}
ZIndexToken represents a z-index layer.