Skip to content

Commit dc94895

Browse files
committed
chore: add completed state with faded text
1 parent ce7d0b8 commit dc94895

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

models/homepage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (m *Homepage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4949
}
5050

5151
func (m *Homepage) View() string {
52-
view := styles.FadeText("Welcome to Weave! 🪢 CLI for managing Initia deployments.\n\n")
52+
view := styles.FadeText("\nWelcome to Weave! 🪢 CLI for managing Initia deployments.\n")
5353
view += styles.RenderPrompt("What would you like to do today?", []string{}, styles.Question) + m.Selector.View()
5454
return view
5555
}

models/weaveinit/run_l1_node.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ func NewMinGasPriceInput(state *RunL1NodeState) *MinGasPriceInput {
304304
model := &MinGasPriceInput{
305305
TextInput: utils.NewTextInput(),
306306
state: state,
307-
question: "Please specify min-gas-price (uinit)",
307+
question: "Please specify min-gas-price",
308308
}
309+
model.WithPlaceholder("add a number with denom")
309310
model.WithValidatorFn(utils.ValidateDecCoin)
310311
return model
311312
}
@@ -330,9 +331,9 @@ func (m *MinGasPriceInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
330331
}
331332

332333
func (m *MinGasPriceInput) View() string {
333-
preText := ""
334+
preText := "\n"
334335
if !m.state.existingApp {
335-
preText += styles.RenderPrompt("There is no config/app.toml or config/config.toml available. You will need to enter the required information to proceed.\n\n", []string{"config/app.toml", "config/config.toml"}, styles.Information)
336+
preText += styles.RenderPrompt("There is no config/app.toml or config/config.toml available. You will need to enter the required information to proceed.\n", []string{"config/app.toml", "config/config.toml"}, styles.Information)
336337
}
337338
return m.state.weave.PreviousResponse + preText + styles.RenderPrompt(m.GetQuestion(), []string{"min-gas-price"}, styles.Question) + m.TextInput.View()
338339
}
@@ -393,7 +394,7 @@ func (m *EnableFeaturesCheckbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
393394
}
394395

395396
func (m *EnableFeaturesCheckbox) View() string {
396-
return m.state.weave.PreviousResponse + "\n" + styles.RenderPrompt(m.GetQuestion(), []string{}, styles.Question) + "\n" + m.CheckBox.View()
397+
return m.state.weave.PreviousResponse + styles.RenderPrompt(m.GetQuestion(), []string{}, styles.Question) + "\n" + m.CheckBox.View()
397398
}
398399

399400
type SeedsInput struct {
@@ -408,6 +409,7 @@ func NewSeedsInput(state *RunL1NodeState) *SeedsInput {
408409
state: state,
409410
question: "Please specify the seeds",
410411
}
412+
model.WithPlaceholder("add in the format id@ip:port, you can add multiple seeds by adding comma (,)")
411413
model.WithValidatorFn(utils.IsValidPeerOrSeed)
412414
return model
413415
}
@@ -447,6 +449,7 @@ func NewPersistentPeersInput(state *RunL1NodeState) *PersistentPeersInput {
447449
state: state,
448450
question: "Please specify the persistent_peers",
449451
}
452+
model.WithPlaceholder("add in the format id@ip:port, you can add multiple seeds by adding comma (,)")
450453
model.WithValidatorFn(utils.IsValidPeerOrSeed)
451454
return model
452455
}
@@ -628,9 +631,9 @@ func (m *GenesisEndpointInput) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
628631
}
629632

630633
func (m *GenesisEndpointInput) View() string {
631-
preText := ""
634+
preText := "\n"
632635
if !m.state.existingApp {
633-
preText += styles.RenderPrompt("There is no config/genesis.json available. You will need to enter the required information to proceed.\n\n", []string{"config/genesis.json"}, styles.Information)
636+
preText += styles.RenderPrompt("There is no config/genesis.json available. You will need to enter the required information to proceed.\n", []string{"config/genesis.json"}, styles.Information)
634637
}
635638
return m.state.weave.PreviousResponse + preText + styles.RenderPrompt(m.GetQuestion(), []string{"endpoint"}, styles.Question) + m.TextInput.View()
636639
}
@@ -655,7 +658,7 @@ func (m *InitializingAppLoading) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
655658
loader, cmd := m.Loading.Update(msg)
656659
m.Loading = loader
657660
if m.Loading.Completing {
658-
m.state.weave.PreviousResponse += styles.RenderPreviousResponse(styles.NoSeparator, "Initialization successful.", []string{}, "")
661+
m.state.weave.PreviousResponse += styles.RenderPrompt("Initialization successful.\n", []string{}, styles.Completed)
659662
switch m.state.network {
660663
case string(Local):
661664
return m, tea.Quit

styles/text.go

+17-9
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ type PromptStatus string
8585

8686
const (
8787
Empty PromptStatus = "empty"
88-
Completed PromptStatus = "completed"
88+
Checked PromptStatus = "checked"
8989
Question PromptStatus = "question"
9090
Information PromptStatus = "information"
91+
Completed PromptStatus = "completed"
9192
)
9293

9394
var (
@@ -100,23 +101,30 @@ var (
100101
// RenderPrompt highlights phrases in the text if they match any phrase in the highlights list
101102
func RenderPrompt(text string, highlights []string, status PromptStatus) string {
102103
prompt := ""
104+
if status == Question {
105+
prompt += "\n"
106+
}
103107
switch status {
104108
case Question:
105109
prompt += QuestionMark
106-
case Completed:
110+
case Checked:
107111
prompt += CorrectMark
108112
case Information:
109113
prompt += InformationMark
114+
case Completed:
115+
prompt += CorrectMark
110116
}
111117

112-
for _, highlight := range highlights {
113-
if strings.Contains(text, highlight) {
114-
text = strings.ReplaceAll(text, highlight, BoldText(highlight, Cyan))
118+
if status != Completed {
119+
for _, highlight := range highlights {
120+
if strings.Contains(text, highlight) {
121+
text = strings.ReplaceAll(text, highlight, BoldText(highlight, Cyan))
122+
}
115123
}
124+
text = DefaultTextWithoutOverridingStyledText(text)
125+
} else {
126+
text = FadeText(text)
116127
}
117-
118-
text = DefaultTextWithoutOverridingStyledText(text)
119-
120128
return prompt + text
121129
}
122130

@@ -162,7 +170,7 @@ var (
162170
)
163171

164172
func RenderPreviousResponse(separator string, question string, highlights []string, answer string) string {
165-
return RenderPrompt(question, highlights, Completed) + separator + answer + "\n"
173+
return RenderPrompt(question, highlights, Checked) + separator + answer + "\n"
166174
}
167175

168176
func RenderError(err error) string {

utils/text_input.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func (ti *TextInput) WithValidatorFn(fn func(string) error) {
2828
ti.ValidationFn = fn
2929
}
3030

31+
func (ti *TextInput) WithPlaceholder(placeholder string) {
32+
ti.Placeholder = placeholder
33+
}
34+
3135
func (ti TextInput) Update(msg tea.Msg) (TextInput, tea.Cmd, bool) {
3236
switch msg := msg.(type) {
3337
case tea.KeyMsg:
@@ -71,12 +75,12 @@ func (ti TextInput) View() string {
7175
return "\n" + styles.Text("> ", styles.Cyan) + styles.Text(ti.Placeholder, styles.Gray) + styles.Cursor(" ") + "\n\n" + bottomText
7276
} else if ti.Cursor < len(ti.Text) {
7377
// Cursor is within the text
74-
beforeCursor = styles.Text(ti.Text[:ti.Cursor], styles.Ivory)
78+
beforeCursor = styles.Text(ti.Text[:ti.Cursor], styles.White)
7579
cursorChar = styles.Cursor(ti.Text[ti.Cursor : ti.Cursor+1])
76-
afterCursor = styles.Text(ti.Text[ti.Cursor+1:], styles.Ivory)
80+
afterCursor = styles.Text(ti.Text[ti.Cursor+1:], styles.White)
7781
} else {
7882
// Cursor is at the end of the text
79-
beforeCursor = styles.Text(ti.Text, styles.Ivory)
83+
beforeCursor = styles.Text(ti.Text, styles.White)
8084
cursorChar = styles.Cursor(" ")
8185
}
8286

utils/validate.go

+1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ func IsValidPeerOrSeed(addresses string) error {
207207
}
208208
}
209209

210+
// TODO add in error that id need to bbe 40 chars
210211
if len(invalidAddresses) > 0 {
211212
// Return an error with detailed messages
212213
return errors.New("invalid peer/seed addresses:" + strings.Join(invalidAddresses, ","))

0 commit comments

Comments
 (0)