summaryrefslogtreecommitdiff
path: root/internal/client/ui/auth/field
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-11-06 00:02:02 +0200
committerKyren223 <Kyren223@proton.me>2024-11-06 00:02:02 +0200
commit68635d49634fe83a6b495eed034e4ce7952e4ac6 (patch)
treeb2fc1e6ae19ca63a7c5bd740f9a38e38ef667d80 /internal/client/ui/auth/field
parentbdf7d2c2d2ee578edc3b6ecacbb9b0236e591b57 (diff)
feat: more UI design
Diffstat (limited to 'internal/client/ui/auth/field')
-rw-r--r--internal/client/ui/auth/field/field.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/internal/client/ui/auth/field/field.go b/internal/client/ui/auth/field/field.go
index afc55b1..623cdd6 100644
--- a/internal/client/ui/auth/field/field.go
+++ b/internal/client/ui/auth/field/field.go
@@ -1,20 +1,20 @@
package field
import (
- "strings"
-
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
-)
+ "github.com/kyren223/eko/internal/client/ui"
+)
type Model struct {
- Input textinput.Model
- Style lipgloss.Style
+ Input textinput.Model
+ Style lipgloss.Style
FocusedStyle lipgloss.Style
BlurredStyle lipgloss.Style
- ErrorStyle lipgloss.Style
+ ErrorStyle lipgloss.Style
+ Header string
}
func New(width int) Model {
@@ -37,15 +37,18 @@ func (m Model) Init() tea.Cmd {
}
func (m Model) View() string {
- var builder strings.Builder
-
- builder.WriteString(m.Style.Render(m.Input.View()))
- builder.WriteRune('\n')
+ style := m.Style
+ error := ""
if m.Input.Err != nil {
- builder.WriteString(m.ErrorStyle.Render(m.Input.Err.Error()))
+ error = m.Input.Err.Error()
+ style = style.BorderForeground(m.ErrorStyle.GetForeground())
}
+ field := ui.AddBorderHeader(m.Header, 1, style, m.Input.View())
+
+ error = m.ErrorStyle.MaxWidth(lipgloss.Width(field)).Render(error)
- return builder.String()
+ // return lipgloss.JoinVertical(lipgloss.Left, borderTop, field, error)
+ return lipgloss.JoinVertical(lipgloss.Left, field, error)
}
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {