theme.go

  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).Bold(true)
 51	accountEmailStyle = lipgloss.NewStyle().Foreground(t.Secondary)
 52	dangerStyle = lipgloss.NewStyle().Foreground(t.Danger)
 53	settingsFocusedStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
 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	helpStyle = lipgloss.NewStyle().Foreground(t.SubtleText)
 63	emailRecipientStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
 64	attachmentStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
 65	smimeToggleStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
 66
 67	// inbox.go
 68	tabStyle = lipgloss.NewStyle().Padding(0, 2)
 69	activeTabStyle = lipgloss.NewStyle().Padding(0, 2).Foreground(t.Accent).Bold(true).Underline(true)
 70	tabBarStyle = lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderBottom(true).PaddingBottom(1).MarginBottom(1)
 71	unreadEmailStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
 72	readEmailStyle = lipgloss.NewStyle().Foreground(t.Secondary)
 73	visualSelectedStyle = lipgloss.NewStyle().Background(t.AccentDark).Foreground(t.AccentText).PaddingLeft(2)
 74	selectedDateStyle = lipgloss.NewStyle().Foreground(t.Accent)
 75
 76	// folder_inbox.go
 77	sidebarStyle = lipgloss.NewStyle().
 78		Width(sidebarWidth).
 79		BorderStyle(lipgloss.NormalBorder()).
 80		BorderRight(true).
 81		PaddingRight(1).
 82		PaddingLeft(1)
 83	sidebarTitleStyle = lipgloss.NewStyle().
 84		Foreground(t.Accent).
 85		Bold(true).
 86		PaddingBottom(1)
 87	folderStyle = lipgloss.NewStyle().
 88		PaddingLeft(1).
 89		PaddingRight(1)
 90	activeFolderStyle = lipgloss.NewStyle().
 91		PaddingLeft(1).
 92		PaddingRight(1).
 93		Background(t.Accent).
 94		Foreground(t.Contrast).
 95		Bold(true)
 96	moveOverlayStyle = lipgloss.NewStyle().
 97		Border(lipgloss.RoundedBorder()).
 98		BorderForeground(t.AccentDark).
 99		Padding(1, 2)
100	moveOverlayTitleStyle = lipgloss.NewStyle().
101		Foreground(t.Accent).
102		Bold(true).
103		PaddingBottom(1)
104	moveItemStyle = lipgloss.NewStyle().
105		PaddingLeft(1)
106	moveSelectedItemStyle = lipgloss.NewStyle().
107		PaddingLeft(1).
108		Foreground(t.Accent).
109		Bold(true)
110
111	// filepicker.go
112	filePickerItemStyle = lipgloss.NewStyle().PaddingLeft(2)
113	filePickerSelectedItemStyle = lipgloss.NewStyle().PaddingLeft(2).Foreground(t.Accent)
114	directoryStyle = lipgloss.NewStyle().Foreground(t.Directory)
115	fileSizeStyle = lipgloss.NewStyle().Foreground(t.Secondary)
116}
117
118// ThemedTextInputStyles returns textinput.Styles using the active theme colors.
119func ThemedTextInputStyles() textinput.Styles {
120	t := theme.ActiveTheme
121	return textinput.Styles{
122		Focused: textinput.StyleState{
123			Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
124			Suggestion:  lipgloss.NewStyle().Foreground(t.DimText),
125			Prompt:      lipgloss.NewStyle().Foreground(t.AccentText),
126			Text:        lipgloss.NewStyle(),
127		},
128		Blurred: textinput.StyleState{
129			Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
130			Suggestion:  lipgloss.NewStyle().Foreground(t.DimText),
131			Prompt:      lipgloss.NewStyle().Foreground(t.MutedText),
132			Text:        lipgloss.NewStyle().Foreground(t.DimText),
133		},
134		Cursor: textinput.CursorStyle{
135			Color: t.AccentText,
136			Shape: tea.CursorBlock,
137			Blink: true,
138		},
139	}
140}
141
142// ThemedTextAreaStyles returns textarea.Styles using the active theme colors.
143func ThemedTextAreaStyles() textarea.Styles {
144	t := theme.ActiveTheme
145	return textarea.Styles{
146		Focused: textarea.StyleState{
147			Base:             lipgloss.NewStyle(),
148			CursorLine:       lipgloss.NewStyle(),
149			CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
150			EndOfBuffer:      lipgloss.NewStyle().Foreground(t.Secondary),
151			LineNumber:       lipgloss.NewStyle().Foreground(t.MutedText),
152			Placeholder:      lipgloss.NewStyle().Foreground(t.DimText),
153			Prompt:           lipgloss.NewStyle().Foreground(t.AccentText),
154			Text:             lipgloss.NewStyle(),
155		},
156		Blurred: textarea.StyleState{
157			Base:             lipgloss.NewStyle(),
158			CursorLine:       lipgloss.NewStyle().Foreground(t.DimText),
159			CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
160			EndOfBuffer:      lipgloss.NewStyle().Foreground(t.Secondary),
161			LineNumber:       lipgloss.NewStyle().Foreground(t.MutedText),
162			Placeholder:      lipgloss.NewStyle().Foreground(t.DimText),
163			Prompt:           lipgloss.NewStyle().Foreground(t.MutedText),
164			Text:             lipgloss.NewStyle().Foreground(t.DimText),
165		},
166		Cursor: textarea.CursorStyle{
167			Color: t.AccentText,
168			Shape: tea.CursorBlock,
169			Blink: true,
170		},
171	}
172}