summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/client/client.go3
-rw-r--r--internal/client/ui/auth/auth.go31
-rw-r--r--internal/client/ui/colors/colors.go26
-rw-r--r--internal/client/ui/core/networkcreation/networkcreation.go22
-rw-r--r--internal/client/ui/ui.go3
5 files changed, 56 insertions, 29 deletions
diff --git a/internal/client/client.go b/internal/client/client.go
index ec760dd..c5fc8a9 100644
--- a/internal/client/client.go
+++ b/internal/client/client.go
@@ -13,6 +13,7 @@ import (
"github.com/kyren223/eko/internal/client/config"
"github.com/kyren223/eko/internal/client/ui"
"github.com/kyren223/eko/internal/client/ui/auth"
+ "github.com/kyren223/eko/internal/client/ui/colors"
"github.com/kyren223/eko/pkg/assert"
)
@@ -46,7 +47,7 @@ func Run() {
// I am not aware of a way to query the current background color (to revert this)
// Ideally bubbletea will handle the setting/reventing, for now it's fine
// It only changes the current pane so new terminal panes/windows are not affected.
- termenv.DefaultOutput().SetBackgroundColor(termenv.RGBColor(ui.BackgroundColor))
+ termenv.DefaultOutput().SetBackgroundColor(termenv.RGBColor(colors.ToHex(colors.Background)))
program := tea.NewProgram(initialModel(dump), tea.WithAltScreen())
assert.AddFlush(BubbleTeaCloser{program})
diff --git a/internal/client/ui/auth/auth.go b/internal/client/ui/auth/auth.go
index 363daf1..42ea3e5 100644
--- a/internal/client/ui/auth/auth.go
+++ b/internal/client/ui/auth/auth.go
@@ -19,6 +19,7 @@ import (
"github.com/kyren223/eko/internal/client/config"
"github.com/kyren223/eko/internal/client/ui"
"github.com/kyren223/eko/internal/client/ui/choicepopup"
+ "github.com/kyren223/eko/internal/client/ui/colors"
"github.com/kyren223/eko/internal/client/ui/core"
authfield "github.com/kyren223/eko/internal/client/ui/field"
"github.com/kyren223/eko/pkg/assert"
@@ -34,24 +35,24 @@ const (
)
var (
- grayStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
- focusedStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#5874FF"))
- cursorStyle = focusedStyle
- noStyle = lipgloss.NewStyle()
- errorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#F16265"))
+ grayStyle = lipgloss.NewStyle().Foreground(colors.Gray)
+ focusedStyle = lipgloss.NewStyle().Foreground(colors.Focus)
+ errorStyle = lipgloss.NewStyle().Foreground(colors.Error)
fieldBlurredStyle = lipgloss.NewStyle().
PaddingLeft(1).
Border(lipgloss.RoundedBorder()).
- BorderForeground(lipgloss.Color("#007E8A"))
- fieldFocusedStyle = fieldBlurredStyle.BorderForeground(focusedStyle.GetForeground()).Border(lipgloss.ThickBorder())
+ BorderForeground(colors.DarkCyan)
+ fieldFocusedStyle = fieldBlurredStyle.
+ BorderForeground(focusedStyle.GetForeground()).
+ Border(lipgloss.ThickBorder())
focusedSignupButton = focusedStyle.Bold(true).Render("[ SIGN-UP ]")
focusedSigninButton = focusedStyle.Bold(true).Render("[ SIGN-IN ]")
blurredSignupButton = fmt.Sprintf("[ %s ]", grayStyle.Render("sign-up"))
blurredSigninButton = fmt.Sprintf("[ %s ]", grayStyle.Render("sign-in"))
- headerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#54D7A9"))
+ headerStyle = lipgloss.NewStyle().Foreground(colors.Turquoise)
titleStyle = focusedStyle.Width(authWidth).Bold(true).AlignHorizontal(lipgloss.Center)
signupTitle = titleStyle.Render(`
@@ -68,13 +69,13 @@ ___] | |__] | \| | | \|`)
concealIcon = lipgloss.NewStyle().PaddingLeft(1).Render("󰈉 ")
popupStyle = lipgloss.NewStyle().Border(lipgloss.ThickBorder())
- choiceSelectedStyle = lipgloss.NewStyle().Background(lipgloss.Color("#0029f5")).Padding(0, 1).Margin(0, 1)
- choiceUnselectedStyle = lipgloss.NewStyle().Background(grayStyle.GetForeground()).Padding(0, 1).Margin(0, 1)
+ choiceSelectedStyle = lipgloss.NewStyle().Padding(0, 1).Margin(0, 1).Background(colors.Blue)
+ choiceUnselectedStyle = lipgloss.NewStyle().Padding(0, 1).Margin(0, 1).Background(colors.Gray)
- focusedRememberChecked = focusedStyle.Render("[x] Remember")
- focusedRememberUnchecked = focusedStyle.Render("[ ] Remember")
blurredRememberChecked = "[x] Remember"
blurredRememberUnchecked = "[ ] Remember"
+ focusedRememberChecked = focusedStyle.Render(blurredRememberChecked)
+ focusedRememberUnchecked = focusedStyle.Render(blurredRememberUnchecked)
centerStyle = lipgloss.NewStyle().Width(authWidth).AlignHorizontal(0.5)
)
@@ -96,12 +97,12 @@ func New() Model {
for i := range m.fields {
field := authfield.New(48)
- field.Input.Cursor.Style = cursorStyle
+ field.Input.Cursor.Style = focusedStyle
field.BlurredStyle = fieldBlurredStyle
field.FocusedStyle = fieldFocusedStyle
field.ErrorStyle = errorStyle
field.FocusedTextStyle = focusedStyle
- field.BlurredTextStyle = noStyle
+ field.BlurredTextStyle = lipgloss.NewStyle()
switch i {
case usernameField:
@@ -220,7 +221,7 @@ func (m Model) View() string {
result = lipgloss.NewStyle().
Border(lipgloss.RoundedBorder()).
- BorderForeground(lipgloss.Color("#007E8A")).
+ BorderForeground(colors.DarkCyan).
Render(result)
result = lipgloss.Place(
diff --git a/internal/client/ui/colors/colors.go b/internal/client/ui/colors/colors.go
new file mode 100644
index 0000000..0c38720
--- /dev/null
+++ b/internal/client/ui/colors/colors.go
@@ -0,0 +1,26 @@
+package colors
+
+import (
+ "fmt"
+
+ "github.com/charmbracelet/lipgloss"
+)
+
+var (
+ Gray = lipgloss.Color("240")
+ LightBlue = lipgloss.Color("#5874FF")
+ Blue = lipgloss.Color("#0029f5")
+ DarkCyan = lipgloss.Color("#007E8A")
+ DarkMidnightBlue = lipgloss.Color("#1E1E2E")
+ Turquoise = lipgloss.Color("#54D7A9")
+ Red = lipgloss.Color("#F16265")
+
+ Background = DarkMidnightBlue
+ Error = Red
+ Focus = LightBlue
+)
+
+func ToHex(color lipgloss.Color) string {
+ r, g, b, _ := color.RGBA()
+ return fmt.Sprintf("#%02X%02X%02X", r>>8, g>>8, b>>8)
+}
diff --git a/internal/client/ui/core/networkcreation/networkcreation.go b/internal/client/ui/core/networkcreation/networkcreation.go
index 08f85a3..b6324e0 100644
--- a/internal/client/ui/core/networkcreation/networkcreation.go
+++ b/internal/client/ui/core/networkcreation/networkcreation.go
@@ -4,25 +4,27 @@ import (
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
+ "github.com/kyren223/eko/internal/client/ui/colors"
"github.com/kyren223/eko/internal/client/ui/field"
)
var (
- style = lipgloss.NewStyle().Border(lipgloss.ThickBorder())
- focusColor = lipgloss.Color("#5874FF")
-
- focusedStyle = lipgloss.NewStyle().Foreground(focusColor)
+ style = lipgloss.NewStyle().Border(lipgloss.ThickBorder())
+ focusedStyle = lipgloss.NewStyle().Foreground(colors.Focus)
+ headerStyle = lipgloss.NewStyle().Foreground(colors.Turquoise)
fieldBlurredStyle = lipgloss.NewStyle().
PaddingLeft(1).
Border(lipgloss.RoundedBorder()).
- BorderForeground(lipgloss.Color("#007E8A"))
- fieldFocusedStyle = fieldBlurredStyle.BorderForeground(focusedStyle.GetForeground()).Border(lipgloss.ThickBorder())
-
- headerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#54D7A9"))
+ BorderForeground(colors.DarkCyan)
+ fieldFocusedStyle = fieldBlurredStyle.
+ BorderForeground(colors.Focus).
+ Border(lipgloss.ThickBorder())
- blurredUnderlineStyle = lipgloss.NewStyle().Border(lipgloss.ThickBorder(), false, false, true, false).BorderForeground(lipgloss.Color("240"))
- focusedUnderlineStyle = blurredUnderlineStyle.BorderForeground(focusColor)
+ blurredUnderlineStyle = lipgloss.NewStyle().
+ Border(lipgloss.ThickBorder(), false, false, true, false).
+ BorderForeground(colors.Gray)
+ focusedUnderlineStyle = blurredUnderlineStyle.BorderForeground(colors.Focus)
)
const (
diff --git a/internal/client/ui/ui.go b/internal/client/ui/ui.go
index 762d0b6..4b2149d 100644
--- a/internal/client/ui/ui.go
+++ b/internal/client/ui/ui.go
@@ -19,9 +19,6 @@ const DEBUG = true
var Width int
var Height int
-var BackgroundColor = "#1E1E2E"
-var Background = lipgloss.Color(BackgroundColor)
-var Style = lipgloss.NewStyle().Background(Background)
var Program *tea.Program
type ModelTransition struct {