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)
 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	emailRecipientStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
 65	attachmentStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
 66	fromSelectorStyle = lipgloss.NewStyle().Foreground(t.Accent)
 67	smimeToggleStyle = lipgloss.NewStyle().PaddingLeft(4).Foreground(t.Secondary)
 68
 69	// inbox.go
 70	tabStyle = lipgloss.NewStyle().Padding(0, 2)
 71	activeTabStyle = lipgloss.NewStyle().Padding(0, 2).Foreground(t.Accent).Bold(true).Underline(true)
 72	tabBarStyle = lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderBottom(true).PaddingBottom(1).MarginBottom(1)
 73	dateStyle = lipgloss.NewStyle().Foreground(t.MutedText)
 74	unreadEmailStyle = lipgloss.NewStyle().Foreground(t.Accent).Bold(true)
 75	readEmailStyle = lipgloss.NewStyle().Foreground(t.Secondary)
 76	visualSelectedStyle = lipgloss.NewStyle().Background(t.AccentDark).Foreground(t.AccentText).PaddingLeft(2)
 77	selectedDateStyle = lipgloss.NewStyle().Foreground(t.Accent)
 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
121// ThemedTextInputStyles returns textinput.Styles using the active theme colors.
122func ThemedTextInputStyles() textinput.Styles {
123	t := theme.ActiveTheme
124	return textinput.Styles{
125		Focused: textinput.StyleState{
126			Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
127			Suggestion:  lipgloss.NewStyle().Foreground(t.DimText),
128			Prompt:      lipgloss.NewStyle().Foreground(t.AccentText),
129			Text:        lipgloss.NewStyle(),
130		},
131		Blurred: textinput.StyleState{
132			Placeholder: lipgloss.NewStyle().Foreground(t.DimText),
133			Suggestion:  lipgloss.NewStyle().Foreground(t.DimText),
134			Prompt:      lipgloss.NewStyle().Foreground(t.MutedText),
135			Text:        lipgloss.NewStyle().Foreground(t.DimText),
136		},
137		Cursor: textinput.CursorStyle{
138			Color: t.AccentText,
139			Shape: tea.CursorBlock,
140			Blink: true,
141		},
142	}
143}
144
145// ThemedTextAreaStyles returns textarea.Styles using the active theme colors.
146func ThemedTextAreaStyles() textarea.Styles {
147	t := theme.ActiveTheme
148	return textarea.Styles{
149		Focused: textarea.StyleState{
150			Base:             lipgloss.NewStyle(),
151			CursorLine:       lipgloss.NewStyle(),
152			CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
153			EndOfBuffer:      lipgloss.NewStyle().Foreground(t.Secondary),
154			LineNumber:       lipgloss.NewStyle().Foreground(t.MutedText),
155			Placeholder:      lipgloss.NewStyle().Foreground(t.DimText),
156			Prompt:           lipgloss.NewStyle().Foreground(t.AccentText),
157			Text:             lipgloss.NewStyle(),
158		},
159		Blurred: textarea.StyleState{
160			Base:             lipgloss.NewStyle(),
161			CursorLine:       lipgloss.NewStyle().Foreground(t.DimText),
162			CursorLineNumber: lipgloss.NewStyle().Foreground(t.MutedText),
163			EndOfBuffer:      lipgloss.NewStyle().Foreground(t.Secondary),
164			LineNumber:       lipgloss.NewStyle().Foreground(t.MutedText),
165			Placeholder:      lipgloss.NewStyle().Foreground(t.DimText),
166			Prompt:           lipgloss.NewStyle().Foreground(t.MutedText),
167			Text:             lipgloss.NewStyle().Foreground(t.DimText),
168		},
169		Cursor: textarea.CursorStyle{
170			Color: t.AccentText,
171			Shape: tea.CursorBlock,
172			Blink: true,
173		},
174	}
175}