1package tui
2
3import (
4 "charm.land/bubbles/v2/textarea"
5 "charm.land/bubbles/v2/textinput"
6 tea "charm.land/bubbletea/v2"
7 "charm.land/lipgloss/v2"
8 "github.com/floatpane/matcha/theme"
9)
10
11// RebuildStyles updates all package-level style variables to match the active theme.
12// This must be called after theme.SetTheme() and at startup.
13func RebuildStyles() {
14 t := theme.ActiveTheme
15
16 // styles.go
17 DialogBoxStyle = lipgloss.NewStyle().
18 Border(lipgloss.RoundedBorder()).
19 BorderForeground(t.AccentDark).
20 Padding(1, 2).
21 BorderTop(true).
22 BorderLeft(true).
23 BorderRight(true).
24 BorderBottom(true)
25
26 HelpStyle = lipgloss.NewStyle().Foreground(t.Secondary)
27 TipStyle = lipgloss.NewStyle().Foreground(t.Tip).Italic(true)
28 SuccessStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
29 InfoStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
30
31 H1Style = lipgloss.NewStyle().
32 Foreground(t.Accent).
33 Bold(true).
34 Align(lipgloss.Center)
35
36 H2Style = lipgloss.NewStyle().
37 Foreground(t.Accent).
38 Bold(false).
39 Align(lipgloss.Center)
40
41 // choice.go
42 titleStyle = lipgloss.NewStyle().Foreground(t.AccentText).Background(t.AccentDark).Padding(0, 1)
43 logoStyle = lipgloss.NewStyle().Foreground(t.Accent)
44 listHeader = lipgloss.NewStyle().Foreground(t.SubtleText).PaddingBottom(1)
45 itemStyle = lipgloss.NewStyle().PaddingLeft(2)
46 selectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(t.Accent)
47
48 // settings.go
49 accountItemStyle = lipgloss.NewStyle().PaddingLeft(2)
50 selectedAccountItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(t.Accent)
51 accountEmailStyle = lipgloss.NewStyle().Foreground(t.Secondary)
52 dangerStyle = lipgloss.NewStyle().Foreground(t.Danger)
53 settingsFocusedStyle = lipgloss.NewStyle().Foreground(t.Accent)
54 settingsBlurredStyle = lipgloss.NewStyle().Foreground(t.Secondary)
55
56 // composer.go
57 suggestionStyle = lipgloss.NewStyle().Foreground(t.Secondary)
58 selectedSuggestionStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
59 suggestionBoxStyle = lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(t.Secondary).Padding(0, 1)
60 focusedStyle = lipgloss.NewStyle().Foreground(t.Accent)
61 blurredStyle = lipgloss.NewStyle().Foreground(t.Secondary)
62 noStyle = lipgloss.NewStyle()
63 helpStyle = lipgloss.NewStyle().Foreground(t.SubtleText)
64 focusedButton = focusedStyle.Render("[ Send ]")
65 blurredButton = blurredStyle.Render("[ Send ]")
66 emailRecipientStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
67 attachmentStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
68 fromSelectorStyle = lipgloss.NewStyle().Foreground(t.Accent)
69 smimeToggleStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
70
71 // inbox.go
72 tabStyle = lipgloss.NewStyle().Padding(0, 2)
73 activeTabStyle = lipgloss.NewStyle().Padding(0, 2).Foreground(t.Accent).Bold(true).Underline(true)
74 tabBarStyle = lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderBottom(true).PaddingBottom(1).MarginBottom(1)
75 dateStyle = lipgloss.NewStyle().Foreground(t.MutedText)
76 unreadEmailStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
77 readEmailStyle = lipgloss.NewStyle().Foreground(t.Secondary)
78
79 // folder_inbox.go
80 sidebarStyle = lipgloss.NewStyle().
81 Width(sidebarWidth).
82 BorderStyle(lipgloss.NormalBorder()).
83 BorderRight(true).
84 PaddingRight(1).
85 PaddingLeft(1)
86 sidebarTitleStyle = lipgloss.NewStyle().
87 Foreground(t.Accent).
88 Bold(true).
89 PaddingBottom(1)
90 folderStyle = lipgloss.NewStyle().
91 PaddingLeft(1).
92 PaddingRight(1)
93 activeFolderStyle = lipgloss.NewStyle().
94 PaddingLeft(1).
95 PaddingRight(1).
96 Background(t.Accent).
97 Foreground(t.Contrast).
98 Bold(true)
99 moveOverlayStyle = lipgloss.NewStyle().
100 Border(lipgloss.RoundedBorder()).
101 BorderForeground(t.AccentDark).
102 Padding(1, 2)
103 moveOverlayTitleStyle = lipgloss.NewStyle().
104 Foreground(t.Accent).
105 Bold(true).
106 PaddingBottom(1)
107 moveItemStyle = lipgloss.NewStyle().
108 PaddingLeft(1)
109 moveSelectedItemStyle = lipgloss.NewStyle().
110 PaddingLeft(1).
111 Foreground(t.Accent).
112 Bold(true)
113
114 // filepicker.go
115 filePickerItemStyle = lipgloss.NewStyle().PaddingLeft(2)
116 filePickerSelectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(t.Accent)
117 directoryStyle = lipgloss.NewStyle().Foreground(t.Directory)
118 fileSizeStyle = lipgloss.NewStyle().Foreground(t.Secondary)
119
120 // trash_archive.go
121 mailboxTabStyle = lipgloss.NewStyle().Padding(0, 3)
122 activeMailboxTabStyle = lipgloss.NewStyle().Padding(0, 3).Foreground(t.Accent).Bold(true).Underline(true)
123}
124
125// ThemedTextInputStyles returns textinput.Styles using the active theme colors.
126func ThemedTextInputStyles() textinput.Styles {
127 t := theme.ActiveTheme
128 return textinput.Styles{
129 Focused: textinput.StyleState{
130 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
131 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
132 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
133 Text: lipgloss.NewStyle(),
134 },
135 Blurred: textinput.StyleState{
136 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
137 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
138 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
139 Text: lipgloss.NewStyle().Foreground(t.DimText),
140 },
141 Cursor: textinput.CursorStyle{
142 Color: t.AccentText,
143 Shape: tea.CursorBlock,
144 Blink: true,
145 },
146 }
147}
148
149// ThemedTextAreaStyles returns textarea.Styles using the active theme colors.
150func ThemedTextAreaStyles() textarea.Styles {
151 t := theme.ActiveTheme
152 return textarea.Styles{
153 Focused: textarea.StyleState{
154 Base: lipgloss.NewStyle(),
155 CursorLine: lipgloss.NewStyle(),
156 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
157 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
158 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
159 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
160 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
161 Text: lipgloss.NewStyle(),
162 },
163 Blurred: textarea.StyleState{
164 Base: lipgloss.NewStyle(),
165 CursorLine: lipgloss.NewStyle().Foreground(t.DimText),
166 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
167 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
168 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
169 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
170 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
171 Text: lipgloss.NewStyle().Foreground(t.DimText),
172 },
173 Cursor: textarea.CursorStyle{
174 Color: t.AccentText,
175 Shape: tea.CursorBlock,
176 Blink: true,
177 },
178 }
179}