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 visualSelectedStyle = lipgloss.NewStyle().Background(t.AccentDark).Foreground(t.AccentText)
79
80 // folder_inbox.go
81 sidebarStyle = lipgloss.NewStyle().
82 Width(sidebarWidth).
83 BorderStyle(lipgloss.NormalBorder()).
84 BorderRight(true).
85 PaddingRight(1).
86 PaddingLeft(1)
87 sidebarTitleStyle = lipgloss.NewStyle().
88 Foreground(t.Accent).
89 Bold(true).
90 PaddingBottom(1)
91 folderStyle = lipgloss.NewStyle().
92 PaddingLeft(1).
93 PaddingRight(1)
94 activeFolderStyle = lipgloss.NewStyle().
95 PaddingLeft(1).
96 PaddingRight(1).
97 Background(t.Accent).
98 Foreground(t.Contrast).
99 Bold(true)
100 moveOverlayStyle = lipgloss.NewStyle().
101 Border(lipgloss.RoundedBorder()).
102 BorderForeground(t.AccentDark).
103 Padding(1, 2)
104 moveOverlayTitleStyle = lipgloss.NewStyle().
105 Foreground(t.Accent).
106 Bold(true).
107 PaddingBottom(1)
108 moveItemStyle = lipgloss.NewStyle().
109 PaddingLeft(1)
110 moveSelectedItemStyle = lipgloss.NewStyle().
111 PaddingLeft(1).
112 Foreground(t.Accent).
113 Bold(true)
114
115 // filepicker.go
116 filePickerItemStyle = lipgloss.NewStyle().PaddingLeft(2)
117 filePickerSelectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(t.Accent)
118 directoryStyle = lipgloss.NewStyle().Foreground(t.Directory)
119 fileSizeStyle = lipgloss.NewStyle().Foreground(t.Secondary)
120
121 // trash_archive.go
122 mailboxTabStyle = lipgloss.NewStyle().Padding(0, 3)
123 activeMailboxTabStyle = lipgloss.NewStyle().Padding(0, 3).Foreground(t.Accent).Bold(true).Underline(true)
124}
125
126// ThemedTextInputStyles returns textinput.Styles using the active theme colors.
127func ThemedTextInputStyles() textinput.Styles {
128 t := theme.ActiveTheme
129 return textinput.Styles{
130 Focused: textinput.StyleState{
131 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
132 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
133 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
134 Text: lipgloss.NewStyle(),
135 },
136 Blurred: textinput.StyleState{
137 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
138 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
139 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
140 Text: lipgloss.NewStyle().Foreground(t.DimText),
141 },
142 Cursor: textinput.CursorStyle{
143 Color: t.AccentText,
144 Shape: tea.CursorBlock,
145 Blink: true,
146 },
147 }
148}
149
150// ThemedTextAreaStyles returns textarea.Styles using the active theme colors.
151func ThemedTextAreaStyles() textarea.Styles {
152 t := theme.ActiveTheme
153 return textarea.Styles{
154 Focused: textarea.StyleState{
155 Base: lipgloss.NewStyle(),
156 CursorLine: lipgloss.NewStyle(),
157 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
158 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
159 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
160 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
161 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
162 Text: lipgloss.NewStyle(),
163 },
164 Blurred: textarea.StyleState{
165 Base: lipgloss.NewStyle(),
166 CursorLine: lipgloss.NewStyle().Foreground(t.DimText),
167 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
168 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
169 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
170 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
171 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
172 Text: lipgloss.NewStyle().Foreground(t.DimText),
173 },
174 Cursor: textarea.CursorStyle{
175 Color: t.AccentText,
176 Shape: tea.CursorBlock,
177 Blink: true,
178 },
179 }
180}