Files
nebula/pkg/wa/split-panel.templ

226 lines
6.6 KiB
Plaintext
Raw Normal View History

2026-01-01 14:41:31 -05:00
// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-split-panel
package wa
import (
"github.com/a-h/templ"
)
// Split panels display two adjacent panels, allowing the user to reposition them.
//
// Web Awesome component: <wa-split-panel>
// SplitPanelProps holds all properties for the wa-split-panel component
type SplitPanelProps struct {
// The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
Position float64 `attr:"position"`
// The current position of the divider from the primary panel's edge in pixels.
PositionInPixels float64 `attr:"position-in-pixels"`
// Sets the split panel's orientation.
// Valid values: "horizontal", "vertical"
Orientation string `attr:"orientation"`
// Disables resizing. Note that the position may still change as a result of resizing the host element.
Disabled bool `attr:"disabled"`
// If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a
// Valid values: "start", "end"
Primary string `attr:"primary"`
// One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.
Snap string `attr:"snap"`
// How close the divider must be to a snap point until snapping occurs.
SnapThreshold float64 `attr:"snap-threshold"`
// Events
// Emitted when the divider's position changes.
OnReposition string `attr:"x-on:wa-reposition"`
// Slots contains named slot content
Slots SplitPanelSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// SplitPanelSlots holds named slot content for the component
type SplitPanelSlots struct {
// Content to place in the start panel.
Start templ.Component
// Content to place in the end panel.
End templ.Component
// The divider. Useful for slotting in a custom icon that renders as a handle.
Divider templ.Component
}
// SplitPanelBuilder provides a fluent API for constructing SplitPanelProps
type SplitPanelBuilder struct {
props SplitPanelProps
}
// NewSplitPanel creates a new builder for wa-split-panel
func NewSplitPanel() *SplitPanelBuilder {
return &SplitPanelBuilder{}
}
// Position sets the position attribute
// The current position of the divider from the primary panel's edge as a percentage 0-100. Defaults to 50% of the
func (b *SplitPanelBuilder) Position(v float64) *SplitPanelBuilder {
b.props.Position = v
return b
}
// PositionInPixels sets the position-in-pixels attribute
// The current position of the divider from the primary panel's edge in pixels.
func (b *SplitPanelBuilder) PositionInPixels(v float64) *SplitPanelBuilder {
b.props.PositionInPixels = v
return b
}
// Orientation sets the orientation attribute
// Sets the split panel's orientation.
func (b *SplitPanelBuilder) Orientation(v string) *SplitPanelBuilder {
b.props.Orientation = v
return b
}
// Disabled sets the disabled attribute
// Disables resizing. Note that the position may still change as a result of resizing the host element.
func (b *SplitPanelBuilder) Disabled(v bool) *SplitPanelBuilder {
b.props.Disabled = v
return b
}
// Primary sets the primary attribute
// If no primary panel is designated, both panels will resize proportionally when the host element is resized. If a
func (b *SplitPanelBuilder) Primary(v string) *SplitPanelBuilder {
b.props.Primary = v
return b
}
// Snap sets the snap attribute
// One or more space-separated values at which the divider should snap. Values can be in pixels or percentages, e.g.
func (b *SplitPanelBuilder) Snap(v string) *SplitPanelBuilder {
b.props.Snap = v
return b
}
// SnapThreshold sets the snap-threshold attribute
// How close the divider must be to a snap point until snapping occurs.
func (b *SplitPanelBuilder) SnapThreshold(v float64) *SplitPanelBuilder {
b.props.SnapThreshold = v
return b
}
// OnReposition sets the handler for wa-reposition event
// Emitted when the divider's position changes.
func (b *SplitPanelBuilder) OnReposition(handler string) *SplitPanelBuilder {
b.props.OnReposition = handler
return b
}
// StartSlot sets the start slot content
// Content to place in the start panel.
func (b *SplitPanelBuilder) StartSlot(c templ.Component) *SplitPanelBuilder {
b.props.Slots.Start = c
return b
}
// EndSlot sets the end slot content
// Content to place in the end panel.
func (b *SplitPanelBuilder) EndSlot(c templ.Component) *SplitPanelBuilder {
b.props.Slots.End = c
return b
}
// DividerSlot sets the divider slot content
// The divider. Useful for slotting in a custom icon that renders as a handle.
func (b *SplitPanelBuilder) DividerSlot(c templ.Component) *SplitPanelBuilder {
b.props.Slots.Divider = c
return b
}
// Attr adds a custom HTML attribute
func (b *SplitPanelBuilder) Attr(name, value string) *SplitPanelBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *SplitPanelBuilder) Attrs(attrs templ.Attributes) *SplitPanelBuilder {
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 *SplitPanelBuilder) Props() SplitPanelProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *SplitPanelBuilder) Build() SplitPanelProps {
return b.props
}
// SplitPanel renders the wa-split-panel component
templ SplitPanel(props SplitPanelProps) {
<wa-split-panel
if props.Position != 0 {
position={ templ.Sprintf("%v", props.Position) }
}
if props.PositionInPixels != 0 {
position-in-pixels={ templ.Sprintf("%v", props.PositionInPixels) }
}
if props.Orientation != "" {
orientation={ props.Orientation }
}
if props.Disabled {
disabled
}
if props.Primary != "" {
primary={ props.Primary }
}
if props.Snap != "" {
snap={ props.Snap }
}
if props.SnapThreshold != 0 {
snap-threshold={ templ.Sprintf("%v", props.SnapThreshold) }
}
if props.OnReposition != "" {
x-on:wa-reposition={ props.OnReposition }
}
{ props.Attrs... }
>
if props.Slots.Start != nil {
<div slot="start">
@props.Slots.Start
</div>
}
if props.Slots.End != nil {
<div slot="end">
@props.Slots.End
</div>
}
if props.Slots.Divider != nil {
<div slot="divider">
@props.Slots.Divider
</div>
}
{ children... }
</wa-split-panel>
}
// SplitPanelFunc renders with a builder function for inline configuration
templ SplitPanelFunc(fn func(*SplitPanelBuilder)) {
{{ b := NewSplitPanel(); fn(b) }}
@SplitPanel(b.Props()) {
{ children... }
}
}