diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..4d037f9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,151 @@ +# AGENTS.md - Nebula Code Generator + +> **Project**: Nebula - WebAwesome UI Library code generator for Go Templ +> **Module**: `github.com/sonr-io/nebula` +> **Go Version**: 1.25.5 + +## Build Commands + +```bash +go build -o nebula ./cmd/generate # Build binary +go run ./cmd/generate -input config.json -output pkg/wa # Run generator +go run ./cmd/generate -input config.json -output pkg/wa -verbose # Verbose +``` + +## Test Commands + +```bash +go test ./... # Run all tests +go test -v ./internal/generator # Single package +go test -v ./internal/generator -run TestToPascalCase # Single test by name +go test -cover ./... # With coverage +go test -coverprofile=coverage.out ./... && go tool cover -html=coverage.out +``` + +## Lint/Format + +```bash +go fmt ./... # Format +gofmt -s -w . # Format with simplify +go vet ./... # Vet +staticcheck ./... # Static analysis (if installed) +golangci-lint run # Comprehensive lint (if installed) +``` + +## Project Structure + +``` +cmd/generate/main.go # CLI entry point +internal/generator/generator.go # Code generation with text/template +internal/generator/strings.go # String utilities (case conversion) +internal/parser/types.go # JSON schema types +config.json # WebAwesome web-types.json input +``` + +## Code Style + +### Naming + +| Element | Style | Example | +|---------|-------|---------| +| Exported | PascalCase | `Generator`, `ToPascalCase` | +| Unexported | camelCase | `funcMap`, `hasSlots` | +| Struct fields | PascalCase | `Element.Name` | +| JSON tags | kebab-case | `json:"doc-url"` | +| Files | lowercase | `strings.go` | +| Packages | lowercase, single word | `generator` | + +### Imports + +Standard library → blank line → external → blank line → internal: + +```go +import ( + "bytes" + "fmt" + "os" + + "github.com/sonr-io/nebula/internal/parser" +) +``` + +### Error Handling + +```go +// Good: wrap with context +if err := tmpl.Execute(&buf, data); err != nil { + return fmt.Errorf("executing template: %w", err) +} + +// Bad: don't just log +if err != nil { log.Println(err) } +``` + +### Documentation + +All exported functions MUST have doc comments starting with function name: + +```go +// ToPascalCase converts kebab-case or snake_case to PascalCase +func ToPascalCase(s string) string { +``` + +### Struct Tags + +```go +type Attribute struct { + Name string `json:"name"` + Description string `json:"description,omitempty"` +} +``` + +## Generator CLI Flags + +| Flag | Default | Description | +|------|---------|-------------| +| `-input` | `web-types.json` | Input web-types.json path | +| `-output` | `pkg/wa` | Output directory | +| `-package` | `wa` | Generated package name | +| `-verbose` | `false` | Verbose output | + +## Template Conventions + +- Templates defined as string constants in `generator.go` +- Register functions via `template.FuncMap` in `generator.New()` +- Generated files header: `// Code generated by wa-generator. DO NOT EDIT.` + +## Testing + +Use table-driven tests: + +```go +func TestToPascalCase(t *testing.T) { + tests := []struct{ input, want string }{ + {"wa-button", "WaButton"}, + {"", ""}, + } + for _, tt := range tests { + if got := ToPascalCase(tt.input); got != tt.want { + t.Errorf("ToPascalCase(%q) = %q, want %q", tt.input, got, tt.want) + } + } +} +``` + +## Generated Outputs + +| File | Purpose | +|------|---------| +| `{component}.templ` | Individual component files | +| `types.go` | Shared types (Variant, Size, etc.) | +| `builders.go` | Builder pattern helpers | +| `cdn.templ` | CDN loader templates | +| `events.go` | Event constants and handlers | + +## Do NOT + +- Use `panic()` for recoverable errors - return errors +- Modify generated files - edit templates instead +- Use global variables - use struct methods +- Commit generated files without running generator +- Suppress type errors with unsafe patterns diff --git a/devbox.json b/devbox.json new file mode 100644 index 0000000..0cc60ec --- /dev/null +++ b/devbox.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json", + "packages": ["templ@latest"], + "shell": { + "init_hook": [ + "echo 'Welcome to devbox!' > /dev/null" + ], + "scripts": { + "test": [ + "echo \"Error: no test specified\" && exit 1" + ] + } + } +} diff --git a/devbox.lock b/devbox.lock new file mode 100644 index 0000000..e7ca4d1 --- /dev/null +++ b/devbox.lock @@ -0,0 +1,53 @@ +{ + "lockfile_version": "1", + "packages": { + "templ@latest": { + "last_modified": "2025-11-23T21:50:36Z", + "resolved": "github:NixOS/nixpkgs/ee09932cedcef15aaf476f9343d1dea2cb77e261#templ", + "source": "devbox-search", + "version": "0.3.960", + "systems": { + "aarch64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/lk4nhispzqgdahrwjhy2gvsb5s0ba47k-templ-0.3.960", + "default": true + } + ], + "store_path": "/nix/store/lk4nhispzqgdahrwjhy2gvsb5s0ba47k-templ-0.3.960" + }, + "aarch64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/yybzygyj99dhf256dk346z8hxv8vsai5-templ-0.3.960", + "default": true + } + ], + "store_path": "/nix/store/yybzygyj99dhf256dk346z8hxv8vsai5-templ-0.3.960" + }, + "x86_64-darwin": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/lzm0pclc2axwh0v6vyqinp98ikl52csf-templ-0.3.960", + "default": true + } + ], + "store_path": "/nix/store/lzm0pclc2axwh0v6vyqinp98ikl52csf-templ-0.3.960" + }, + "x86_64-linux": { + "outputs": [ + { + "name": "out", + "path": "/nix/store/arv446admjsgwr64gxam4s4m02kmy3bs-templ-0.3.960", + "default": true + } + ], + "store_path": "/nix/store/arv446admjsgwr64gxam4s4m02kmy3bs-templ-0.3.960" + } + } + } + } +} diff --git a/go.mod b/go.mod index 1bfbf91..9750f3f 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/sonr-io/nebula go 1.25.5 + +require github.com/a-h/templ v0.3.977 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..c737496 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/a-h/templ v0.3.977 h1:kiKAPXTZE2Iaf8JbtM21r54A8bCNsncrfnokZZSrSDg= +github.com/a-h/templ v0.3.977/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo= diff --git a/internal/generator/generator.go b/internal/generator/generator.go index ca4e8ca..c056cd1 100644 --- a/internal/generator/generator.go +++ b/internal/generator/generator.go @@ -85,7 +85,7 @@ var componentTemplate = `// Code generated by wa-generator. DO NOT EDIT. package {{ .Package }} import ( - "github.com/a]h/templ" + "github.com/a-h/templ" ) {{- $name := stripWa .Element.Name | toPascal }} diff --git a/pkg/wa/animated-image.templ b/pkg/wa/animated-image.templ new file mode 100644 index 0000000..9af2e33 --- /dev/null +++ b/pkg/wa/animated-image.templ @@ -0,0 +1,173 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-animated-image + +package wa + +import ( + "github.com/a-h/templ" +) + +// A component for displaying animated GIFs and WEBPs that play and pause on interaction. +// +// Web Awesome component: + +// AnimatedImageProps holds all properties for the wa-animated-image component +type AnimatedImageProps struct { + // The path to the image to load. + Src string `attr:"src"` + // A description of the image used by assistive devices. + Alt string `attr:"alt"` + // Plays the animation. When this attribute is remove, the animation will pause. + Play bool `attr:"play"` + + // Events + // Emitted when the image loads successfully. + OnLoad string `attr:"x-on:wa-load"` + // Emitted when the image fails to load. + OnError string `attr:"x-on:wa-error"` + + // Slots contains named slot content + Slots AnimatedImageSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AnimatedImageSlots holds named slot content for the component +type AnimatedImageSlots struct { + // Optional play icon to use instead of the default. Works best with . + PlayIcon templ.Component + // Optional pause icon to use instead of the default. Works best with . + PauseIcon templ.Component +} + +// AnimatedImageBuilder provides a fluent API for constructing AnimatedImageProps +type AnimatedImageBuilder struct { + props AnimatedImageProps +} + +// NewAnimatedImage creates a new builder for wa-animated-image +func NewAnimatedImage() *AnimatedImageBuilder { + return &AnimatedImageBuilder{} +} + +// Src sets the src attribute +// The path to the image to load. +func (b *AnimatedImageBuilder) Src(v string) *AnimatedImageBuilder { + b.props.Src = v + return b +} + +// Alt sets the alt attribute +// A description of the image used by assistive devices. +func (b *AnimatedImageBuilder) Alt(v string) *AnimatedImageBuilder { + b.props.Alt = v + return b +} + +// Play sets the play attribute +// Plays the animation. When this attribute is remove, the animation will pause. +func (b *AnimatedImageBuilder) Play(v bool) *AnimatedImageBuilder { + b.props.Play = v + return b +} + +// OnLoad sets the handler for wa-load event +// Emitted when the image loads successfully. +func (b *AnimatedImageBuilder) OnLoad(handler string) *AnimatedImageBuilder { + b.props.OnLoad = handler + return b +} + +// OnError sets the handler for wa-error event +// Emitted when the image fails to load. +func (b *AnimatedImageBuilder) OnError(handler string) *AnimatedImageBuilder { + b.props.OnError = handler + return b +} + +// PlayIconSlot sets the play-icon slot content +// Optional play icon to use instead of the default. Works best with . +func (b *AnimatedImageBuilder) PlayIconSlot(c templ.Component) *AnimatedImageBuilder { + b.props.Slots.PlayIcon = c + return b +} + +// PauseIconSlot sets the pause-icon slot content +// Optional pause icon to use instead of the default. Works best with . +func (b *AnimatedImageBuilder) PauseIconSlot(c templ.Component) *AnimatedImageBuilder { + b.props.Slots.PauseIcon = c + return b +} + +// Attr adds a custom HTML attribute +func (b *AnimatedImageBuilder) Attr(name, value string) *AnimatedImageBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AnimatedImageBuilder) Attrs(attrs templ.Attributes) *AnimatedImageBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AnimatedImageBuilder) Props() AnimatedImageProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AnimatedImageBuilder) Build() AnimatedImageProps { + return b.props +} + +// AnimatedImage renders the wa-animated-image component +templ AnimatedImage(props AnimatedImageProps) { + + if props.Slots.PlayIcon != nil { +
+ @props.Slots.PlayIcon +
+ } + if props.Slots.PauseIcon != nil { +
+ @props.Slots.PauseIcon +
+ } + { children... } +
+} + +// AnimatedImageFunc renders with a builder function for inline configuration +templ AnimatedImageFunc(fn func(*AnimatedImageBuilder)) { + {{ b := NewAnimatedImage(); fn(b) }} + @AnimatedImage(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/animated-image_templ.go b/pkg/wa/animated-image_templ.go new file mode 100644 index 0000000..93069c3 --- /dev/null +++ b/pkg/wa/animated-image_templ.go @@ -0,0 +1,348 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-animated-image + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// A component for displaying animated GIFs and WEBPs that play and pause on interaction. +// +// Web Awesome component: + +// AnimatedImageProps holds all properties for the wa-animated-image component +type AnimatedImageProps struct { + // The path to the image to load. + Src string `attr:"src"` + // A description of the image used by assistive devices. + Alt string `attr:"alt"` + // Plays the animation. When this attribute is remove, the animation will pause. + Play bool `attr:"play"` + + // Events + // Emitted when the image loads successfully. + OnLoad string `attr:"x-on:wa-load"` + // Emitted when the image fails to load. + OnError string `attr:"x-on:wa-error"` + + // Slots contains named slot content + Slots AnimatedImageSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AnimatedImageSlots holds named slot content for the component +type AnimatedImageSlots struct { + // Optional play icon to use instead of the default. Works best with . + PlayIcon templ.Component + // Optional pause icon to use instead of the default. Works best with . + PauseIcon templ.Component +} + +// AnimatedImageBuilder provides a fluent API for constructing AnimatedImageProps +type AnimatedImageBuilder struct { + props AnimatedImageProps +} + +// NewAnimatedImage creates a new builder for wa-animated-image +func NewAnimatedImage() *AnimatedImageBuilder { + return &AnimatedImageBuilder{} +} + +// Src sets the src attribute +// The path to the image to load. +func (b *AnimatedImageBuilder) Src(v string) *AnimatedImageBuilder { + b.props.Src = v + return b +} + +// Alt sets the alt attribute +// A description of the image used by assistive devices. +func (b *AnimatedImageBuilder) Alt(v string) *AnimatedImageBuilder { + b.props.Alt = v + return b +} + +// Play sets the play attribute +// Plays the animation. When this attribute is remove, the animation will pause. +func (b *AnimatedImageBuilder) Play(v bool) *AnimatedImageBuilder { + b.props.Play = v + return b +} + +// OnLoad sets the handler for wa-load event +// Emitted when the image loads successfully. +func (b *AnimatedImageBuilder) OnLoad(handler string) *AnimatedImageBuilder { + b.props.OnLoad = handler + return b +} + +// OnError sets the handler for wa-error event +// Emitted when the image fails to load. +func (b *AnimatedImageBuilder) OnError(handler string) *AnimatedImageBuilder { + b.props.OnError = handler + return b +} + +// PlayIconSlot sets the play-icon slot content +// Optional play icon to use instead of the default. Works best with . +func (b *AnimatedImageBuilder) PlayIconSlot(c templ.Component) *AnimatedImageBuilder { + b.props.Slots.PlayIcon = c + return b +} + +// PauseIconSlot sets the pause-icon slot content +// Optional pause icon to use instead of the default. Works best with . +func (b *AnimatedImageBuilder) PauseIconSlot(c templ.Component) *AnimatedImageBuilder { + b.props.Slots.PauseIcon = c + return b +} + +// Attr adds a custom HTML attribute +func (b *AnimatedImageBuilder) Attr(name, value string) *AnimatedImageBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AnimatedImageBuilder) Attrs(attrs templ.Attributes) *AnimatedImageBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AnimatedImageBuilder) Props() AnimatedImageProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AnimatedImageBuilder) Build() AnimatedImageProps { + return b.props +} + +// AnimatedImage renders the wa-animated-image component +func AnimatedImage(props AnimatedImageProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if props.Slots.PlayIcon != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.PlayIcon.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if props.Slots.PauseIcon != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.PauseIcon.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// AnimatedImageFunc renders with a builder function for inline configuration +func AnimatedImageFunc(fn func(*AnimatedImageBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewAnimatedImage() + fn(b) + templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = AnimatedImage(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/animation.templ b/pkg/wa/animation.templ new file mode 100644 index 0000000..6c49020 --- /dev/null +++ b/pkg/wa/animation.templ @@ -0,0 +1,249 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-animation + +package wa + +import ( + "github.com/a-h/templ" +) + +// Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes. Powered by t... +// +// Web Awesome component: + +// AnimationProps holds all properties for the wa-animation component +type AnimationProps struct { + // The name of the built-in animation to use. For custom animations, use the keyframes prop. + Name string `attr:"name"` + // Plays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when + Play bool `attr:"play"` + // The number of milliseconds to delay the start of the animation. + Delay float64 `attr:"delay"` + // Determines the direction of playback as well as the behavior when reaching the end of an iteration. + Direction string `attr:"direction"` + // The number of milliseconds each iteration of the animation takes to complete. + Duration float64 `attr:"duration"` + // The easing function to use for the animation. This can be a Web Awesome easing function or a custom easing function + Easing string `attr:"easing"` + // The number of milliseconds to delay after the active period of an animation sequence. + EndDelay float64 `attr:"end-delay"` + // Sets how the animation applies styles to its target before and after its execution. + Fill string `attr:"fill"` + // The number of iterations to run before the animation completes. Defaults to Infinity, which loops. + Iterations float64 `attr:"iterations"` + // The offset at which to start the animation, usually between 0 (start) and 1 (end). + IterationStart float64 `attr:"iteration-start"` + // Sets the animation's playback rate. The default is 1, which plays the animation at a normal speed. Setting this + PlaybackRate float64 `attr:"playback-rate"` + + // Events + // Emitted when the animation is canceled. + OnCancel string `attr:"x-on:wa-cancel"` + // Emitted when the animation finishes. + OnFinish string `attr:"x-on:wa-finish"` + // Emitted when the animation starts or restarts. + OnStart string `attr:"x-on:wa-start"` + + // Slots contains named slot content + Slots AnimationSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AnimationBuilder provides a fluent API for constructing AnimationProps +type AnimationBuilder struct { + props AnimationProps +} + +// NewAnimation creates a new builder for wa-animation +func NewAnimation() *AnimationBuilder { + return &AnimationBuilder{} +} + +// Name sets the name attribute +// The name of the built-in animation to use. For custom animations, use the keyframes prop. +func (b *AnimationBuilder) Name(v string) *AnimationBuilder { + b.props.Name = v + return b +} + +// Play sets the play attribute +// Plays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when +func (b *AnimationBuilder) Play(v bool) *AnimationBuilder { + b.props.Play = v + return b +} + +// Delay sets the delay attribute +// The number of milliseconds to delay the start of the animation. +func (b *AnimationBuilder) Delay(v float64) *AnimationBuilder { + b.props.Delay = v + return b +} + +// Direction sets the direction attribute +// Determines the direction of playback as well as the behavior when reaching the end of an iteration. +func (b *AnimationBuilder) Direction(v string) *AnimationBuilder { + b.props.Direction = v + return b +} + +// Duration sets the duration attribute +// The number of milliseconds each iteration of the animation takes to complete. +func (b *AnimationBuilder) Duration(v float64) *AnimationBuilder { + b.props.Duration = v + return b +} + +// Easing sets the easing attribute +// The easing function to use for the animation. This can be a Web Awesome easing function or a custom easing function +func (b *AnimationBuilder) Easing(v string) *AnimationBuilder { + b.props.Easing = v + return b +} + +// EndDelay sets the end-delay attribute +// The number of milliseconds to delay after the active period of an animation sequence. +func (b *AnimationBuilder) EndDelay(v float64) *AnimationBuilder { + b.props.EndDelay = v + return b +} + +// Fill sets the fill attribute +// Sets how the animation applies styles to its target before and after its execution. +func (b *AnimationBuilder) Fill(v string) *AnimationBuilder { + b.props.Fill = v + return b +} + +// Iterations sets the iterations attribute +// The number of iterations to run before the animation completes. Defaults to Infinity, which loops. +func (b *AnimationBuilder) Iterations(v float64) *AnimationBuilder { + b.props.Iterations = v + return b +} + +// IterationStart sets the iteration-start attribute +// The offset at which to start the animation, usually between 0 (start) and 1 (end). +func (b *AnimationBuilder) IterationStart(v float64) *AnimationBuilder { + b.props.IterationStart = v + return b +} + +// PlaybackRate sets the playback-rate attribute +// Sets the animation's playback rate. The default is 1, which plays the animation at a normal speed. Setting this +func (b *AnimationBuilder) PlaybackRate(v float64) *AnimationBuilder { + b.props.PlaybackRate = v + return b +} + +// OnCancel sets the handler for wa-cancel event +// Emitted when the animation is canceled. +func (b *AnimationBuilder) OnCancel(handler string) *AnimationBuilder { + b.props.OnCancel = handler + return b +} + +// OnFinish sets the handler for wa-finish event +// Emitted when the animation finishes. +func (b *AnimationBuilder) OnFinish(handler string) *AnimationBuilder { + b.props.OnFinish = handler + return b +} + +// OnStart sets the handler for wa-start event +// Emitted when the animation starts or restarts. +func (b *AnimationBuilder) OnStart(handler string) *AnimationBuilder { + b.props.OnStart = handler + return b +} + +// Attr adds a custom HTML attribute +func (b *AnimationBuilder) Attr(name, value string) *AnimationBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AnimationBuilder) Attrs(attrs templ.Attributes) *AnimationBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AnimationBuilder) Props() AnimationProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AnimationBuilder) Build() AnimationProps { + return b.props +} + +// Animation renders the wa-animation component +templ Animation(props AnimationProps) { + + { children... } + +} + +// AnimationFunc renders with a builder function for inline configuration +templ AnimationFunc(fn func(*AnimationBuilder)) { + {{ b := NewAnimation(); fn(b) }} + @Animation(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/animation_templ.go b/pkg/wa/animation_templ.go new file mode 100644 index 0000000..0f20cf4 --- /dev/null +++ b/pkg/wa/animation_templ.go @@ -0,0 +1,550 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-animation + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Animate elements declaratively with nearly 100 baked-in presets, or roll your own with custom keyframes. Powered by t... +// +// Web Awesome component: + +// AnimationProps holds all properties for the wa-animation component +type AnimationProps struct { + // The name of the built-in animation to use. For custom animations, use the keyframes prop. + Name string `attr:"name"` + // Plays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when + Play bool `attr:"play"` + // The number of milliseconds to delay the start of the animation. + Delay float64 `attr:"delay"` + // Determines the direction of playback as well as the behavior when reaching the end of an iteration. + Direction string `attr:"direction"` + // The number of milliseconds each iteration of the animation takes to complete. + Duration float64 `attr:"duration"` + // The easing function to use for the animation. This can be a Web Awesome easing function or a custom easing function + Easing string `attr:"easing"` + // The number of milliseconds to delay after the active period of an animation sequence. + EndDelay float64 `attr:"end-delay"` + // Sets how the animation applies styles to its target before and after its execution. + Fill string `attr:"fill"` + // The number of iterations to run before the animation completes. Defaults to Infinity, which loops. + Iterations float64 `attr:"iterations"` + // The offset at which to start the animation, usually between 0 (start) and 1 (end). + IterationStart float64 `attr:"iteration-start"` + // Sets the animation's playback rate. The default is 1, which plays the animation at a normal speed. Setting this + PlaybackRate float64 `attr:"playback-rate"` + + // Events + // Emitted when the animation is canceled. + OnCancel string `attr:"x-on:wa-cancel"` + // Emitted when the animation finishes. + OnFinish string `attr:"x-on:wa-finish"` + // Emitted when the animation starts or restarts. + OnStart string `attr:"x-on:wa-start"` + + // Slots contains named slot content + Slots AnimationSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AnimationBuilder provides a fluent API for constructing AnimationProps +type AnimationBuilder struct { + props AnimationProps +} + +// NewAnimation creates a new builder for wa-animation +func NewAnimation() *AnimationBuilder { + return &AnimationBuilder{} +} + +// Name sets the name attribute +// The name of the built-in animation to use. For custom animations, use the keyframes prop. +func (b *AnimationBuilder) Name(v string) *AnimationBuilder { + b.props.Name = v + return b +} + +// Play sets the play attribute +// Plays the animation. When omitted, the animation will be paused. This attribute will be automatically removed when +func (b *AnimationBuilder) Play(v bool) *AnimationBuilder { + b.props.Play = v + return b +} + +// Delay sets the delay attribute +// The number of milliseconds to delay the start of the animation. +func (b *AnimationBuilder) Delay(v float64) *AnimationBuilder { + b.props.Delay = v + return b +} + +// Direction sets the direction attribute +// Determines the direction of playback as well as the behavior when reaching the end of an iteration. +func (b *AnimationBuilder) Direction(v string) *AnimationBuilder { + b.props.Direction = v + return b +} + +// Duration sets the duration attribute +// The number of milliseconds each iteration of the animation takes to complete. +func (b *AnimationBuilder) Duration(v float64) *AnimationBuilder { + b.props.Duration = v + return b +} + +// Easing sets the easing attribute +// The easing function to use for the animation. This can be a Web Awesome easing function or a custom easing function +func (b *AnimationBuilder) Easing(v string) *AnimationBuilder { + b.props.Easing = v + return b +} + +// EndDelay sets the end-delay attribute +// The number of milliseconds to delay after the active period of an animation sequence. +func (b *AnimationBuilder) EndDelay(v float64) *AnimationBuilder { + b.props.EndDelay = v + return b +} + +// Fill sets the fill attribute +// Sets how the animation applies styles to its target before and after its execution. +func (b *AnimationBuilder) Fill(v string) *AnimationBuilder { + b.props.Fill = v + return b +} + +// Iterations sets the iterations attribute +// The number of iterations to run before the animation completes. Defaults to Infinity, which loops. +func (b *AnimationBuilder) Iterations(v float64) *AnimationBuilder { + b.props.Iterations = v + return b +} + +// IterationStart sets the iteration-start attribute +// The offset at which to start the animation, usually between 0 (start) and 1 (end). +func (b *AnimationBuilder) IterationStart(v float64) *AnimationBuilder { + b.props.IterationStart = v + return b +} + +// PlaybackRate sets the playback-rate attribute +// Sets the animation's playback rate. The default is 1, which plays the animation at a normal speed. Setting this +func (b *AnimationBuilder) PlaybackRate(v float64) *AnimationBuilder { + b.props.PlaybackRate = v + return b +} + +// OnCancel sets the handler for wa-cancel event +// Emitted when the animation is canceled. +func (b *AnimationBuilder) OnCancel(handler string) *AnimationBuilder { + b.props.OnCancel = handler + return b +} + +// OnFinish sets the handler for wa-finish event +// Emitted when the animation finishes. +func (b *AnimationBuilder) OnFinish(handler string) *AnimationBuilder { + b.props.OnFinish = handler + return b +} + +// OnStart sets the handler for wa-start event +// Emitted when the animation starts or restarts. +func (b *AnimationBuilder) OnStart(handler string) *AnimationBuilder { + b.props.OnStart = handler + return b +} + +// Attr adds a custom HTML attribute +func (b *AnimationBuilder) Attr(name, value string) *AnimationBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AnimationBuilder) Attrs(attrs templ.Attributes) *AnimationBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AnimationBuilder) Props() AnimationProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AnimationBuilder) Build() AnimationProps { + return b.props +} + +// Animation renders the wa-animation component +func Animation(props AnimationProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// AnimationFunc renders with a builder function for inline configuration +func AnimationFunc(fn func(*AnimationBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var15 := templ.GetChildren(ctx) + if templ_7745c5c3_Var15 == nil { + templ_7745c5c3_Var15 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewAnimation() + fn(b) + templ_7745c5c3_Var16 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var15.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = Animation(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/avatar.templ b/pkg/wa/avatar.templ new file mode 100644 index 0000000..9d5a394 --- /dev/null +++ b/pkg/wa/avatar.templ @@ -0,0 +1,173 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-avatar + +package wa + +import ( + "github.com/a-h/templ" +) + +// Avatars are used to represent a person or object. +// +// Web Awesome component: + +// AvatarProps holds all properties for the wa-avatar component +type AvatarProps struct { + // The image source to use for the avatar. + Image string `attr:"image"` + // A label to use to describe the avatar to assistive devices. + Label string `attr:"label"` + // Initials to use as a fallback when no image is available (1-2 characters max recommended). + Initials string `attr:"initials"` + // Indicates how the browser should load the image. + // Valid values: "eager", "lazy" + Loading string `attr:"loading"` + // The shape of the avatar. + // Valid values: "circle", "square", "rounded" + Shape string `attr:"shape"` + + // Events + // The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. + OnError string `attr:"x-on:wa-error"` + + // Slots contains named slot content + Slots AvatarSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AvatarSlots holds named slot content for the component +type AvatarSlots struct { + // The default icon to use when no image or initials are present. Works best with . + Icon templ.Component +} + +// AvatarBuilder provides a fluent API for constructing AvatarProps +type AvatarBuilder struct { + props AvatarProps +} + +// NewAvatar creates a new builder for wa-avatar +func NewAvatar() *AvatarBuilder { + return &AvatarBuilder{} +} + +// Image sets the image attribute +// The image source to use for the avatar. +func (b *AvatarBuilder) Image(v string) *AvatarBuilder { + b.props.Image = v + return b +} + +// Label sets the label attribute +// A label to use to describe the avatar to assistive devices. +func (b *AvatarBuilder) Label(v string) *AvatarBuilder { + b.props.Label = v + return b +} + +// Initials sets the initials attribute +// Initials to use as a fallback when no image is available (1-2 characters max recommended). +func (b *AvatarBuilder) Initials(v string) *AvatarBuilder { + b.props.Initials = v + return b +} + +// Loading sets the loading attribute +// Indicates how the browser should load the image. +func (b *AvatarBuilder) Loading(v string) *AvatarBuilder { + b.props.Loading = v + return b +} + +// Shape sets the shape attribute +// The shape of the avatar. +func (b *AvatarBuilder) Shape(v string) *AvatarBuilder { + b.props.Shape = v + return b +} + +// OnError sets the handler for wa-error event +// The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. +func (b *AvatarBuilder) OnError(handler string) *AvatarBuilder { + b.props.OnError = handler + return b +} + +// IconSlot sets the icon slot content +// The default icon to use when no image or initials are present. Works best with . +func (b *AvatarBuilder) IconSlot(c templ.Component) *AvatarBuilder { + b.props.Slots.Icon = c + return b +} + +// Attr adds a custom HTML attribute +func (b *AvatarBuilder) Attr(name, value string) *AvatarBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AvatarBuilder) Attrs(attrs templ.Attributes) *AvatarBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AvatarBuilder) Props() AvatarProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AvatarBuilder) Build() AvatarProps { + return b.props +} + +// Avatar renders the wa-avatar component +templ Avatar(props AvatarProps) { + + if props.Slots.Icon != nil { +
+ @props.Slots.Icon +
+ } + { children... } +
+} + +// AvatarFunc renders with a builder function for inline configuration +templ AvatarFunc(fn func(*AvatarBuilder)) { + {{ b := NewAvatar(); fn(b) }} + @Avatar(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/avatar_templ.go b/pkg/wa/avatar_templ.go new file mode 100644 index 0000000..394969a --- /dev/null +++ b/pkg/wa/avatar_templ.go @@ -0,0 +1,368 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-avatar + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Avatars are used to represent a person or object. +// +// Web Awesome component: + +// AvatarProps holds all properties for the wa-avatar component +type AvatarProps struct { + // The image source to use for the avatar. + Image string `attr:"image"` + // A label to use to describe the avatar to assistive devices. + Label string `attr:"label"` + // Initials to use as a fallback when no image is available (1-2 characters max recommended). + Initials string `attr:"initials"` + // Indicates how the browser should load the image. + // Valid values: "eager", "lazy" + Loading string `attr:"loading"` + // The shape of the avatar. + // Valid values: "circle", "square", "rounded" + Shape string `attr:"shape"` + + // Events + // The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. + OnError string `attr:"x-on:wa-error"` + + // Slots contains named slot content + Slots AvatarSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// AvatarSlots holds named slot content for the component +type AvatarSlots struct { + // The default icon to use when no image or initials are present. Works best with . + Icon templ.Component +} + +// AvatarBuilder provides a fluent API for constructing AvatarProps +type AvatarBuilder struct { + props AvatarProps +} + +// NewAvatar creates a new builder for wa-avatar +func NewAvatar() *AvatarBuilder { + return &AvatarBuilder{} +} + +// Image sets the image attribute +// The image source to use for the avatar. +func (b *AvatarBuilder) Image(v string) *AvatarBuilder { + b.props.Image = v + return b +} + +// Label sets the label attribute +// A label to use to describe the avatar to assistive devices. +func (b *AvatarBuilder) Label(v string) *AvatarBuilder { + b.props.Label = v + return b +} + +// Initials sets the initials attribute +// Initials to use as a fallback when no image is available (1-2 characters max recommended). +func (b *AvatarBuilder) Initials(v string) *AvatarBuilder { + b.props.Initials = v + return b +} + +// Loading sets the loading attribute +// Indicates how the browser should load the image. +func (b *AvatarBuilder) Loading(v string) *AvatarBuilder { + b.props.Loading = v + return b +} + +// Shape sets the shape attribute +// The shape of the avatar. +func (b *AvatarBuilder) Shape(v string) *AvatarBuilder { + b.props.Shape = v + return b +} + +// OnError sets the handler for wa-error event +// The image could not be loaded. This may because of an invalid URL, a temporary network condition, or some unknown cause. +func (b *AvatarBuilder) OnError(handler string) *AvatarBuilder { + b.props.OnError = handler + return b +} + +// IconSlot sets the icon slot content +// The default icon to use when no image or initials are present. Works best with . +func (b *AvatarBuilder) IconSlot(c templ.Component) *AvatarBuilder { + b.props.Slots.Icon = c + return b +} + +// Attr adds a custom HTML attribute +func (b *AvatarBuilder) Attr(name, value string) *AvatarBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *AvatarBuilder) Attrs(attrs templ.Attributes) *AvatarBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *AvatarBuilder) Props() AvatarProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *AvatarBuilder) Build() AvatarProps { + return b.props +} + +// Avatar renders the wa-avatar component +func Avatar(props AvatarProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if props.Slots.Icon != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.Icon.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// AvatarFunc renders with a builder function for inline configuration +func AvatarFunc(fn func(*AvatarBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var8 := templ.GetChildren(ctx) + if templ_7745c5c3_Var8 == nil { + templ_7745c5c3_Var8 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewAvatar() + fn(b) + templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var8.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = Avatar(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/badge.templ b/pkg/wa/badge.templ new file mode 100644 index 0000000..7de3930 --- /dev/null +++ b/pkg/wa/badge.templ @@ -0,0 +1,132 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-badge + +package wa + +import ( + "github.com/a-h/templ" +) + +// Badges are used to draw attention and display statuses or counts. +// +// Web Awesome component: + +// BadgeProps holds all properties for the wa-badge component +type BadgeProps struct { + // The badge's theme variant. Defaults to brand if not within another element with a variant. + // Valid values: "brand", "neutral", "success", "warning", "danger" + Variant string `attr:"variant"` + // The badge's visual appearance. + // Valid values: "accent", "filled", "outlined", "filled-outlined" + Appearance string `attr:"appearance"` + // Draws a pill-style badge with rounded edges. + Pill bool `attr:"pill"` + // Adds an animation to draw attention to the badge. + // Valid values: "none", "pulse", "bounce" + Attention string `attr:"attention"` + + // Events + + // Slots contains named slot content + Slots BadgeSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BadgeBuilder provides a fluent API for constructing BadgeProps +type BadgeBuilder struct { + props BadgeProps +} + +// NewBadge creates a new builder for wa-badge +func NewBadge() *BadgeBuilder { + return &BadgeBuilder{} +} + +// Variant sets the variant attribute +// The badge's theme variant. Defaults to brand if not within another element with a variant. +func (b *BadgeBuilder) Variant(v string) *BadgeBuilder { + b.props.Variant = v + return b +} + +// Appearance sets the appearance attribute +// The badge's visual appearance. +func (b *BadgeBuilder) Appearance(v string) *BadgeBuilder { + b.props.Appearance = v + return b +} + +// Pill sets the pill attribute +// Draws a pill-style badge with rounded edges. +func (b *BadgeBuilder) Pill(v bool) *BadgeBuilder { + b.props.Pill = v + return b +} + +// Attention sets the attention attribute +// Adds an animation to draw attention to the badge. +func (b *BadgeBuilder) Attention(v string) *BadgeBuilder { + b.props.Attention = v + return b +} + +// Attr adds a custom HTML attribute +func (b *BadgeBuilder) Attr(name, value string) *BadgeBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BadgeBuilder) Attrs(attrs templ.Attributes) *BadgeBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BadgeBuilder) Props() BadgeProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BadgeBuilder) Build() BadgeProps { + return b.props +} + +// Badge renders the wa-badge component +templ Badge(props BadgeProps) { + + { children... } + +} + +// BadgeFunc renders with a builder function for inline configuration +templ BadgeFunc(fn func(*BadgeBuilder)) { + {{ b := NewBadge(); fn(b) }} + @Badge(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/badge_templ.go b/pkg/wa/badge_templ.go new file mode 100644 index 0000000..99bffdb --- /dev/null +++ b/pkg/wa/badge_templ.go @@ -0,0 +1,273 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-badge + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Badges are used to draw attention and display statuses or counts. +// +// Web Awesome component: + +// BadgeProps holds all properties for the wa-badge component +type BadgeProps struct { + // The badge's theme variant. Defaults to brand if not within another element with a variant. + // Valid values: "brand", "neutral", "success", "warning", "danger" + Variant string `attr:"variant"` + // The badge's visual appearance. + // Valid values: "accent", "filled", "outlined", "filled-outlined" + Appearance string `attr:"appearance"` + // Draws a pill-style badge with rounded edges. + Pill bool `attr:"pill"` + // Adds an animation to draw attention to the badge. + // Valid values: "none", "pulse", "bounce" + Attention string `attr:"attention"` + + // Events + + // Slots contains named slot content + Slots BadgeSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BadgeBuilder provides a fluent API for constructing BadgeProps +type BadgeBuilder struct { + props BadgeProps +} + +// NewBadge creates a new builder for wa-badge +func NewBadge() *BadgeBuilder { + return &BadgeBuilder{} +} + +// Variant sets the variant attribute +// The badge's theme variant. Defaults to brand if not within another element with a variant. +func (b *BadgeBuilder) Variant(v string) *BadgeBuilder { + b.props.Variant = v + return b +} + +// Appearance sets the appearance attribute +// The badge's visual appearance. +func (b *BadgeBuilder) Appearance(v string) *BadgeBuilder { + b.props.Appearance = v + return b +} + +// Pill sets the pill attribute +// Draws a pill-style badge with rounded edges. +func (b *BadgeBuilder) Pill(v bool) *BadgeBuilder { + b.props.Pill = v + return b +} + +// Attention sets the attention attribute +// Adds an animation to draw attention to the badge. +func (b *BadgeBuilder) Attention(v string) *BadgeBuilder { + b.props.Attention = v + return b +} + +// Attr adds a custom HTML attribute +func (b *BadgeBuilder) Attr(name, value string) *BadgeBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BadgeBuilder) Attrs(attrs templ.Attributes) *BadgeBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BadgeBuilder) Props() BadgeProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BadgeBuilder) Build() BadgeProps { + return b.props +} + +// Badge renders the wa-badge component +func Badge(props BadgeProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// BadgeFunc renders with a builder function for inline configuration +func BadgeFunc(fn func(*BadgeBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewBadge() + fn(b) + templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var5.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = Badge(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/breadcrumb-item.templ b/pkg/wa/breadcrumb-item.templ new file mode 100644 index 0000000..7d58a6f --- /dev/null +++ b/pkg/wa/breadcrumb-item.templ @@ -0,0 +1,164 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-breadcrumb-item + +package wa + +import ( + "github.com/a-h/templ" +) + +// Breadcrumb Items are used inside breadcrumbs to represent different links. +// +// Web Awesome component: + +// BreadcrumbItemProps holds all properties for the wa-breadcrumb-item component +type BreadcrumbItemProps struct { + // Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered + Href string `attr:"href"` + // Tells the browser where to open the link. Only used when href is set. + // Valid values: "_blank", "_parent", "_self", "_top" + Target string `attr:"target"` + // The rel attribute to use on the link. Only used when href is set. + Rel string `attr:"rel"` + + // Events + + // Slots contains named slot content + Slots BreadcrumbItemSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BreadcrumbItemSlots holds named slot content for the component +type BreadcrumbItemSlots struct { + // An element, such as , placed before the label. + Start templ.Component + // An element, such as , placed after the label. + End templ.Component + // The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang... + Separator templ.Component +} + +// BreadcrumbItemBuilder provides a fluent API for constructing BreadcrumbItemProps +type BreadcrumbItemBuilder struct { + props BreadcrumbItemProps +} + +// NewBreadcrumbItem creates a new builder for wa-breadcrumb-item +func NewBreadcrumbItem() *BreadcrumbItemBuilder { + return &BreadcrumbItemBuilder{} +} + +// Href sets the href attribute +// Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered +func (b *BreadcrumbItemBuilder) Href(v string) *BreadcrumbItemBuilder { + b.props.Href = v + return b +} + +// Target sets the target attribute +// Tells the browser where to open the link. Only used when href is set. +func (b *BreadcrumbItemBuilder) Target(v string) *BreadcrumbItemBuilder { + b.props.Target = v + return b +} + +// Rel sets the rel attribute +// The rel attribute to use on the link. Only used when href is set. +func (b *BreadcrumbItemBuilder) Rel(v string) *BreadcrumbItemBuilder { + b.props.Rel = v + return b +} + +// StartSlot sets the start slot content +// An element, such as , placed before the label. +func (b *BreadcrumbItemBuilder) StartSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.Start = c + return b +} + +// EndSlot sets the end slot content +// An element, such as , placed after the label. +func (b *BreadcrumbItemBuilder) EndSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.End = c + return b +} + +// SeparatorSlot sets the separator slot content +// The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang... +func (b *BreadcrumbItemBuilder) SeparatorSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.Separator = c + return b +} + +// Attr adds a custom HTML attribute +func (b *BreadcrumbItemBuilder) Attr(name, value string) *BreadcrumbItemBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BreadcrumbItemBuilder) Attrs(attrs templ.Attributes) *BreadcrumbItemBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BreadcrumbItemBuilder) Props() BreadcrumbItemProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BreadcrumbItemBuilder) Build() BreadcrumbItemProps { + return b.props +} + +// BreadcrumbItem renders the wa-breadcrumb-item component +templ BreadcrumbItem(props BreadcrumbItemProps) { + + if props.Slots.Start != nil { +
+ @props.Slots.Start +
+ } + if props.Slots.End != nil { +
+ @props.Slots.End +
+ } + if props.Slots.Separator != nil { +
+ @props.Slots.Separator +
+ } + { children... } +
+} + +// BreadcrumbItemFunc renders with a builder function for inline configuration +templ BreadcrumbItemFunc(fn func(*BreadcrumbItemBuilder)) { + {{ b := NewBreadcrumbItem(); fn(b) }} + @BreadcrumbItem(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/breadcrumb-item_templ.go b/pkg/wa/breadcrumb-item_templ.go new file mode 100644 index 0000000..c5cd0b7 --- /dev/null +++ b/pkg/wa/breadcrumb-item_templ.go @@ -0,0 +1,329 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-breadcrumb-item + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Breadcrumb Items are used inside breadcrumbs to represent different links. +// +// Web Awesome component: + +// BreadcrumbItemProps holds all properties for the wa-breadcrumb-item component +type BreadcrumbItemProps struct { + // Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered + Href string `attr:"href"` + // Tells the browser where to open the link. Only used when href is set. + // Valid values: "_blank", "_parent", "_self", "_top" + Target string `attr:"target"` + // The rel attribute to use on the link. Only used when href is set. + Rel string `attr:"rel"` + + // Events + + // Slots contains named slot content + Slots BreadcrumbItemSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BreadcrumbItemSlots holds named slot content for the component +type BreadcrumbItemSlots struct { + // An element, such as , placed before the label. + Start templ.Component + // An element, such as , placed after the label. + End templ.Component + // The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang... + Separator templ.Component +} + +// BreadcrumbItemBuilder provides a fluent API for constructing BreadcrumbItemProps +type BreadcrumbItemBuilder struct { + props BreadcrumbItemProps +} + +// NewBreadcrumbItem creates a new builder for wa-breadcrumb-item +func NewBreadcrumbItem() *BreadcrumbItemBuilder { + return &BreadcrumbItemBuilder{} +} + +// Href sets the href attribute +// Optional URL to direct the user to when the breadcrumb item is activated. When set, a link will be rendered +func (b *BreadcrumbItemBuilder) Href(v string) *BreadcrumbItemBuilder { + b.props.Href = v + return b +} + +// Target sets the target attribute +// Tells the browser where to open the link. Only used when href is set. +func (b *BreadcrumbItemBuilder) Target(v string) *BreadcrumbItemBuilder { + b.props.Target = v + return b +} + +// Rel sets the rel attribute +// The rel attribute to use on the link. Only used when href is set. +func (b *BreadcrumbItemBuilder) Rel(v string) *BreadcrumbItemBuilder { + b.props.Rel = v + return b +} + +// StartSlot sets the start slot content +// An element, such as , placed before the label. +func (b *BreadcrumbItemBuilder) StartSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.Start = c + return b +} + +// EndSlot sets the end slot content +// An element, such as , placed after the label. +func (b *BreadcrumbItemBuilder) EndSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.End = c + return b +} + +// SeparatorSlot sets the separator slot content +// The separator to use for the breadcrumb item. This will only change the separator for this item. If you want to chang... +func (b *BreadcrumbItemBuilder) SeparatorSlot(c templ.Component) *BreadcrumbItemBuilder { + b.props.Slots.Separator = c + return b +} + +// Attr adds a custom HTML attribute +func (b *BreadcrumbItemBuilder) Attr(name, value string) *BreadcrumbItemBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BreadcrumbItemBuilder) Attrs(attrs templ.Attributes) *BreadcrumbItemBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BreadcrumbItemBuilder) Props() BreadcrumbItemProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BreadcrumbItemBuilder) Build() BreadcrumbItemProps { + return b.props +} + +// BreadcrumbItem renders the wa-breadcrumb-item component +func BreadcrumbItem(props BreadcrumbItemProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if props.Slots.Start != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.Start.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if props.Slots.End != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.End.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if props.Slots.Separator != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.Separator.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// BreadcrumbItemFunc renders with a builder function for inline configuration +func BreadcrumbItemFunc(fn func(*BreadcrumbItemBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var5 := templ.GetChildren(ctx) + if templ_7745c5c3_Var5 == nil { + templ_7745c5c3_Var5 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewBreadcrumbItem() + fn(b) + templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var5.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = BreadcrumbItem(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/breadcrumb.templ b/pkg/wa/breadcrumb.templ new file mode 100644 index 0000000..b645cc7 --- /dev/null +++ b/pkg/wa/breadcrumb.templ @@ -0,0 +1,111 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-breadcrumb + +package wa + +import ( + "github.com/a-h/templ" +) + +// Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy. +// +// Web Awesome component: + +// BreadcrumbProps holds all properties for the wa-breadcrumb component +type BreadcrumbProps struct { + // The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by + Label string `attr:"label"` + + // Events + + // Slots contains named slot content + Slots BreadcrumbSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BreadcrumbSlots holds named slot content for the component +type BreadcrumbSlots struct { + // The separator to use between breadcrumb items. Works best with . + Separator templ.Component +} + +// BreadcrumbBuilder provides a fluent API for constructing BreadcrumbProps +type BreadcrumbBuilder struct { + props BreadcrumbProps +} + +// NewBreadcrumb creates a new builder for wa-breadcrumb +func NewBreadcrumb() *BreadcrumbBuilder { + return &BreadcrumbBuilder{} +} + +// Label sets the label attribute +// The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by +func (b *BreadcrumbBuilder) Label(v string) *BreadcrumbBuilder { + b.props.Label = v + return b +} + +// SeparatorSlot sets the separator slot content +// The separator to use between breadcrumb items. Works best with . +func (b *BreadcrumbBuilder) SeparatorSlot(c templ.Component) *BreadcrumbBuilder { + b.props.Slots.Separator = c + return b +} + +// Attr adds a custom HTML attribute +func (b *BreadcrumbBuilder) Attr(name, value string) *BreadcrumbBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BreadcrumbBuilder) Attrs(attrs templ.Attributes) *BreadcrumbBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BreadcrumbBuilder) Props() BreadcrumbProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BreadcrumbBuilder) Build() BreadcrumbProps { + return b.props +} + +// Breadcrumb renders the wa-breadcrumb component +templ Breadcrumb(props BreadcrumbProps) { + + if props.Slots.Separator != nil { +
+ @props.Slots.Separator +
+ } + { children... } +
+} + +// BreadcrumbFunc renders with a builder function for inline configuration +templ BreadcrumbFunc(fn func(*BreadcrumbBuilder)) { + {{ b := NewBreadcrumb(); fn(b) }} + @Breadcrumb(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/breadcrumb_templ.go b/pkg/wa/breadcrumb_templ.go new file mode 100644 index 0000000..0849699 --- /dev/null +++ b/pkg/wa/breadcrumb_templ.go @@ -0,0 +1,226 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-breadcrumb + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy. +// +// Web Awesome component: + +// BreadcrumbProps holds all properties for the wa-breadcrumb component +type BreadcrumbProps struct { + // The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by + Label string `attr:"label"` + + // Events + + // Slots contains named slot content + Slots BreadcrumbSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// BreadcrumbSlots holds named slot content for the component +type BreadcrumbSlots struct { + // The separator to use between breadcrumb items. Works best with . + Separator templ.Component +} + +// BreadcrumbBuilder provides a fluent API for constructing BreadcrumbProps +type BreadcrumbBuilder struct { + props BreadcrumbProps +} + +// NewBreadcrumb creates a new builder for wa-breadcrumb +func NewBreadcrumb() *BreadcrumbBuilder { + return &BreadcrumbBuilder{} +} + +// Label sets the label attribute +// The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by +func (b *BreadcrumbBuilder) Label(v string) *BreadcrumbBuilder { + b.props.Label = v + return b +} + +// SeparatorSlot sets the separator slot content +// The separator to use between breadcrumb items. Works best with . +func (b *BreadcrumbBuilder) SeparatorSlot(c templ.Component) *BreadcrumbBuilder { + b.props.Slots.Separator = c + return b +} + +// Attr adds a custom HTML attribute +func (b *BreadcrumbBuilder) Attr(name, value string) *BreadcrumbBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *BreadcrumbBuilder) Attrs(attrs templ.Attributes) *BreadcrumbBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *BreadcrumbBuilder) Props() BreadcrumbProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *BreadcrumbBuilder) Build() BreadcrumbProps { + return b.props +} + +// Breadcrumb renders the wa-breadcrumb component +func Breadcrumb(props BreadcrumbProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if props.Slots.Separator != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = props.Slots.Separator.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// BreadcrumbFunc renders with a builder function for inline configuration +func BreadcrumbFunc(fn func(*BreadcrumbBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewBreadcrumb() + fn(b) + templ_7745c5c3_Var4 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = Breadcrumb(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var4), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/builders.go b/pkg/wa/builders.go new file mode 100644 index 0000000..269a5ce --- /dev/null +++ b/pkg/wa/builders.go @@ -0,0 +1,146 @@ +// Code generated by wa-generator. DO NOT EDIT. + +package wa + +import "github.com/a]h/templ" + +// PropsBuilder is the interface all component builders implement +type PropsBuilder[T any] interface { + Attr(name, value string) PropsBuilder[T] + Attrs(attrs templ.Attributes) PropsBuilder[T] + Build() T +} + +// BaseBuilder provides common builder functionality +type BaseBuilder struct { + attrs templ.Attributes +} + +// SetAttr sets a single attribute +func (b *BaseBuilder) SetAttr(name, value string) { + if b.attrs == nil { + b.attrs = templ.Attributes{} + } + b.attrs[name] = value +} + +// MergeAttrs merges attributes +func (b *BaseBuilder) MergeAttrs(attrs templ.Attributes) { + if b.attrs == nil { + b.attrs = templ.Attributes{} + } + for k, v := range attrs { + b.attrs[k] = v + } +} + +// GetAttrs returns the attributes +func (b *BaseBuilder) GetAttrs() templ.Attributes { + if b.attrs == nil { + return templ.Attributes{} + } + return b.attrs +} + +// Common builder method helpers + +// WithClass is a helper to add CSS classes +func WithClass[B interface{ Attr(string, string) B }](b B, classes ...string) B { + return b.Attr("class", strings.Join(classes, " ")) +} + +// WithID is a helper to set element ID +func WithID[B interface{ Attr(string, string) B }](b B, id string) B { + return b.Attr("id", id) +} + +// WithStyle is a helper to add inline styles +func WithStyle[B interface{ Attr(string, string) B }](b B, style string) B { + return b.Attr("style", style) +} + +// WithData is a helper to add data attributes +func WithData[B interface{ Attr(string, string) B }](b B, key, value string) B { + return b.Attr("data-"+key, value) +} + +// Component registry for dynamic component creation +var componentRegistry = map[string]func() interface{}{ + "wa-animated-image": func() interface{} { return NewAnimatedImage() }, + "wa-animation": func() interface{} { return NewAnimation() }, + "wa-avatar": func() interface{} { return NewAvatar() }, + "wa-badge": func() interface{} { return NewBadge() }, + "wa-breadcrumb-item": func() interface{} { return NewBreadcrumbItem() }, + "wa-breadcrumb": func() interface{} { return NewBreadcrumb() }, + "wa-button-group": func() interface{} { return NewButtonGroup() }, + "wa-button": func() interface{} { return NewButton() }, + "wa-callout": func() interface{} { return NewCallout() }, + "wa-card": func() interface{} { return NewCard() }, + "wa-carousel": func() interface{} { return NewCarousel() }, + "wa-carousel-item": func() interface{} { return NewCarouselItem() }, + "wa-checkbox": func() interface{} { return NewCheckbox() }, + "wa-color-picker": func() interface{} { return NewColorPicker() }, + "wa-combobox": func() interface{} { return NewCombobox() }, + "wa-comparison": func() interface{} { return NewComparison() }, + "wa-copy-button": func() interface{} { return NewCopyButton() }, + "wa-details": func() interface{} { return NewDetails() }, + "wa-dialog": func() interface{} { return NewDialog() }, + "wa-divider": func() interface{} { return NewDivider() }, + "wa-drawer": func() interface{} { return NewDrawer() }, + "wa-dropdown": func() interface{} { return NewDropdown() }, + "wa-dropdown-item": func() interface{} { return NewDropdownItem() }, + "wa-format-bytes": func() interface{} { return NewFormatBytes() }, + "wa-format-date": func() interface{} { return NewFormatDate() }, + "wa-format-number": func() interface{} { return NewFormatNumber() }, + "wa-icon": func() interface{} { return NewIcon() }, + "wa-include": func() interface{} { return NewInclude() }, + "wa-input": func() interface{} { return NewInput() }, + "wa-intersection-observer": func() interface{} { return NewIntersectionObserver() }, + "wa-mutation-observer": func() interface{} { return NewMutationObserver() }, + "wa-option": func() interface{} { return NewOption() }, + "wa-page": func() interface{} { return NewPage() }, + "wa-popover": func() interface{} { return NewPopover() }, + "wa-popup": func() interface{} { return NewPopup() }, + "wa-progress-bar": func() interface{} { return NewProgressBar() }, + "wa-qr-code": func() interface{} { return NewQrCode() }, + "wa-progress-ring": func() interface{} { return NewProgressRing() }, + "wa-radio": func() interface{} { return NewRadio() }, + "wa-radio-group": func() interface{} { return NewRadioGroup() }, + "wa-rating": func() interface{} { return NewRating() }, + "wa-relative-time": func() interface{} { return NewRelativeTime() }, + "wa-resize-observer": func() interface{} { return NewResizeObserver() }, + "wa-scroller": func() interface{} { return NewScroller() }, + "wa-skeleton": func() interface{} { return NewSkeleton() }, + "wa-select": func() interface{} { return NewSelect() }, + "wa-slider": func() interface{} { return NewSlider() }, + "wa-spinner": func() interface{} { return NewSpinner() }, + "wa-split-panel": func() interface{} { return NewSplitPanel() }, + "wa-switch": func() interface{} { return NewSwitch() }, + "wa-tab": func() interface{} { return NewTab() }, + "wa-tab-group": func() interface{} { return NewTabGroup() }, + "wa-tab-panel": func() interface{} { return NewTabPanel() }, + "wa-tag": func() interface{} { return NewTag() }, + "wa-textarea": func() interface{} { return NewTextarea() }, + "wa-tooltip": func() interface{} { return NewTooltip() }, + "wa-tree": func() interface{} { return NewTree() }, + "wa-tree-item": func() interface{} { return NewTreeItem() }, + "wa-zoomable-frame": func() interface{} { return NewZoomableFrame() }, +} + +// GetBuilder returns a builder for the given component name +func GetBuilder(name string) interface{} { + if fn, ok := componentRegistry[name]; ok { + return fn() + } + return nil +} + +// ComponentNames returns all available component names +func ComponentNames() []string { + names := make([]string, 0, len(componentRegistry)) + for name := range componentRegistry { + names = append(names, name) + } + sort.Strings(names) + return names +} diff --git a/pkg/wa/button-group.templ b/pkg/wa/button-group.templ new file mode 100644 index 0000000..5b1d03e --- /dev/null +++ b/pkg/wa/button-group.templ @@ -0,0 +1,106 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-button-group + +package wa + +import ( + "github.com/a-h/templ" +) + +// Button groups can be used to group related buttons into sections. +// +// Web Awesome component: + +// ButtonGroupProps holds all properties for the wa-button-group component +type ButtonGroupProps struct { + // A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive + Label string `attr:"label"` + // The button group's orientation. + // Valid values: "horizontal", "vertical" + Orientation string `attr:"orientation"` + + // Events + + // Slots contains named slot content + Slots ButtonGroupSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// ButtonGroupBuilder provides a fluent API for constructing ButtonGroupProps +type ButtonGroupBuilder struct { + props ButtonGroupProps +} + +// NewButtonGroup creates a new builder for wa-button-group +func NewButtonGroup() *ButtonGroupBuilder { + return &ButtonGroupBuilder{} +} + +// Label sets the label attribute +// A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive +func (b *ButtonGroupBuilder) Label(v string) *ButtonGroupBuilder { + b.props.Label = v + return b +} + +// Orientation sets the orientation attribute +// The button group's orientation. +func (b *ButtonGroupBuilder) Orientation(v string) *ButtonGroupBuilder { + b.props.Orientation = v + return b +} + +// Attr adds a custom HTML attribute +func (b *ButtonGroupBuilder) Attr(name, value string) *ButtonGroupBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *ButtonGroupBuilder) Attrs(attrs templ.Attributes) *ButtonGroupBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *ButtonGroupBuilder) Props() ButtonGroupProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *ButtonGroupBuilder) Build() ButtonGroupProps { + return b.props +} + +// ButtonGroup renders the wa-button-group component +templ ButtonGroup(props ButtonGroupProps) { + + { children... } + +} + +// ButtonGroupFunc renders with a builder function for inline configuration +templ ButtonGroupFunc(fn func(*ButtonGroupBuilder)) { + {{ b := NewButtonGroup(); fn(b) }} + @ButtonGroup(b.Props()) { + { children... } + } +} diff --git a/pkg/wa/button-group_templ.go b/pkg/wa/button-group_templ.go new file mode 100644 index 0000000..8d0adfe --- /dev/null +++ b/pkg/wa/button-group_templ.go @@ -0,0 +1,228 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.977 +// Code generated by wa-generator. DO NOT EDIT. + +// Source: Web Awesome wa-button-group + +package wa + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/a-h/templ" +) + +// Button groups can be used to group related buttons into sections. +// +// Web Awesome component: + +// ButtonGroupProps holds all properties for the wa-button-group component +type ButtonGroupProps struct { + // A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive + Label string `attr:"label"` + // The button group's orientation. + // Valid values: "horizontal", "vertical" + Orientation string `attr:"orientation"` + + // Events + + // Slots contains named slot content + Slots ButtonGroupSlots + + // Attrs contains additional HTML attributes + Attrs templ.Attributes +} + +// ButtonGroupBuilder provides a fluent API for constructing ButtonGroupProps +type ButtonGroupBuilder struct { + props ButtonGroupProps +} + +// NewButtonGroup creates a new builder for wa-button-group +func NewButtonGroup() *ButtonGroupBuilder { + return &ButtonGroupBuilder{} +} + +// Label sets the label attribute +// A label to use for the button group. This won't be displayed on the screen, but it will be announced by assistive +func (b *ButtonGroupBuilder) Label(v string) *ButtonGroupBuilder { + b.props.Label = v + return b +} + +// Orientation sets the orientation attribute +// The button group's orientation. +func (b *ButtonGroupBuilder) Orientation(v string) *ButtonGroupBuilder { + b.props.Orientation = v + return b +} + +// Attr adds a custom HTML attribute +func (b *ButtonGroupBuilder) Attr(name, value string) *ButtonGroupBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + b.props.Attrs[name] = value + return b +} + +// Attrs merges multiple attributes +func (b *ButtonGroupBuilder) Attrs(attrs templ.Attributes) *ButtonGroupBuilder { + if b.props.Attrs == nil { + b.props.Attrs = templ.Attributes{} + } + for k, v := range attrs { + b.props.Attrs[k] = v + } + return b +} + +// Props returns the built properties +func (b *ButtonGroupBuilder) Props() ButtonGroupProps { + return b.props +} + +// Build returns the props (alias for Props for semantic clarity) +func (b *ButtonGroupBuilder) Build() ButtonGroupProps { + return b.props +} + +// ButtonGroup renders the wa-button-group component +func ButtonGroup(props ButtonGroupProps) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +// ButtonGroupFunc renders with a builder function for inline configuration +func ButtonGroupFunc(fn func(*ButtonGroupBuilder)) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + b := NewButtonGroup() + fn(b) + templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templ_7745c5c3_Var4.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = ButtonGroup(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/wa/button.templ b/pkg/wa/button.templ new file mode 100644 index 0000000..b1d72d3 --- /dev/null +++ b/pkg/wa/button.templ @@ -0,0 +1,385 @@ +// Code generated by wa-generator. DO NOT EDIT. +// Source: Web Awesome wa-button + +package wa + +import ( + "github.com/a-h/templ" +) + +// Buttons represent actions that are available to the user. +// +// Web Awesome component: + +// ButtonProps holds all properties for the wa-button component +type ButtonProps struct { + // The button's theme variant. Defaults to neutral if not within another element with a variant. + // Valid values: "neutral", "brand", "success", "warning", "danger" + Variant string `attr:"variant"` + // The button's visual appearance. + // Valid values: "accent", "filled", "outlined", "filled-outlined", "plain" + Appearance string `attr:"appearance"` + // The button's size. + // Valid values: "small", "medium", "large" + Size string `attr:"size"` + // Draws the button with a caret. Used to indicate that the button triggers a dropdown menu or similar behavior. + WithCaret bool `attr:"with-caret"` + // Disables the button. Does not apply to link buttons. + Disabled bool `attr:"disabled"` + // Draws the button in a loading state. + Loading bool `attr:"loading"` + // Draws a pill-style button with rounded edges. + Pill bool `attr:"pill"` + // The type of button. Note that the default value is button instead of submit, which is opposite of how native + // Valid values: "button", "submit", "reset" + Type string `attr:"type"` + // The name of the button, submitted as a name/value pair with form data, but only when this button is the submitter. + Name string `attr:"name"` + // The value of the button, submitted as a pair with the button's name as part of the form data, but only when this + Value string `attr:"value"` + // When set, the underlying button will be rendered as an with this href instead of a