mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
feat: use adaptive colors to accommodate different terminal bg colors
This commit is contained in:
+6
-6
@@ -47,7 +47,7 @@ func NewLogin() State {
|
||||
var t textinput.Model
|
||||
for i := range state.Inputs {
|
||||
t = textinput.New()
|
||||
t.CursorStyle = ui.CursorStyle
|
||||
t.CursorStyle = CursorStyle
|
||||
t.Prompt = "| "
|
||||
|
||||
switch i {
|
||||
@@ -55,7 +55,7 @@ func NewLogin() State {
|
||||
t.Placeholder = "Host"
|
||||
t.Focus()
|
||||
t.CharLimit = 40
|
||||
t.TextStyle = ui.FocusedStyle
|
||||
t.TextStyle = FocusedStyle
|
||||
case 1:
|
||||
t.Placeholder = "Port"
|
||||
t.CharLimit = 5
|
||||
@@ -111,14 +111,14 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
for i := 0; i <= len(s.Inputs)-1; i++ {
|
||||
if i == s.FocusIndex {
|
||||
cmds[i] = s.Inputs[i].Focus()
|
||||
s.Inputs[i].PromptStyle = ui.FocusedStyle
|
||||
s.Inputs[i].TextStyle = ui.FocusedStyle
|
||||
s.Inputs[i].PromptStyle = FocusedStyle
|
||||
s.Inputs[i].TextStyle = FocusedStyle
|
||||
continue
|
||||
}
|
||||
|
||||
s.Inputs[i].Blur()
|
||||
s.Inputs[i].PromptStyle = ui.NoStyle
|
||||
s.Inputs[i].TextStyle = ui.NoStyle
|
||||
s.Inputs[i].PromptStyle = NoStyle
|
||||
s.Inputs[i].TextStyle = NoStyle
|
||||
}
|
||||
|
||||
return s, tea.Batch(cmds...)
|
||||
|
||||
+20
-9
@@ -18,6 +18,7 @@ package login
|
||||
|
||||
import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/illusionman1212/gorc/ui"
|
||||
)
|
||||
|
||||
const WelcomeMsg = `
|
||||
@@ -36,37 +37,40 @@ const WelcomeMsg = `
|
||||
|
||||
var (
|
||||
FocusedButton = lipgloss.NewStyle().
|
||||
Background(lipgloss.Color("105")).
|
||||
Foreground(lipgloss.Color("#000")).
|
||||
Border(lipgloss.NormalBorder()).
|
||||
BorderForeground(ui.AccentColor).
|
||||
Foreground(ui.AccentColor).
|
||||
MarginTop(1).
|
||||
Padding(0, 2).
|
||||
Align(lipgloss.Center).
|
||||
Bold(true).
|
||||
Render("Connect")
|
||||
BlurredButton = lipgloss.NewStyle().
|
||||
Background(lipgloss.Color("#505050")).
|
||||
Foreground(lipgloss.Color("#EEEEEE")).
|
||||
Border(lipgloss.NormalBorder()).
|
||||
BorderForeground(ui.PrimaryColor).
|
||||
Foreground(ui.PrimaryColor).
|
||||
MarginTop(1).
|
||||
Padding(0, 2).
|
||||
Align(lipgloss.Center).
|
||||
Render("Connect")
|
||||
|
||||
FocusedCheckbox = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("105")).
|
||||
Foreground(ui.AccentColor).
|
||||
MarginTop(1).
|
||||
Render("[ ] Enable TLS")
|
||||
|
||||
BlurredCheckbox = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#EEEEEE")).
|
||||
Foreground(ui.PrimaryColor).
|
||||
MarginTop(1).
|
||||
Render("[ ] Enable TLS")
|
||||
|
||||
FocusedCheckboxChecked = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("105")).
|
||||
Foreground(ui.AccentColor).
|
||||
MarginTop(1).
|
||||
Render("[x] Enable TLS")
|
||||
|
||||
BlurredCheckboxChecked = lipgloss.NewStyle().
|
||||
Foreground(lipgloss.Color("#EEEEEE")).
|
||||
Foreground(ui.PrimaryColor).
|
||||
MarginTop(1).
|
||||
Render("[x] Enable TLS")
|
||||
|
||||
@@ -74,5 +78,12 @@ var (
|
||||
Align(lipgloss.Center)
|
||||
|
||||
WelcomeMsgStyle = lipgloss.NewStyle().
|
||||
Align(lipgloss.Center)
|
||||
Align(lipgloss.Center).
|
||||
Foreground(ui.PrimaryColor)
|
||||
|
||||
CursorStyle = lipgloss.NewStyle().
|
||||
Foreground(ui.AccentColor)
|
||||
FocusedStyle = lipgloss.NewStyle().
|
||||
Foreground(ui.AccentColor)
|
||||
NoStyle = lipgloss.NewStyle()
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
|
||||
"github.com/illusionman1212/gorc/cmds"
|
||||
"github.com/illusionman1212/gorc/ui"
|
||||
)
|
||||
|
||||
type InputState struct {
|
||||
@@ -64,12 +65,12 @@ func (s InputState) Update(msg tea.Msg) (InputState, tea.Cmd) {
|
||||
|
||||
func (s *InputState) Focus() {
|
||||
s.Input.Focus()
|
||||
s.Style = s.Style.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
s.Style = s.Style.Copy().BorderForeground(ui.AccentColor)
|
||||
}
|
||||
|
||||
func (s *InputState) Blur() {
|
||||
s.Input.Blur()
|
||||
s.Style = s.Style.Copy().BorderForeground(lipgloss.Color("#EEE"))
|
||||
s.Style = s.Style.Copy().BorderForeground(ui.PrimaryColor)
|
||||
}
|
||||
|
||||
func (s *InputState) SetSize(width int) {
|
||||
|
||||
+14
-14
@@ -196,24 +196,24 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
|
||||
}
|
||||
|
||||
func (s *State) Focus() {
|
||||
s.Viewport.Style = s.Viewport.Style.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
s.Viewport.Style = s.Viewport.Style.Copy().BorderForeground(ui.AccentColor)
|
||||
|
||||
tab = tab.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
leftArrowDim = leftArrowDim.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
rightArrowDim = rightArrowDim.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
leftArrowLit = leftArrowLit.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
rightArrowLit = rightArrowLit.Copy().BorderForeground(lipgloss.Color("105"))
|
||||
tabLine = tabLine.Copy().Foreground(lipgloss.Color("105"))
|
||||
tab = tab.Copy().BorderForeground(ui.AccentColor)
|
||||
leftArrowDim = leftArrowDim.Copy().BorderForeground(ui.AccentColor)
|
||||
rightArrowDim = rightArrowDim.Copy().BorderForeground(ui.AccentColor)
|
||||
leftArrowLit = leftArrowLit.Copy().BorderForeground(ui.AccentColor)
|
||||
rightArrowLit = rightArrowLit.Copy().BorderForeground(ui.AccentColor)
|
||||
tabLine = tabLine.Copy().Foreground(ui.AccentColor)
|
||||
}
|
||||
func (s *State) Blur() {
|
||||
s.Viewport.Style = s.Viewport.Style.Copy().BorderForeground(lipgloss.Color("#EEE"))
|
||||
s.Viewport.Style = s.Viewport.Style.Copy().BorderForeground(ui.PrimaryColor)
|
||||
|
||||
tab = tab.Copy().UnsetBorderForeground()
|
||||
leftArrowDim = leftArrowDim.Copy().UnsetBorderForeground()
|
||||
rightArrowDim = rightArrowDim.Copy().UnsetBorderForeground()
|
||||
leftArrowLit = leftArrowLit.Copy().UnsetBorderForeground()
|
||||
rightArrowLit = rightArrowLit.Copy().UnsetBorderForeground()
|
||||
tabLine = tabLine.Copy().UnsetForeground()
|
||||
tab = tab.Copy().BorderForeground(ui.PrimaryColor)
|
||||
leftArrowDim = leftArrowDim.Copy().BorderForeground(ui.PrimaryColor)
|
||||
rightArrowDim = rightArrowDim.Copy().BorderForeground(ui.PrimaryColor)
|
||||
leftArrowLit = leftArrowLit.Copy().BorderForeground(ui.PrimaryColor)
|
||||
rightArrowLit = rightArrowLit.Copy().BorderForeground(ui.PrimaryColor)
|
||||
tabLine = tabLine.Copy().Foreground(ui.PrimaryColor)
|
||||
}
|
||||
|
||||
func (s *State) SetSize(width, height int) {
|
||||
|
||||
@@ -23,9 +23,9 @@ import (
|
||||
|
||||
"github.com/charmbracelet/bubbles/viewport"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/illusionman1212/gorc/cmds"
|
||||
"github.com/illusionman1212/gorc/irc"
|
||||
"github.com/illusionman1212/gorc/ui"
|
||||
)
|
||||
|
||||
type SidePanelState struct {
|
||||
@@ -101,12 +101,12 @@ func (s SidePanelState) Update(msg tea.Msg) (SidePanelState, tea.Cmd) {
|
||||
|
||||
func (s *SidePanelState) Focus() {
|
||||
s.Focused = true
|
||||
s.Viewport.Style = s.Viewport.Style.BorderForeground(lipgloss.Color("105"))
|
||||
s.Viewport.Style = s.Viewport.Style.BorderForeground(ui.AccentColor)
|
||||
}
|
||||
|
||||
func (s *SidePanelState) Blur() {
|
||||
s.Focused = false
|
||||
s.Viewport.Style = s.Viewport.Style.BorderForeground(lipgloss.Color("#EEE"))
|
||||
s.Viewport.Style = s.Viewport.Style.BorderForeground(ui.PrimaryColor)
|
||||
}
|
||||
|
||||
func (s *SidePanelState) UpdateNicks() {
|
||||
|
||||
+15
-11
@@ -26,15 +26,15 @@ var (
|
||||
Border(lipgloss.NormalBorder(), true).
|
||||
Padding(0, 1).
|
||||
Width(ui.MainStyle.GetWidth()).
|
||||
BorderForeground(lipgloss.Color("105"))
|
||||
BorderForeground(ui.AccentColor)
|
||||
MessagesStyle = lipgloss.NewStyle().
|
||||
Border(lipgloss.NormalBorder(), false, true, true, true).
|
||||
Width(ui.MainStyle.GetWidth() * 8 / 10).
|
||||
BorderForeground(lipgloss.Color("#EEE"))
|
||||
BorderForeground(ui.PrimaryColor)
|
||||
SidePanelStyle = lipgloss.NewStyle().
|
||||
Border(lipgloss.NormalBorder(), true).
|
||||
Width(ui.MainStyle.GetWidth() * 2 / 10).
|
||||
BorderForeground(lipgloss.Color("#EEE"))
|
||||
BorderForeground(ui.PrimaryColor)
|
||||
|
||||
activeTabBorder = lipgloss.Border{
|
||||
Top: "─",
|
||||
@@ -46,7 +46,7 @@ var (
|
||||
BottomLeft: "┘",
|
||||
BottomRight: "└",
|
||||
}
|
||||
highlight = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "105"}
|
||||
|
||||
tabBorder = lipgloss.Border{
|
||||
Top: "─",
|
||||
Bottom: "─",
|
||||
@@ -82,28 +82,32 @@ var (
|
||||
|
||||
tab = lipgloss.NewStyle().
|
||||
Border(tabBorder, true).
|
||||
Foreground(ui.PrimaryColor).
|
||||
Padding(0, 1)
|
||||
|
||||
activeTab = tab.Copy().
|
||||
Border(activeTabBorder, true).
|
||||
BorderForeground(highlight).
|
||||
Foreground(lipgloss.Color("105")).
|
||||
BorderForeground(ui.AccentColor).
|
||||
Foreground(ui.AccentColor).
|
||||
Italic(true).
|
||||
Bold(true)
|
||||
|
||||
leftArrowDim = tab.Copy().
|
||||
Border(leftArrowBorder, true).
|
||||
Foreground(lipgloss.Color("#444"))
|
||||
BorderForeground(ui.PrimaryColor).
|
||||
Foreground(ui.ArrowsDimColor)
|
||||
rightArrowDim = tab.Copy().
|
||||
Border(rightArrowBorder, true).
|
||||
Foreground(lipgloss.Color("#444"))
|
||||
BorderForeground(ui.PrimaryColor).
|
||||
Foreground(ui.ArrowsDimColor)
|
||||
|
||||
leftArrowLit = tab.Copy().
|
||||
Border(leftArrowBorder, true).
|
||||
Foreground(lipgloss.Color("#FFF"))
|
||||
Foreground(ui.PrimaryColor)
|
||||
rightArrowLit = tab.Copy().
|
||||
Border(rightArrowBorder, true).
|
||||
Foreground(lipgloss.Color("#FFF"))
|
||||
Foreground(ui.PrimaryColor)
|
||||
|
||||
tabLine = lipgloss.NewStyle()
|
||||
tabLine = lipgloss.NewStyle().
|
||||
Foreground(ui.PrimaryColor)
|
||||
)
|
||||
|
||||
+14
-3
@@ -23,7 +23,18 @@ var (
|
||||
Width(0).
|
||||
Height(0)
|
||||
|
||||
CursorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("105"))
|
||||
FocusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("105"))
|
||||
NoStyle = lipgloss.NewStyle()
|
||||
AccentColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#1C6DD0",
|
||||
Light: "#1C6DD0",
|
||||
}
|
||||
|
||||
PrimaryColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#EEE",
|
||||
Light: "#151515",
|
||||
}
|
||||
|
||||
ArrowsDimColor = lipgloss.AdaptiveColor{
|
||||
Dark: "#444",
|
||||
Light: "#AAA",
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user