1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-06-09 06:20:43 +00:00

Added Selector to Theme, fixed formatting

This commit is contained in:
マリウス 2023-01-07 00:11:44 -05:00
parent 32b1ffe1f0
commit 04eec8293a
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F
3 changed files with 52 additions and 19 deletions

View File

@ -47,6 +47,10 @@ type Config struct {
Systems []SystemConfig
Theme struct {
Header struct {
Selector ThemeItemConfig
}
DialogBox struct {
Window struct {
Focused ThemeItemConfig
@ -186,6 +190,22 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("RenderImages", "true")
// --- Header ---
// Header Selector
viper.SetDefault("Theme.Header.Selector.Margin",
[]int{0, 0, 0, 0})
viper.SetDefault("Theme.Header.Selector.Padding",
[]int{0, 1, 0, 1})
viper.SetDefault("Theme.Header.Selector.Border.Border",
lipgloss.NormalBorder())
viper.SetDefault("Theme.Header.Selector.Border.Sides",
[]bool{true, true, true, true},
)
viper.SetDefault("Theme.Header.Selector.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#6ca1d0", Dark: "#6ca1d0"})
viper.SetDefault("Theme.Header.Selector.Foreground",
lipgloss.AdaptiveColor{Light: "#6ca1d0", Dark: "#6ca1d0"})
// --- DialogBox ---
// DialogBox Window:Focused
viper.SetDefault("Theme.DialogBox.Window.Focused.Margin",
@ -198,7 +218,7 @@ func SetDefaults(cacheDir string) {
[]bool{false, true, true, true},
)
viper.SetDefault("Theme.DialogBox.Window.Focused.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
lipgloss.AdaptiveColor{Light: "#82e4dc", Dark: "#82e4dc"})
// DialogBox Window:Blurred
viper.SetDefault("Theme.DialogBox.Window.Blurred.Margin",
@ -221,7 +241,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Foreground",
lipgloss.AdaptiveColor{Light: "#ffffff", Dark: "#000000"})
viper.SetDefault("Theme.DialogBox.Titlebar.Focused.Background",
lipgloss.AdaptiveColor{Light: "#00cccc", Dark: "#00cccc"})
lipgloss.AdaptiveColor{Light: "#82e4dc", Dark: "#82e4dc"})
// DialogBox Titlebar:Blurred
viper.SetDefault("Theme.DialogBox.Titlebar.Blurred.Margin",
@ -308,7 +328,7 @@ func SetDefaults(cacheDir string) {
[]bool{true, true, true, true},
)
viper.SetDefault("Theme.PostsList.List.Focused.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
lipgloss.AdaptiveColor{Light: "#82e4dc", Dark: "#82e4dc"})
// PostsList List:Blurred
viper.SetDefault("Theme.PostsList.List.Blurred.Margin",
@ -346,7 +366,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Theme.PostsList.Item.Selected.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#ffd500", Dark: "#ffd500"})
viper.SetDefault("Theme.PostsList.Item.Selected.Foreground",
lipgloss.AdaptiveColor{Light: "#F25D94", Dark: "#F25D94"})
lipgloss.AdaptiveColor{Light: "#f119a0", Dark: "#f119a0"})
// PostsList ItemDetail:Focused
viper.SetDefault("Theme.PostsList.ItemDetail.Focused.Padding",
@ -385,7 +405,7 @@ func SetDefaults(cacheDir string) {
[]bool{true, true, true, true},
)
viper.SetDefault("Theme.PopupList.List.Focused.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#00ffff", Dark: "#00ffff"})
lipgloss.AdaptiveColor{Light: "#82e4dc", Dark: "#82e4dc"})
// PopupList List:Blurred
viper.SetDefault("Theme.PopupList.List.Blurred.Margin",
@ -423,7 +443,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Theme.PopupList.Item.Selected.Border.Foreground",
lipgloss.AdaptiveColor{Light: "#ffd500", Dark: "#ffd500"})
viper.SetDefault("Theme.PopupList.Item.Selected.Foreground",
lipgloss.AdaptiveColor{Light: "#F25D94", Dark: "#F25D94"})
lipgloss.AdaptiveColor{Light: "#f119a0", Dark: "#f119a0"})
// PopupList ItemDetail:Focused
viper.SetDefault("Theme.PopupList.ItemDetail.Focused.Padding",
@ -455,7 +475,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Theme.Post.Author.Padding",
[]int{0, 1, 0, 1})
viper.SetDefault("Theme.Post.Author.Foreground",
lipgloss.AdaptiveColor{Light: "#F25D94", Dark: "#F25D94"})
lipgloss.AdaptiveColor{Light: "#f119a0", Dark: "#f119a0"})
// Post Subject
viper.SetDefault("Theme.Post.Subject.Padding",
@ -463,7 +483,7 @@ func SetDefaults(cacheDir string) {
viper.SetDefault("Theme.Post.Subject.Foreground",
lipgloss.AdaptiveColor{Light: "#FFFFFF", Dark: "#FFFFFF"})
viper.SetDefault("Theme.Post.Subject.Background",
lipgloss.AdaptiveColor{Light: "#F25D94", Dark: "#F25D94"})
lipgloss.AdaptiveColor{Light: "#f119a0", Dark: "#f119a0"})
// Reply Author
viper.SetDefault("Theme.Reply.Author.Padding",

View File

@ -67,12 +67,6 @@ func (m Model) View() string {
selectorWidth := 40
selectorTextLen := selectorWidth - 7
selector := lipgloss.NewStyle().
Foreground(lipgloss.Color("#7fffd4")).
BorderForeground(lipgloss.Color("#7fffd4")).
Border(lipgloss.NormalBorder()).
Padding(0, 1, 0, 1).
Width(selectorWidth)
curSysIdx := m.ctx.GetCurrentSystem()
var currentSystem string = "All"
@ -92,15 +86,21 @@ func (m Model) View() string {
}
}
systemSelector := selector.Render(fmt.Sprintf("⏷ %s", currentSystem))
forumSelector := selector.Render(fmt.Sprintf("⏷ %s", currentForum))
systemSelector := m.ctx.Theme.Header.Selector.
Width(selectorWidth).Render(fmt.Sprintf("⏷ %s", currentSystem))
forumSelector := m.ctx.Theme.Header.Selector.
Width(selectorWidth).Render(fmt.Sprintf("⏷ %s", currentForum))
selectorColumn := lipgloss.JoinVertical(lipgloss.Center,
lipgloss.JoinHorizontal(lipgloss.Bottom, "System: \n "+
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("C-e"),
lipgloss.NewStyle().Foreground(
m.ctx.Theme.DialogBox.Bottombar.GetForeground(),
).Render("C-e"),
systemSelector),
lipgloss.JoinHorizontal(lipgloss.Bottom, "Forum: \n "+
lipgloss.NewStyle().Foreground(m.ctx.Theme.DialogBox.Bottombar.GetForeground()).Render("C-t"),
lipgloss.NewStyle().Foreground(
m.ctx.Theme.DialogBox.Bottombar.GetForeground(),
).Render("C-t"),
forumSelector),
)
@ -108,7 +108,13 @@ func (m Model) View() string {
spinner = m.spinner.View()
}
row = lipgloss.JoinHorizontal(lipgloss.Top, banner, " ", selectorColumn, " ", spinner)
row = lipgloss.JoinHorizontal(lipgloss.Top,
banner,
" ",
selectorColumn,
" ",
spinner,
)
return row
}

View File

@ -6,6 +6,10 @@ import (
)
type Theme struct {
Header struct {
Selector lipgloss.Style
}
DialogBox struct {
Window struct {
Focused lipgloss.Style
@ -77,6 +81,9 @@ type Theme struct {
func New(cfg *config.Config) *Theme {
t := new(Theme)
t.Header.Selector =
t.fromConfig(&cfg.Theme.Header.Selector)
t.DialogBox.Window.Focused =
t.fromConfig(&cfg.Theme.DialogBox.Window.Focused)
t.DialogBox.Window.Blurred =