Documentation
¶
Overview ¶
Package popover provides rich content popover components.
Available variants:
- New() creates a popover (template: "lvt:popover:default:v1")
Open/close is handled client-side via CSS classes and onclick/onmouseenter/onmouseleave handlers. Server actions handle data operations only.
Example usage:
// In your controller/state
InfoPopover: popover.New("info",
popover.WithTitle("Details"),
popover.WithPosition(popover.PositionBottom),
)
// In your template
{{template "lvt:popover:default:v1" .InfoPopover}}
Index ¶
- func Templates() *base.TemplateSet
- type Option
- func WithArrow(show bool) Option
- func WithCloseOnClickAway(close bool) Option
- func WithContent(content string) Option
- func WithOpen(_ bool) Option
- func WithPosition(position Position) Option
- func WithShowClose(show bool) Option
- func WithStyled(styled bool) Option
- func WithTitle(title string) Option
- func WithTrigger(trigger Trigger) Option
- func WithWidth(width string) Option
- type Popover
- func (p *Popover) ArrowClasses() string
- func (p *Popover) HasContent() bool
- func (p *Popover) HasHeader() bool
- func (p *Popover) HasTitle() bool
- func (p *Popover) IsBottom() bool
- func (p *Popover) IsClickTrigger() bool
- func (p *Popover) IsFocusTrigger() bool
- func (p *Popover) IsHoverTrigger() bool
- func (p *Popover) IsLeft() bool
- func (p *Popover) IsRight() bool
- func (p *Popover) IsTop() bool
- func (p *Popover) PositionClasses() string
- func (p *Popover) Styles() styles.PopoverStyles
- type Position
- type Trigger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Templates ¶
func Templates() *base.TemplateSet
Templates returns the popover component's template set for registration with the LiveTemplate framework.
Example usage in main.go:
import "github.com/livetemplate/lvt/components/popover"
tmpl, err := livetemplate.New("app",
livetemplate.WithComponentTemplates(popover.Templates()),
)
Available templates:
- "lvt:popover:default:v1" - Rich content popover
Types ¶
type Option ¶
type Option func(*Popover)
Option is a functional option for configuring popovers.
func WithCloseOnClickAway ¶
WithCloseOnClickAway enables closing on click outside.
func WithOpen ¶
WithOpen is a no-op. Open/close is now handled client-side via CSS classes. Deprecated: This option has no effect.
func WithPosition ¶
WithPosition sets the popover position.
type Popover ¶
type Popover struct {
base.Base
// Title is the popover header
Title string
// Content is the popover body text
Content string
// Position is where the popover appears
Position Position
// Trigger is what action shows the popover
Trigger Trigger
// Arrow shows a pointing arrow
Arrow bool
// CloseOnClickAway closes popover when clicking outside
CloseOnClickAway bool
// ShowClose shows a close button in header
ShowClose bool
// Width sets the popover width
Width string
}
Popover is a rich content overlay component. Use template "lvt:popover:default:v1" to render.
func New ¶
New creates a popover.
Example:
p := popover.New("info",
popover.WithTitle("Information"),
popover.WithContent("Some details here"),
popover.WithPosition(popover.PositionBottom),
)
func (*Popover) ArrowClasses ¶
ArrowClasses returns CSS classes for the arrow.
func (*Popover) HasContent ¶
HasContent returns true if popover has content.
func (*Popover) IsClickTrigger ¶
IsClickTrigger returns true if trigger is click.
func (*Popover) IsFocusTrigger ¶
IsFocusTrigger returns true if trigger is focus.
func (*Popover) IsHoverTrigger ¶
IsHoverTrigger returns true if trigger is hover.
func (*Popover) PositionClasses ¶
PositionClasses returns CSS classes for position.
func (*Popover) Styles ¶
func (p *Popover) Styles() styles.PopoverStyles
Styles returns the resolved PopoverStyles for this component.
type Position ¶
type Position string
Position defines where the popover appears relative to trigger.
const ( PositionTop Position = "top" PositionTopStart Position = "top-start" PositionTopEnd Position = "top-end" PositionBottom Position = "bottom" PositionBottomStart Position = "bottom-start" PositionBottomEnd Position = "bottom-end" PositionLeft Position = "left" PositionLeftStart Position = "left-start" PositionLeftEnd Position = "left-end" PositionRight Position = "right" PositionRightStart Position = "right-start" PositionRightEnd Position = "right-end" )