forked from alperdrsnn/clime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththemes.go
More file actions
182 lines (159 loc) · 4.54 KB
/
themes.go
File metadata and controls
182 lines (159 loc) · 4.54 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package clime
import "fmt"
type Theme struct {
Name string
Primary *Color
Secondary *Color
Success *Color
Warning *Color
Error *Color
Info *Color
Muted *Color
Background *Color
Text *Color
Border *Color
}
var (
DarkTheme = &Theme{
Name: "Dark",
Primary: BrightBlueColor,
Secondary: BrightCyanColor,
Success: BrightGreenColor,
Warning: BrightYellowColor,
Error: BrightRedColor,
Info: BrightBlueColor,
Muted: DimColor,
Background: BlackColor,
Text: BrightWhiteColor,
Border: BrightBlackColor,
}
LightTheme = &Theme{
Name: "Light",
Primary: BlueColor,
Secondary: CyanColor,
Success: GreenColor,
Warning: YellowColor,
Error: RedColor,
Info: BlueColor,
Muted: BlackColor,
Background: WhiteColor,
Text: BlackColor,
Border: BlackColor,
}
ColorfulTheme = &Theme{
Name: "Colorful",
Primary: BrightMagentaColor,
Secondary: BrightCyanColor,
Success: BrightGreenColor,
Warning: BrightYellowColor,
Error: BrightRedColor,
Info: BrightBlueColor,
Muted: DimColor,
Background: BlackColor,
Text: BrightWhiteColor,
Border: BrightMagentaColor,
}
MinimalTheme = &Theme{
Name: "Minimal",
Primary: WhiteColor,
Secondary: DimColor,
Success: WhiteColor,
Warning: WhiteColor,
Error: WhiteColor,
Info: WhiteColor,
Muted: DimColor,
Background: BlackColor,
Text: WhiteColor,
Border: DimColor,
}
OceanTheme = &Theme{
Name: "Ocean",
Primary: RGB(0, 150, 255),
Secondary: RGB(0, 200, 200),
Success: RGB(0, 255, 150),
Warning: RGB(255, 200, 0),
Error: RGB(255, 100, 100),
Info: RGB(100, 200, 255),
Muted: RGB(100, 100, 150),
Background: RGB(5, 25, 50),
Text: RGB(200, 230, 255),
Border: RGB(50, 100, 150),
}
)
var availableThemes = map[string]*Theme{
"dark": DarkTheme,
"light": LightTheme,
"colorful": ColorfulTheme,
"minimal": MinimalTheme,
"ocean": OceanTheme,
}
var currentTheme = DarkTheme
// SetTheme sets the active theme by name
func SetTheme(themeName string) error {
theme, exists := availableThemes[themeName]
if !exists {
return fmt.Errorf("theme '%s' not found", themeName)
}
currentTheme = theme
Success = theme.Success
Warning = theme.Warning
Error = theme.Error
Info = theme.Info
Muted = theme.Muted
return nil
}
// GetTheme returns the current active theme
func GetTheme() *Theme {
return currentTheme
}
// GetAvailableThemes returns a list of available theme names
func GetAvailableThemes() []string {
names := make([]string, 0, len(availableThemes))
for name := range availableThemes {
names = append(names, name)
}
return names
}
// ThemePreview shows a preview of a theme
func ThemePreview(themeName string) error {
theme, exists := availableThemes[themeName]
if !exists {
return fmt.Errorf("theme '%s' not found", themeName)
}
fmt.Printf("Theme: %s\n", BoldColor.Sprint(theme.Name))
fmt.Printf("Primary: %s\n", theme.Primary.Sprint("Sample Text"))
fmt.Printf("Secondary: %s\n", theme.Secondary.Sprint("Sample Text"))
fmt.Printf("Success: %s\n", theme.Success.Sprint("Sample Text"))
fmt.Printf("Warning: %s\n", theme.Warning.Sprint("Sample Text"))
fmt.Printf("Error: %s\n", theme.Error.Sprint("Sample Text"))
fmt.Printf("Info: %s\n", theme.Info.Sprint("Sample Text"))
fmt.Printf("Muted: %s\n", theme.Muted.Sprint("Sample Text"))
fmt.Printf("Background: %s\n", theme.Background.Sprint("Sample Text"))
fmt.Printf("Text: %s\n", theme.Text.Sprint("Sample Text"))
fmt.Printf("Border: %s\n", theme.Border.Sprint("Sample Text"))
return nil
}
// ShowAllThemes displays previews of all available themes
func ShowAllThemes() {
fmt.Println(BoldColor.Sprint("Available Themes:"))
fmt.Println()
for _, themeName := range GetAvailableThemes() {
ThemePreview(themeName)
fmt.Println()
}
}
// ThemedBanner creates a banner using current theme colors
func ThemedBanner(message string, bannerType BannerType) *Banner {
banner := NewBanner(message, bannerType)
switch bannerType {
case BannerSuccess:
banner.WithColor(currentTheme.Success).WithBorderColor(currentTheme.Border)
case BannerWarning:
banner.WithColor(currentTheme.Warning).WithBorderColor(currentTheme.Border)
case BannerError:
banner.WithColor(currentTheme.Error).WithBorderColor(currentTheme.Border)
case BannerInfo:
banner.WithColor(currentTheme.Info).WithBorderColor(currentTheme.Border)
}
return banner
}