-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
74 lines (63 loc) · 1.8 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package goaster
// Option type for functional options pattern, allowing customization of the Toaster instance.
type Option func(*Toaster)
// WithVariant configures the style variant for the toast.
func WithVariant(variant Variant) Option {
return func(tp *Toaster) {
tp.Variant = variant
}
}
// WithBorder configures the presence of a border around the toast.
func WithBorder(border bool) Option {
return func(tp *Toaster) {
tp.Border = border
}
}
// WithRounded configures the presence of a rounded border around the toast.
func WithRounded(rounded bool) Option {
return func(tp *Toaster) {
tp.Rounded = rounded
}
}
// WithShowIcon configures whether the toast should display the icon.
func WithShowIcon(icon bool) Option {
return func(tp *Toaster) {
tp.ShowIcon = icon
}
}
// WithButton configures whether the toast should display the close button.
func WithButton(button bool) Option {
return func(tp *Toaster) {
tp.Button = button
}
}
// WithAutoDismiss configures whether the toast should auto-dismiss.
func WithAutoDismiss(autoDismiss bool) Option {
return func(tp *Toaster) {
tp.AutoDismiss = autoDismiss
}
}
// WithAnimation configures whether the toast should use animations.
func WithAnimation(animation bool) Option {
return func(tp *Toaster) {
tp.Animation = animation
}
}
// WithProgressBar configures whether the toast should display a progressbar.
func WithProgressBar(progressbar bool) Option {
return func(tp *Toaster) {
tp.ProgressBar = progressbar
}
}
// WithPosition sets the position of the toast notifications.
func WithPosition(position Position) Option {
return func(t *Toaster) {
t.Position = position
}
}
// WithIcon sets the icon for a specific toast level.
func WithIcon(level Level, iconSVG string) Option {
return func(t *Toaster) {
t.Icons[level] = iconSVG
}
}