Documentation
¶
Overview ¶
Package goaster - Helpers for using toasts with `template/html`
Index ¶
- Constants
- type HTMLGenerator
- type Icon
- type Level
- type Option
- func WithAnimation(animation bool) Option
- func WithAutoDismiss(autoDismiss bool) Option
- func WithBorder(border bool) Option
- func WithButton(button bool) Option
- func WithIcon(level Level, iconSVG string) Option
- func WithPosition(position Position) Option
- func WithProgressBar(progressbar bool) Option
- func WithRounded(rounded bool) Option
- func WithShowIcon(icon bool) Option
- func WithVariant(variant Variant) Option
- type Position
- type Queue
- type Toast
- type Toaster
- func (t *Toaster) Default(message string) templ.Component
- func (t *Toaster) Error(message string) templ.Component
- func (t *Toaster) Info(message string) templ.Component
- func (t *Toaster) PushDefault(message string)
- func (t *Toaster) PushError(message string)
- func (t *Toaster) PushInfo(message string)
- func (t *Toaster) PushSuccess(message string)
- func (t *Toaster) PushWarning(message string)
- func (t *Toaster) Queue() *Queue
- func (t *Toaster) RenderAll() templ.Component
- func (t *Toaster) Success(message string) templ.Component
- func (t *Toaster) ToViewModel() viewmodel.ToasterViewModel
- func (t *Toaster) Warning(message string) templ.Component
- type ToasterBuilder
- func (b *ToasterBuilder) Build() *Toaster
- func (b *ToasterBuilder) WithAnimation(animation bool) *ToasterBuilder
- func (b *ToasterBuilder) WithAutoDismiss(autoDismiss bool) *ToasterBuilder
- func (b *ToasterBuilder) WithBorder(border bool) *ToasterBuilder
- func (b *ToasterBuilder) WithButton(button bool) *ToasterBuilder
- func (b *ToasterBuilder) WithIcon(level Level, iconSVG string) *ToasterBuilder
- func (b *ToasterBuilder) WithOptions(options ...Option) *ToasterBuilder
- func (b *ToasterBuilder) WithPosition(position Position) *ToasterBuilder
- func (b *ToasterBuilder) WithProgressBar(progressBar bool) *ToasterBuilder
- func (b *ToasterBuilder) WithRounded(rounded bool) *ToasterBuilder
- func (b *ToasterBuilder) WithShowIcon(showIcon bool) *ToasterBuilder
- func (b *ToasterBuilder) WithVariant(variant Variant) *ToasterBuilder
- type Variant
Constants ¶
const ( TopRight = Position("top-right") TopLeft = Position("top-left") TopCenter = Position("top-center") BottomRight = Position("bottom-right") BottomLeft = Position("bottom-left") BottomCenter = Position("bottom-center") )
Predefined toast positions
const ( Accent = Variant("accent") AccentLight = Variant("accent-light") AccentDark = Variant("accent-dark") )
Predefined style variants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTMLGenerator ¶
type HTMLGenerator struct{}
HTMLGenerator provides functions for generating HTML code for toast notifications.
func NewHTMLGenerator ¶
func NewHTMLGenerator() *HTMLGenerator
NewHTMLGenerator creates a new instance of HTMLGenerator.
func (*HTMLGenerator) DisplayAll ¶
func (g *HTMLGenerator) DisplayAll(t *Toaster) (template.HTML, error)
DisplayAll generates HTML code for displaying the toast and returns it as a template.HTML.
type Level ¶
type Level string
Level represents the severity level of a toast notification.
type Option ¶
type Option func(*Toaster)
Option represents a configuration function that modifies a Toaster instance.
func WithAnimation ¶
WithAnimation configures whether the toast should use animations.
func WithAutoDismiss ¶
WithAutoDismiss configures whether the toast should auto-dismiss.
func WithBorder ¶
WithBorder configures the presence of a border around the toast.
func WithButton ¶
WithButton configures whether the toast should display the close button.
func WithPosition ¶
WithPosition sets the position of the toast notifications.
func WithProgressBar ¶
WithProgressBar configures whether the toast should display a progressbar.
func WithRounded ¶ added in v0.1.1
WithRounded configures the presence of a rounded border around the toast.
func WithShowIcon ¶
WithShowIcon configures whether the toast should display the icon.
func WithVariant ¶
WithVariant configures the style variant for the toast.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func (*Queue) Dequeue ¶
Dequeue removes and returns the first element of the queue. If the queue is empty, it returns -1 and an error.
func (*Queue) GetMessagesAndDequeue ¶
GetMessagesAndDequeue returns a slice of Toast messages from the queue. It dequeues messages from the queue until it's empty. **NOTE**: in a-h/templ only `for...range` is a valid `for`loop.
type Toaster ¶
type Toaster struct { Variant Variant // Style variant Border bool // Display border Rounded bool // Use rounded corners ShowIcon bool // Show icon Button bool // Show close button AutoDismiss bool // Auto-dismiss after timeout Animation bool // Animate entrance/exit ProgressBar bool // Show progress bar Position Position // Screen position Icons map[Level]string // Custom icons // contains filtered or unexported fields }
Toaster holds configuration for toast notifications.
func NewToaster ¶
NewToaster creates a Toaster instance with default settings and applies any given options.
func ToasterDefaults ¶ added in v0.2.0
func ToasterDefaults() *Toaster
func (*Toaster) PushDefault ¶
PushDefault adds a default toast notification.
func (*Toaster) PushSuccess ¶
PushSuccess adds a success toast notification.
func (*Toaster) PushWarning ¶
PushWarning adds a warning toast notification.
func (*Toaster) ToViewModel ¶ added in v0.2.0
func (t *Toaster) ToViewModel() viewmodel.ToasterViewModel
type ToasterBuilder ¶ added in v0.2.0
type ToasterBuilder struct {
// contains filtered or unexported fields
}
ToasterBuilder builds a Toaster instance using chainable methods.
func NewToasterBuilder ¶ added in v0.2.0
func NewToasterBuilder() *ToasterBuilder
NewToasterBuilder creates a new builder with default values.
func (*ToasterBuilder) Build ¶ added in v0.2.0
func (b *ToasterBuilder) Build() *Toaster
Build finalizes and returns the configured Toaster instance.
func (*ToasterBuilder) WithAnimation ¶ added in v0.2.0
func (b *ToasterBuilder) WithAnimation(animation bool) *ToasterBuilder
func (*ToasterBuilder) WithAutoDismiss ¶ added in v0.2.0
func (b *ToasterBuilder) WithAutoDismiss(autoDismiss bool) *ToasterBuilder
func (*ToasterBuilder) WithBorder ¶ added in v0.2.0
func (b *ToasterBuilder) WithBorder(border bool) *ToasterBuilder
func (*ToasterBuilder) WithButton ¶ added in v0.2.0
func (b *ToasterBuilder) WithButton(button bool) *ToasterBuilder
func (*ToasterBuilder) WithIcon ¶ added in v0.2.0
func (b *ToasterBuilder) WithIcon(level Level, iconSVG string) *ToasterBuilder
func (*ToasterBuilder) WithOptions ¶ added in v0.2.0
func (b *ToasterBuilder) WithOptions(options ...Option) *ToasterBuilder
func (*ToasterBuilder) WithPosition ¶ added in v0.2.0
func (b *ToasterBuilder) WithPosition(position Position) *ToasterBuilder
func (*ToasterBuilder) WithProgressBar ¶ added in v0.2.0
func (b *ToasterBuilder) WithProgressBar(progressBar bool) *ToasterBuilder
func (*ToasterBuilder) WithRounded ¶ added in v0.2.0
func (b *ToasterBuilder) WithRounded(rounded bool) *ToasterBuilder
func (*ToasterBuilder) WithShowIcon ¶ added in v0.2.0
func (b *ToasterBuilder) WithShowIcon(showIcon bool) *ToasterBuilder
func (*ToasterBuilder) WithVariant ¶ added in v0.2.0
func (b *ToasterBuilder) WithVariant(variant Variant) *ToasterBuilder
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
templ: version: v0.3.920
|
templ: version: v0.3.920 |
css
templ: version: v0.3.920
|
templ: version: v0.3.920 |
css/themes
templ: version: v0.3.920
|
templ: version: v0.3.920 |
css/variants
templ: version: v0.3.920
|
templ: version: v0.3.920 |
js
templ: version: v0.3.920
|
templ: version: v0.3.920 |
layouts
templ: version: v0.3.920
|
templ: version: v0.3.920 |
layouts/partials
templ: version: v0.3.920
|
templ: version: v0.3.920 |
pages
templ: version: v0.3.920
|
templ: version: v0.3.920 |
styles
templ: version: v0.3.920
|
templ: version: v0.3.920 |
internal
|
|