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