From 98483972443b4093d9ec5dff9eacec4a7800ea62 Mon Sep 17 00:00:00 2001 From: Danny Olson Date: Thu, 21 Mar 2024 09:41:15 -0700 Subject: [PATCH 1/9] Make styling consistent --- internal/setup/flags.go | 10 ++++++---- internal/setup/sdk_instructions.go | 2 +- internal/setup/sdks.go | 14 ++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/setup/flags.go b/internal/setup/flags.go index 7d2fe380..36e37213 100644 --- a/internal/setup/flags.go +++ b/internal/setup/flags.go @@ -2,6 +2,7 @@ package setup import ( "fmt" + "github.com/charmbracelet/bubbles/key" "github.com/charmbracelet/bubbles/list" "github.com/charmbracelet/bubbles/textinput" @@ -27,7 +28,6 @@ func (p flag) FilterValue() string { return "" } type flagModel struct { input string - err error textInput textinput.Model } @@ -69,9 +69,11 @@ func (m flagModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m flagModel) View() string { + style := lipgloss.NewStyle(). + MarginLeft(2) + return fmt.Sprintf( - "Name your first feature flag (enter for default value):\n\n%s\n\n%s", - m.textInput.View(), - "(esc to quit)", + "Name your first feature flag (enter for default value):\n\n%s", + style.Render(m.textInput.View()), ) + "\n" } diff --git a/internal/setup/sdk_instructions.go b/internal/setup/sdk_instructions.go index b33444b6..d097cbdc 100644 --- a/internal/setup/sdk_instructions.go +++ b/internal/setup/sdk_instructions.go @@ -32,7 +32,7 @@ func (m sdkInstructionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m sdkInstructionModel) View() string { return wordwrap.String( fmt.Sprintf( - "Set up your application. Here are the steps to incorporate the LaunchDarkly %s SDK into your code. \n\n%s", + "Set up your application. Here are the steps to incorporate the LaunchDarkly %s SDK into your code.\n%s", m.name, m.renderMarkdown(), ), diff --git a/internal/setup/sdks.go b/internal/setup/sdks.go index 725a0fe4..d6a0292a 100644 --- a/internal/setup/sdks.go +++ b/internal/setup/sdks.go @@ -26,10 +26,8 @@ type sdk struct { func (s sdk) FilterValue() string { return "" } type sdkModel struct { - choice sdk - instructions string - err error - list list.Model + choice sdk + list list.Model } const sdkInstructionsFilePath = "internal/setup/sdk_build_instructions/" @@ -75,7 +73,11 @@ func NewSdk() tea.Model { } l := list.New(sdksToItems(sdks), sdkDelegate{}, 30, 14) - l.Title = "Select your SDK." + l.Title = "Select your SDK\n" + // reset title styles + l.Styles.Title = lipgloss.NewStyle() + l.Styles.TitleBar = lipgloss.NewStyle() + l.SetShowPagination(true) l.SetShowStatusBar(false) l.SetFilteringEnabled(false) l.Paginator.PerPage = 5 @@ -111,7 +113,7 @@ func (m sdkModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m sdkModel) View() string { - return "\n" + m.list.View() + return m.list.View() } type sdkDelegate struct{} From 18e1dc4d3b3a26ac64095c87baf63ea71e4e8326 Mon Sep 17 00:00:00 2001 From: Danny Olson Date: Thu, 21 Mar 2024 09:58:29 -0700 Subject: [PATCH 2/9] Update title punctuation and capitalization --- internal/setup/flag_toggle.go | 2 +- internal/setup/sdks.go | 2 +- internal/setup/wizard.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/setup/flag_toggle.go b/internal/setup/flag_toggle.go index 365b181a..dc261452 100644 --- a/internal/setup/flag_toggle.go +++ b/internal/setup/flag_toggle.go @@ -39,7 +39,7 @@ func (m flagToggleModel) View() string { margin := 1 if m.enabled { bgColor = "#3d9c51" - furtherInstructions = "\n\nCheck your [browser|application logs] to see the change!" + furtherInstructions = "\n\nCheck your [browser|application logs] to see the change." margin = 2 toggle = "ON" } diff --git a/internal/setup/sdks.go b/internal/setup/sdks.go index d6a0292a..b6192d3b 100644 --- a/internal/setup/sdks.go +++ b/internal/setup/sdks.go @@ -73,7 +73,7 @@ func NewSdk() tea.Model { } l := list.New(sdksToItems(sdks), sdkDelegate{}, 30, 14) - l.Title = "Select your SDK\n" + l.Title = "Select your SDK:\n" // reset title styles l.Styles.Title = lipgloss.NewStyle() l.Styles.TitleBar = lipgloss.NewStyle() diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index 510e5fa0..cc9e211d 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -130,7 +130,7 @@ func (m WizardModel) View() string { return fmt.Sprintf("ERROR: %s", m.err) } - return fmt.Sprintf("\nstep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) + return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) } type keyMap struct { From 5dc7a94b8f6a55ac7eec28d4bd8b1e130b0db32e Mon Sep 17 00:00:00 2001 From: Danny Olson Date: Thu, 21 Mar 2024 09:58:54 -0700 Subject: [PATCH 3/9] Add border around rendered markdown --- internal/setup/sdk_instructions.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/setup/sdk_instructions.go b/internal/setup/sdk_instructions.go index d097cbdc..ecf304a4 100644 --- a/internal/setup/sdk_instructions.go +++ b/internal/setup/sdk_instructions.go @@ -7,6 +7,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/glamour" + "github.com/charmbracelet/lipgloss" "github.com/muesli/reflow/wordwrap" ) @@ -30,11 +31,13 @@ func (m sdkInstructionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m sdkInstructionModel) View() string { + style := lipgloss.NewStyle().Border(lipgloss.NormalBorder()) + return wordwrap.String( fmt.Sprintf( "Set up your application. Here are the steps to incorporate the LaunchDarkly %s SDK into your code.\n%s", m.name, - m.renderMarkdown(), + style.Render(m.renderMarkdown()), ), m.width, ) From 3cd6b5dcf8c5ef7cdee718e83fd9e2baaa8501d8 Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 10:46:17 -0700 Subject: [PATCH 4/9] use tab to toggle flag, add final congrats step --- internal/setup/flag_toggle.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/setup/flag_toggle.go b/internal/setup/flag_toggle.go index dc261452..eff0ce39 100644 --- a/internal/setup/flag_toggle.go +++ b/internal/setup/flag_toggle.go @@ -23,7 +23,7 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch { - case key.Matches(msg, keys.Enter): + case key.Matches(msg, keys.Toggle): m.enabled = !m.enabled } } @@ -33,13 +33,13 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m flagToggleModel) View() string { var furtherInstructions string - title := "Toggle your feature flag!" + title := "Toggle your feature flag (press tab)" toggle := "OFF" bgColor := "#646a73" margin := 1 if m.enabled { bgColor = "#3d9c51" - furtherInstructions = "\n\nCheck your [browser|application logs] to see the change." + furtherInstructions = "\n\nCheck your [browser|application logs] to see the change ✨" margin = 2 toggle = "ON" } From 94f41da3bacb7892142dad4070d792d55df1ed50 Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 10:46:49 -0700 Subject: [PATCH 5/9] update wizard --- internal/setup/wizard.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index cc9e211d..97ce13a1 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -5,6 +5,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" + "github.com/muesli/reflow/wordwrap" ) // TODO: we may want to rename this for clarity @@ -102,7 +103,12 @@ func (m WizardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case flagToggleStep: updatedModel, _ := m.steps[flagToggleStep].Update(msg) m.steps[flagToggleStep] = updatedModel + m.currStep += 1 default: + m.currStep += 1 + if m.currStep > flagToggleStep+1 { + return m, tea.Quit + } } case key.Matches(msg, keys.Back): // only go back if not on the first step @@ -130,14 +136,19 @@ func (m WizardModel) View() string { return fmt.Sprintf("ERROR: %s", m.err) } + if m.currStep > flagToggleStep { + return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application 🎉", m.width) + } + return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) } type keyMap struct { - Back key.Binding - Enter key.Binding - Help key.Binding - Quit key.Binding + Back key.Binding + Enter key.Binding + Help key.Binding + Quit key.Binding + Toggle key.Binding } var keys = keyMap{ @@ -157,4 +168,8 @@ var keys = keyMap{ key.WithKeys("ctrl+c", "q"), key.WithHelp("q", "quit"), ), + Toggle: key.NewBinding( + key.WithKeys("tab"), + key.WithHelp("tab", "toggle"), + ), } From 617ef4508b840083de20cd3a0323ee1da153136c Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 10:51:00 -0700 Subject: [PATCH 6/9] quit when we've run out of models --- internal/setup/wizard.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index 97ce13a1..788f7f92 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -105,10 +105,8 @@ func (m WizardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.steps[flagToggleStep] = updatedModel m.currStep += 1 default: - m.currStep += 1 - if m.currStep > flagToggleStep+1 { - return m, tea.Quit - } + return m, tea.Quit + } case key.Matches(msg, keys.Back): // only go back if not on the first step From 0ac9fc1b93903ff5018f61b034a852aea310ea28 Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 11:05:04 -0700 Subject: [PATCH 7/9] no emojis :( --- internal/setup/flag_toggle.go | 2 +- internal/setup/wizard.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/setup/flag_toggle.go b/internal/setup/flag_toggle.go index eff0ce39..21d7856b 100644 --- a/internal/setup/flag_toggle.go +++ b/internal/setup/flag_toggle.go @@ -39,7 +39,7 @@ func (m flagToggleModel) View() string { margin := 1 if m.enabled { bgColor = "#3d9c51" - furtherInstructions = "\n\nCheck your [browser|application logs] to see the change ✨" + furtherInstructions = "\n\nCheck your [browser|application logs] to see the change!" margin = 2 toggle = "ON" } diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index 788f7f92..a6488e9b 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -135,7 +135,7 @@ func (m WizardModel) View() string { } if m.currStep > flagToggleStep { - return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application 🎉", m.width) + return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application.", m.width) } return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) From 38daa3cf34a827f575acb6aaad9d3ebf158419f1 Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 11:28:34 -0700 Subject: [PATCH 8/9] add placeholder cta to final step --- internal/setup/wizard.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index a6488e9b..cc816ef9 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -135,7 +135,7 @@ func (m WizardModel) View() string { } if m.currStep > flagToggleStep { - return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application.", m.width) + 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, let’s get you going with ________.", m.width) } return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) From 79361e97023d0f2246e42d93fb42bd20e8865157 Mon Sep 17 00:00:00 2001 From: Kelly Hofmann Date: Thu, 21 Mar 2024 11:35:08 -0700 Subject: [PATCH 9/9] different placeholder text --- internal/setup/wizard.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index cc816ef9..868d0f01 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -135,7 +135,7 @@ func (m WizardModel) View() string { } if m.currStep > flagToggleStep { - 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, let’s get you going with ________.", m.width) + 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. ", m.width) } return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps))