Skip to content

Commit 33a447d

Browse files
k3llymarieeDanny Olson
andauthored
feat: use tab to toggle, add final step (#50)
* Make styling consistent * Update title punctuation and capitalization * Add border around rendered markdown * use tab to toggle flag, add final congrats step * update wizard * quit when we've run out of models * no emojis :( * add placeholder cta to final step * different placeholder text --------- Co-authored-by: Danny Olson <dolson@launchdarkly.com>
1 parent 73ef41e commit 33a447d

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

internal/setup/flag_toggle.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2323
switch msg := msg.(type) {
2424
case tea.KeyMsg:
2525
switch {
26-
case key.Matches(msg, keys.Enter):
26+
case key.Matches(msg, keys.Toggle):
2727
m.enabled = !m.enabled
2828
}
2929
}
@@ -33,13 +33,13 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
3333

3434
func (m flagToggleModel) View() string {
3535
var furtherInstructions string
36-
title := "Toggle your feature flag!"
36+
title := "Toggle your feature flag (press tab)"
3737
toggle := "OFF"
3838
bgColor := "#646a73"
3939
margin := 1
4040
if m.enabled {
4141
bgColor = "#3d9c51"
42-
furtherInstructions = "\n\nCheck your [browser|application logs] to see the change."
42+
furtherInstructions = "\n\nCheck your [browser|application logs] to see the change!"
4343
margin = 2
4444
toggle = "ON"
4545
}

internal/setup/wizard.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/charmbracelet/bubbles/key"
77
tea "github.com/charmbracelet/bubbletea"
8+
"github.com/muesli/reflow/wordwrap"
89
)
910

1011
// TODO: we may want to rename this for clarity
@@ -102,7 +103,10 @@ func (m WizardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
102103
case flagToggleStep:
103104
updatedModel, _ := m.steps[flagToggleStep].Update(msg)
104105
m.steps[flagToggleStep] = updatedModel
106+
m.currStep += 1
105107
default:
108+
return m, tea.Quit
109+
106110
}
107111
case key.Matches(msg, keys.Back):
108112
// only go back if not on the first step
@@ -130,14 +134,19 @@ func (m WizardModel) View() string {
130134
return fmt.Sprintf("ERROR: %s", m.err)
131135
}
132136

137+
if m.currStep > flagToggleStep {
138+
return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application.\n\nNow that you’re set up with your first feature flag, let’s make it easier to manage your flags collaboratively with your team. <Instructions will go here>", m.width)
139+
}
140+
133141
return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps))
134142
}
135143

136144
type keyMap struct {
137-
Back key.Binding
138-
Enter key.Binding
139-
Help key.Binding
140-
Quit key.Binding
145+
Back key.Binding
146+
Enter key.Binding
147+
Help key.Binding
148+
Quit key.Binding
149+
Toggle key.Binding
141150
}
142151

143152
var keys = keyMap{
@@ -157,4 +166,8 @@ var keys = keyMap{
157166
key.WithKeys("ctrl+c", "q"),
158167
key.WithHelp("q", "quit"),
159168
),
169+
Toggle: key.NewBinding(
170+
key.WithKeys("tab"),
171+
key.WithHelp("tab", "toggle"),
172+
),
160173
}

0 commit comments

Comments
 (0)