// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.960 // Code generated by wa-generator. DO NOT EDIT. // Source: Web Awesome wa-intersection-observer 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" ) // Tracks immediate child elements and fires events as they move in and out of view. // // Web Awesome component: // IntersectionObserverProps holds all properties for the wa-intersection-observer component type IntersectionObserverProps struct { // Element ID to define the viewport boundaries for tracked targets. Root string `attr:"root"` // Offset space around the root boundary. Accepts values like CSS margin syntax. RootMargin string `attr:"root-margin"` // One or more space-separated values representing visibility percentages that trigger the observer callback. Threshold string `attr:"threshold"` // CSS class applied to elements during intersection. Automatically removed when elements leave IntersectClass string `attr:"intersect-class"` // If enabled, observation ceases after initial intersection. Once bool `attr:"once"` // Deactivates the intersection observer functionality. Disabled bool `attr:"disabled"` // Events // Fired when a tracked element begins or ceases intersecting. OnIntersect string `attr:"x-on:wa-intersect"` // Slots contains named slot content Slots IntersectionObserverSlots // Attrs contains additional HTML attributes Attrs templ.Attributes } // IntersectionObserverBuilder provides a fluent API for constructing IntersectionObserverProps type IntersectionObserverBuilder struct { props IntersectionObserverProps } // NewIntersectionObserver creates a new builder for wa-intersection-observer func NewIntersectionObserver() *IntersectionObserverBuilder { return &IntersectionObserverBuilder{} } // Root sets the root attribute // Element ID to define the viewport boundaries for tracked targets. func (b *IntersectionObserverBuilder) Root(v string) *IntersectionObserverBuilder { b.props.Root = v return b } // RootMargin sets the root-margin attribute // Offset space around the root boundary. Accepts values like CSS margin syntax. func (b *IntersectionObserverBuilder) RootMargin(v string) *IntersectionObserverBuilder { b.props.RootMargin = v return b } // Threshold sets the threshold attribute // One or more space-separated values representing visibility percentages that trigger the observer callback. func (b *IntersectionObserverBuilder) Threshold(v string) *IntersectionObserverBuilder { b.props.Threshold = v return b } // IntersectClass sets the intersect-class attribute // CSS class applied to elements during intersection. Automatically removed when elements leave func (b *IntersectionObserverBuilder) IntersectClass(v string) *IntersectionObserverBuilder { b.props.IntersectClass = v return b } // Once sets the once attribute // If enabled, observation ceases after initial intersection. func (b *IntersectionObserverBuilder) Once(v bool) *IntersectionObserverBuilder { b.props.Once = v return b } // Disabled sets the disabled attribute // Deactivates the intersection observer functionality. func (b *IntersectionObserverBuilder) Disabled(v bool) *IntersectionObserverBuilder { b.props.Disabled = v return b } // OnIntersect sets the handler for wa-intersect event // Fired when a tracked element begins or ceases intersecting. func (b *IntersectionObserverBuilder) OnIntersect(handler string) *IntersectionObserverBuilder { b.props.OnIntersect = handler return b } // Attr adds a custom HTML attribute func (b *IntersectionObserverBuilder) Attr(name, value string) *IntersectionObserverBuilder { if b.props.Attrs == nil { b.props.Attrs = templ.Attributes{} } b.props.Attrs[name] = value return b } // Attrs merges multiple attributes func (b *IntersectionObserverBuilder) Attrs(attrs templ.Attributes) *IntersectionObserverBuilder { 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 *IntersectionObserverBuilder) Props() IntersectionObserverProps { return b.props } // Build returns the props (alias for Props for semantic clarity) func (b *IntersectionObserverBuilder) Build() IntersectionObserverProps { return b.props } // IntersectionObserver renders the wa-intersection-observer component func IntersectionObserver(props IntersectionObserverProps) 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, 15, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } // IntersectionObserverFunc renders with a builder function for inline configuration func IntersectionObserverFunc(fn func(*IntersectionObserverBuilder)) 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_Var7 := templ.GetChildren(ctx) if templ_7745c5c3_Var7 == nil { templ_7745c5c3_Var7 = templ.NopComponent } ctx = templ.ClearChildren(ctx) b := NewIntersectionObserver() fn(b) templ_7745c5c3_Var8 := 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_Var7.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) templ_7745c5c3_Err = IntersectionObserver(b.Props()).Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) } var _ = templruntime.GeneratedTemplate