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
122// ThemedTextInputStyles returns textinput.Styles using the active theme colors.
123func ThemedTextInputStyles() textinput.Styles {
124 t := theme.ActiveTheme
125 return textinput.Styles{
126 Focused: textinput.StyleState{
127 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
128 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
129 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
130 Text: lipgloss.NewStyle(),
131 },
132 Blurred: textinput.StyleState{
133 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
134 Suggestion: lipgloss.NewStyle().Foreground(t.DimText),
135 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
136 Text: lipgloss.NewStyle().Foreground(t.DimText),
137 },
138 Cursor: textinput.CursorStyle{
139 Color: t.AccentText,
140 Shape: tea.CursorBlock,
141 Blink: true,
142 },
143 }
144}
145
146// ThemedTextAreaStyles returns textarea.Styles using the active theme colors.
147func ThemedTextAreaStyles() textarea.Styles {
148 t := theme.ActiveTheme
149 return textarea.Styles{
150 Focused: textarea.StyleState{
151 Base: lipgloss.NewStyle(),
152 CursorLine: lipgloss.NewStyle(),
153 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
154 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
155 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
156 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
157 Prompt: lipgloss.NewStyle().Foreground(t.AccentText),
158 Text: lipgloss.NewStyle(),
159 },
160 Blurred: textarea.StyleState{
161 Base: lipgloss.NewStyle(),
162 CursorLine: lipgloss.NewStyle().Foreground(t.DimText),
163 CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
164 EndOfBuffer: lipgloss.NewStyle().Foreground(t.Secondary),
165 LineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
166 Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
167 Prompt: lipgloss.NewStyle().Foreground(t.MutedText),
168 Text: lipgloss.NewStyle().Foreground(t.DimText),
169 },
170 Cursor: textarea.CursorStyle{
171 Color: t.AccentText,
172 Shape: tea.CursorBlock,
173 Blink: true,
174 },
175 }
176}