-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.go
78 lines (70 loc) · 2.33 KB
/
utils.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
75
76
77
78
package goaster
import (
"github.com/a-h/templ"
"strings"
)
// defaultIcons returns a map of default SVG icons for each toast level.
func defaultIcons() map[Level]string {
return map[Level]string{
DefaultLevel: defaultDefaultIcon,
SuccessLevel: defaultSuccessIcon,
ErrorLevel: defaultErrorIcon,
WarningLevel: defaultWarningIcon,
InfoLevel: defaultInfoIcon,
}
}
// getMapCssClassByLevel returns a map of CSS classes for toasts based on their level.
func getMapCssClassByLevel() map[Level]templ.CSSClass {
return map[Level]templ.CSSClass{
SuccessLevel: gttSuccessLevel(),
ErrorLevel: gttErrorLevel(),
WarningLevel: gttWarningLevel(),
InfoLevel: gttInfoLevel(),
}
}
func isAccent(variant Variant) bool {
return strings.Contains(variant.String(), "accent")
}
// getMapCssClassByVariant returns a map of CSS classes corresponding to each toast level
// based on the specified variant.
func getMapCssClassByVariant(variant Variant) map[Level]templ.CSSClass {
var variantClasses map[Level]templ.CSSClass
switch variant {
case Accent:
variantClasses = map[Level]templ.CSSClass{
DefaultLevel: gttAccentDefaultLevel(),
SuccessLevel: gttAccentSuccessLevel(),
ErrorLevel: gttAccentErrorLevel(),
WarningLevel: gttAccentWarningLevel(),
InfoLevel: gttAccentInfoLevel(),
}
case AccentLight:
variantClasses = map[Level]templ.CSSClass{
DefaultLevel: gttAccentLightDefaultLevel(),
SuccessLevel: gttAccentLightSuccessLevel(),
ErrorLevel: gttAccentLightErrorLevel(),
WarningLevel: gttAccentLightWarningLevel(),
InfoLevel: gttAccentLightInfoLevel(),
}
case AccentDark:
variantClasses = map[Level]templ.CSSClass{
DefaultLevel: gttAccentDarkDefaultLevel(),
SuccessLevel: gttAccentDarkSuccessLevel(),
ErrorLevel: gttAccentDarkErrorLevel(),
WarningLevel: gttAccentDarkWarningLevel(),
InfoLevel: gttAccentDarkInfoLevel(),
}
}
return variantClasses
}
// getToastEntranceCSSClassesByPosition returns a map of CSS classes for toast entrances based on their position.
func getToastEntranceCSSClassesByPosition() map[Position]templ.CSSClass {
return map[Position]templ.CSSClass{
TopRight: gttShowFromTop(),
TopLeft: gttShowFromTop(),
TopCenter: gttShowFromTop(),
BottomRight: gttShowFromBottom(),
BottomLeft: gttShowFromBottom(),
BottomCenter: gttShowFromBottom(),
}
}