Files
nebula/pkg/wa/zoomable-frame.templ

259 lines
7.0 KiB
Plaintext

// Code generated by wa-generator. DO NOT EDIT.
// Source: Web Awesome wa-zoomable-frame
package wa
import (
"github.com/a-h/templ"
)
// Zoomable frames render iframe content with zoom and interaction controls.
//
// Web Awesome component: <wa-zoomable-frame>
// ZoomableFrameProps holds all properties for the wa-zoomable-frame component
type ZoomableFrameProps struct {
// The URL of the content to display.
Src string `attr:"src"`
// Inline HTML to display.
Srcdoc string `attr:"srcdoc"`
// Allows fullscreen mode.
Allowfullscreen bool `attr:"allowfullscreen"`
// Controls iframe loading behavior.
// Valid values: "eager", "lazy"
Loading string `attr:"loading"`
// Controls referrer information.
Referrerpolicy string `attr:"referrerpolicy"`
// Security restrictions for the iframe.
Sandbox string `attr:"sandbox"`
// The current zoom of the frame, e.g. 0 = 0% and 1 = 100%.
Zoom float64 `attr:"zoom"`
// The zoom levels to step through when using zoom controls. This does not restrict programmatic changes to the zoom.
ZoomLevels string `attr:"zoom-levels"`
// Removes the zoom controls.
WithoutControls bool `attr:"without-controls"`
// Disables interaction when present.
WithoutInteraction bool `attr:"without-interaction"`
// Events
// Emitted when the internal iframe when it finishes loading.
OnLoad string `attr:"x-on:load"`
// Emitted from the internal iframe when it fails to load.
OnError string `attr:"x-on:error"`
// Slots contains named slot content
Slots ZoomableFrameSlots
// Attrs contains additional HTML attributes
Attrs templ.Attributes
}
// ZoomableFrameSlots holds named slot content for the component
type ZoomableFrameSlots struct {
// The slot that contains the zoom in icon.
ZoomInIcon templ.Component
// The slot that contains the zoom out icon.
ZoomOutIcon templ.Component
}
// ZoomableFrameBuilder provides a fluent API for constructing ZoomableFrameProps
type ZoomableFrameBuilder struct {
props ZoomableFrameProps
}
// NewZoomableFrame creates a new builder for wa-zoomable-frame
func NewZoomableFrame() *ZoomableFrameBuilder {
return &ZoomableFrameBuilder{}
}
// Src sets the src attribute
// The URL of the content to display.
func (b *ZoomableFrameBuilder) Src(v string) *ZoomableFrameBuilder {
b.props.Src = v
return b
}
// Srcdoc sets the srcdoc attribute
// Inline HTML to display.
func (b *ZoomableFrameBuilder) Srcdoc(v string) *ZoomableFrameBuilder {
b.props.Srcdoc = v
return b
}
// Allowfullscreen sets the allowfullscreen attribute
// Allows fullscreen mode.
func (b *ZoomableFrameBuilder) Allowfullscreen(v bool) *ZoomableFrameBuilder {
b.props.Allowfullscreen = v
return b
}
// Loading sets the loading attribute
// Controls iframe loading behavior.
func (b *ZoomableFrameBuilder) Loading(v string) *ZoomableFrameBuilder {
b.props.Loading = v
return b
}
// Referrerpolicy sets the referrerpolicy attribute
// Controls referrer information.
func (b *ZoomableFrameBuilder) Referrerpolicy(v string) *ZoomableFrameBuilder {
b.props.Referrerpolicy = v
return b
}
// Sandbox sets the sandbox attribute
// Security restrictions for the iframe.
func (b *ZoomableFrameBuilder) Sandbox(v string) *ZoomableFrameBuilder {
b.props.Sandbox = v
return b
}
// Zoom sets the zoom attribute
// The current zoom of the frame, e.g. 0 = 0% and 1 = 100%.
func (b *ZoomableFrameBuilder) Zoom(v float64) *ZoomableFrameBuilder {
b.props.Zoom = v
return b
}
// ZoomLevels sets the zoom-levels attribute
// The zoom levels to step through when using zoom controls. This does not restrict programmatic changes to the zoom.
func (b *ZoomableFrameBuilder) ZoomLevels(v string) *ZoomableFrameBuilder {
b.props.ZoomLevels = v
return b
}
// WithoutControls sets the without-controls attribute
// Removes the zoom controls.
func (b *ZoomableFrameBuilder) WithoutControls(v bool) *ZoomableFrameBuilder {
b.props.WithoutControls = v
return b
}
// WithoutInteraction sets the without-interaction attribute
// Disables interaction when present.
func (b *ZoomableFrameBuilder) WithoutInteraction(v bool) *ZoomableFrameBuilder {
b.props.WithoutInteraction = v
return b
}
// OnLoad sets the handler for load event
// Emitted when the internal iframe when it finishes loading.
func (b *ZoomableFrameBuilder) OnLoad(handler string) *ZoomableFrameBuilder {
b.props.OnLoad = handler
return b
}
// OnError sets the handler for error event
// Emitted from the internal iframe when it fails to load.
func (b *ZoomableFrameBuilder) OnError(handler string) *ZoomableFrameBuilder {
b.props.OnError = handler
return b
}
// ZoomInIconSlot sets the zoom-in-icon slot content
// The slot that contains the zoom in icon.
func (b *ZoomableFrameBuilder) ZoomInIconSlot(c templ.Component) *ZoomableFrameBuilder {
b.props.Slots.ZoomInIcon = c
return b
}
// ZoomOutIconSlot sets the zoom-out-icon slot content
// The slot that contains the zoom out icon.
func (b *ZoomableFrameBuilder) ZoomOutIconSlot(c templ.Component) *ZoomableFrameBuilder {
b.props.Slots.ZoomOutIcon = c
return b
}
// Attr adds a custom HTML attribute
func (b *ZoomableFrameBuilder) Attr(name, value string) *ZoomableFrameBuilder {
if b.props.Attrs == nil {
b.props.Attrs = templ.Attributes{}
}
b.props.Attrs[name] = value
return b
}
// Attrs merges multiple attributes
func (b *ZoomableFrameBuilder) Attrs(attrs templ.Attributes) *ZoomableFrameBuilder {
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 *ZoomableFrameBuilder) Props() ZoomableFrameProps {
return b.props
}
// Build returns the props (alias for Props for semantic clarity)
func (b *ZoomableFrameBuilder) Build() ZoomableFrameProps {
return b.props
}
// ZoomableFrame renders the wa-zoomable-frame component
templ ZoomableFrame(props ZoomableFrameProps) {
<wa-zoomable-frame
if props.Src != "" {
src={ props.Src }
}
if props.Srcdoc != "" {
srcdoc={ props.Srcdoc }
}
if props.Allowfullscreen {
allowfullscreen
}
if props.Loading != "" {
loading={ props.Loading }
}
if props.Referrerpolicy != "" {
referrerpolicy={ props.Referrerpolicy }
}
if props.Sandbox != "" {
sandbox={ props.Sandbox }
}
if props.Zoom != 0 {
zoom={ templ.Sprintf("%v", props.Zoom) }
}
if props.ZoomLevels != "" {
zoom-levels={ props.ZoomLevels }
}
if props.WithoutControls {
without-controls
}
if props.WithoutInteraction {
without-interaction
}
if props.OnLoad != "" {
x-on:load={ props.OnLoad }
}
if props.OnError != "" {
x-on:error={ props.OnError }
}
{ props.Attrs... }
>
if props.Slots.ZoomInIcon != nil {
<div slot="zoom-in-icon">
@props.Slots.ZoomInIcon
</div>
}
if props.Slots.ZoomOutIcon != nil {
<div slot="zoom-out-icon">
@props.Slots.ZoomOutIcon
</div>
}
{ children... }
</wa-zoomable-frame>
}
// ZoomableFrameFunc renders with a builder function for inline configuration
templ ZoomableFrameFunc(fn func(*ZoomableFrameBuilder)) {
{{ b := NewZoomableFrame(); fn(b) }}
@ZoomableFrame(b.Props()) {
{ children... }
}
}