-
Notifications
You must be signed in to change notification settings - Fork 1
/
style.go
143 lines (121 loc) · 4.24 KB
/
style.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
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
package style
import (
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/lipgloss"
)
const (
White = "#ffffff"
Gray = "#777777"
Red = "#ff4444"
HighlightColor = "#1DB954"
SemiHighlightColor = "#146542"
BgColor = "#191414"
)
func RecommendationNormal(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.HiddenBorder())
}
func RecommendationFocused(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(HighlightColor))
}
func ChatNormal(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.HiddenBorder()).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor})
}
func ChatFocused(width, height int) lipgloss.Style {
return lipgloss.NewStyle().
Width(width).
Height(height).
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(HighlightColor)).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor})
}
func BotChat(width int) lipgloss.Style {
return lipgloss.NewStyle().
AlignHorizontal(lipgloss.Right).
Width(width)
}
func UserChat() lipgloss.Style {
return lipgloss.NewStyle().
AlignHorizontal(lipgloss.Left).
Foreground(lipgloss.Color(HighlightColor))
}
func TextInput() lipgloss.Style {
return lipgloss.NewStyle().
AlignHorizontal(lipgloss.Left)
}
func List() (s list.DefaultItemStyles) {
s.NormalTitle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: White, Dark: White}).
Padding(0, 0, 0, 4)
s.NormalDesc = s.NormalTitle.Copy().
Foreground(lipgloss.AdaptiveColor{Light: Gray, Dark: Gray})
s.SelectedTitle = lipgloss.NewStyle().
Border(lipgloss.NormalBorder(), false, false, false, true).
BorderForeground(lipgloss.AdaptiveColor{Light: HighlightColor, Dark: HighlightColor}).
Foreground(lipgloss.AdaptiveColor{Light: HighlightColor, Dark: HighlightColor}).
Padding(0, 0, 0, 1)
s.SelectedDesc = s.SelectedTitle.Copy().
Foreground(lipgloss.AdaptiveColor{Light: SemiHighlightColor, Dark: SemiHighlightColor})
s.DimmedTitle = lipgloss.NewStyle().
Foreground(lipgloss.AdaptiveColor{Light: HighlightColor, Dark: HighlightColor}).
Padding(0, 0, 0, 2)
s.DimmedDesc = s.DimmedTitle.Copy().
Foreground(lipgloss.AdaptiveColor{Light: SemiHighlightColor, Dark: SemiHighlightColor})
s.FilterMatch = lipgloss.NewStyle().Underline(true)
return s
}
func AsciiArt() lipgloss.Style {
return lipgloss.NewStyle().
Foreground(lipgloss.Color(HighlightColor))
}
const (
DefaultErrorMessage = "unexpected error happens.\n\nplease report at\n\nhttps://github.com/JunNishimura/Chatify/issues"
errorDisplayWidth = 60
errorDisplayHeight = 10
)
func ErrorView(message string, windowWidth, windowHeight int) string {
return lipgloss.Place(windowWidth, windowHeight, lipgloss.Center, lipgloss.Center,
lipgloss.NewStyle().
Width(errorDisplayWidth).
Height(errorDisplayHeight).
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(HighlightColor)).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor}).
Render(lipgloss.Place(errorDisplayWidth, errorDisplayHeight, lipgloss.Center, lipgloss.Center,
lipgloss.NewStyle().
Width(errorDisplayWidth).
Align(lipgloss.Center).
Foreground(lipgloss.Color(Red)).
Background(lipgloss.Color(BgColor)).
Render(message))))
}
const (
quitDisplayWidth = 80
quitDisplayHeight = 10
)
func QuitView(message string, windowWidth, windowHeight int) string {
return lipgloss.Place(windowWidth, windowHeight, lipgloss.Center, lipgloss.Center,
lipgloss.NewStyle().
Width(quitDisplayWidth).
Height(quitDisplayHeight).
BorderStyle(lipgloss.ThickBorder()).
BorderForeground(lipgloss.Color(HighlightColor)).
Background(lipgloss.AdaptiveColor{Dark: BgColor, Light: BgColor}).
Render(lipgloss.Place(quitDisplayWidth, quitDisplayHeight, lipgloss.Center, lipgloss.Center,
lipgloss.NewStyle().
Width(quitDisplayWidth).
Align(lipgloss.Center).
Foreground(lipgloss.Color(HighlightColor)).
Background(lipgloss.Color(BgColor)).
Render(message))))
}