Skip to content

Commit eec5dc7

Browse files
committed
chore: refactor styling
1 parent f613693 commit eec5dc7

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

models/homepage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (m *Homepage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4747
}
4848
view := styles.RenderPrompt("Please set up a Gas Station account", []string{"Gas Station account"}, styles.Question) +
4949
" " + styles.Text("(The account that will hold the funds required by the OPinit-bots or relayer to send transactions)", styles.Gray) +
50-
"\n> " + styles.Text(input.Text, styles.White)
50+
"\n> " + styles.Text(input.Text, styles.Ivory)
5151
model := NewHomepageInitialization(view)
5252
return model, model.Init()
5353
}

styles/color.go

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ type HexColor string
44

55
const (
66
White HexColor = "#FFFFFF"
7+
Ivory HexColor = "#EEEEEE"
78
Cyan HexColor = "#27D8FF"
89
Green HexColor = "#B0EE5F"
910
Gray HexColor = "#808080"

styles/text.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var (
6969

7070
// RenderPrompt highlights phrases in the text if they match any phrase in the highlights list
7171
func RenderPrompt(text string, highlights []string, status PromptStatus) string {
72-
prompt := ""
72+
prompt := "\n"
7373
switch status {
7474
case Question:
7575
prompt += QuestionMark
@@ -85,7 +85,7 @@ func RenderPrompt(text string, highlights []string, status PromptStatus) string
8585
// Apply Cyan color to the matching highlight
8686
coloredHighlight := ""
8787
if status == Information {
88-
coloredHighlight = BoldText(highlight, White)
88+
coloredHighlight = BoldText(highlight, Ivory)
8989
} else {
9090
coloredHighlight = BoldText(highlight, Cyan)
9191
}

utils/selector.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ func (s *Selector[T]) Select(msg tea.Msg) (*T, tea.Cmd) {
3232
}
3333

3434
func (s *Selector[T]) View() string {
35-
view := "\n"
35+
view := "\n\n"
3636
for i, option := range s.Options {
3737
if i == s.Cursor {
3838
view += styles.SelectorCursor + styles.BoldText(fmt.Sprintf("%v", option), styles.White) + "\n"
3939
} else {
40-
view += " " + styles.Text(fmt.Sprintf("%v", option), styles.White) + "\n"
40+
view += " " + styles.Text(fmt.Sprintf("%v", option), styles.Ivory) + "\n"
4141
}
4242
}
4343

44-
return view + "Press Enter to select, or q to quit.\n"
44+
return view + styles.Text("\nPress Enter to select, or q to quit.\n", styles.Gray)
4545
}

utils/text_input.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,18 @@ func (ti TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd, bool) {
5454
func (ti TextInput) View() string {
5555
var beforeCursor, cursorChar, afterCursor string
5656
if len(ti.Text) == 0 {
57-
return "\n> " + styles.Text(ti.Placeholder, styles.Gray) + styles.Cursor(" ") + "\n\nPress Enter to submit, or Ctrl+c to quit."
57+
return "\n" + styles.Text("> ", styles.Yellow) + styles.Text(ti.Placeholder, styles.Gray) + styles.Cursor(" ") + "\n\nPress Enter to submit, or Ctrl+c to quit."
5858
} else if ti.Cursor < len(ti.Text) {
5959
// Cursor is within the text
60-
beforeCursor = styles.Text(ti.Text[:ti.Cursor], styles.White)
60+
beforeCursor = styles.Text(ti.Text[:ti.Cursor], styles.Ivory)
6161
cursorChar = styles.Cursor(ti.Text[ti.Cursor : ti.Cursor+1])
62-
afterCursor = styles.Text(ti.Text[ti.Cursor+1:], styles.White)
62+
afterCursor = styles.Text(ti.Text[ti.Cursor+1:], styles.Ivory)
6363
} else {
6464
// Cursor is at the end of the text
65-
beforeCursor = styles.Text(ti.Text, styles.White)
65+
beforeCursor = styles.Text(ti.Text, styles.Ivory)
6666
cursorChar = styles.Cursor(" ")
6767
}
6868

6969
// Compose the full view string
70-
return fmt.Sprintf("\n> %s%s%s\n\nPress Enter to submit, or Ctrl+c to quit.", beforeCursor, cursorChar, afterCursor)
70+
return fmt.Sprintf("\n%s %s%s%s\n\nPress Enter to submit, or Ctrl+c to quit.", styles.Text(">", styles.Yellow), beforeCursor, cursorChar, afterCursor)
7171
}

0 commit comments

Comments
 (0)