From 5044b31cff4da982b200f8fc8109fb4e4549b5e3 Mon Sep 17 00:00:00 2001 From: Robin Olsen Date: Tue, 17 Feb 2026 17:29:00 +0100 Subject: [PATCH] style intro better add info and disclaimer --- cmd/survey/intro.go | 118 ++++++++++++++++++++++++++++++++------- go.mod | 1 + go.sum | 3 +- internal/style/styles.go | 2 +- 4 files changed, 101 insertions(+), 23 deletions(-) diff --git a/cmd/survey/intro.go b/cmd/survey/intro.go index 840d631..32553a9 100644 --- a/cmd/survey/intro.go +++ b/cmd/survey/intro.go @@ -2,26 +2,63 @@ package main import ( "errors" + "strings" + "github.com/LazyBachelor/LazyPM/internal/style" + "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" ) var ErrUserQuit = errors.New("user quit") +const stages = 2 + const ( - IntroTitle = "Welcome to the Task Survey!" + IntroTitle = "✦ Project Managment Interface Survey ✦" - IntroductionText = `This survey is designed to gather feedback on task management interfaces. -Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes. -By participating, you consent to the collection and use of your data as described in this disclaimer. + IntroductionText = `Welcome! This survey gathers feedback on task management interfaces. -Press any key to continue...` +Your responses will help us improve our services. All data is anonymized +and used solely for research purposes. - Disclaimer = `This survey is designed to gather feedback on task management interfaces. -Your responses will help us improve our services. Please note that all data collected will be anonymized and used solely for research purposes. -By participating, you consent to the collection and use of your data as described in this disclaimer.` +By participating, you consent to data collection as described below.` + + Disclaimer = `📋 Data Collection Notice + +• All responses are completely anonymized +• Data is used for research purposes only +• No personally identifiable information is collected +• You may exit at any time by pressing Esc +• We get no data unless you complete the survey and submit.` ) +type keyMap struct { + Start key.Binding + Continue key.Binding + Back key.Binding + Quit key.Binding +} + +var keys = keyMap{ + Start: key.NewBinding( + key.WithKeys("enter"), + key.WithHelp("enter", "start survey"), + ), + Continue: key.NewBinding( + key.WithKeys(" ", "j", "l", "down", "right"), + key.WithHelp("space", "continue"), + ), + Back: key.NewBinding( + key.WithKeys("b", "k", "h", "backspace", "up", "left"), + key.WithHelp("b", "back"), + ), + Quit: key.NewBinding( + key.WithKeys("esc", "ctrl+c", "q"), + key.WithHelp("esc", "quit"), + ), +} + type introModel struct { stage int width, height int @@ -30,7 +67,7 @@ type introModel struct { func newIntroModel() introModel { return introModel{ - stage: 0, + stage: 1, } } @@ -54,13 +91,19 @@ func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.WindowSizeMsg: m.SetSize(msg.Width, msg.Height) case tea.KeyMsg: - switch msg.Type { - case tea.KeyEnter, tea.KeySpace: - m.stage++ - if m.stage > 1 { - return m, tea.Quit + switch { + case key.Matches(msg, keys.Start) && m.stage == stages: + return m, tea.Quit + case key.Matches(msg, keys.Continue): + if m.stage < stages { + m.stage++ } - case tea.KeyEsc, tea.KeyCtrlC: + case key.Matches(msg, keys.Back): + if m.stage > 1 { + m.stage-- + } + return m, nil + case key.Matches(msg, keys.Quit): m.userQuit = true return m, tea.Quit } @@ -70,13 +113,46 @@ func (m introModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m introModel) View() string { - switch m.stage { - case 0: - return IntroductionText - case 1: - return Disclaimer + if m.width < 55 || m.height < 16 { + return lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, "Terminal too small.") } - return "" + + var content string + switch m.stage { + case 1: + content = IntroductionText + case 2: + content = Disclaimer + default: + return "" + } + + boxWidth := min(m.width-10, 90) + + boxStyle := lipgloss.NewStyle(). + Border(style.DefaultBorder). + Margin(1, 0).Padding(2, 4).Width(boxWidth) + + var b strings.Builder + + b.WriteString(style.TitleStyle.Render(IntroTitle)) + b.WriteString("\n") + + b.WriteString(boxStyle.Render(content)) + b.WriteString("\n") + + helpText := "Press " + keys.Continue.Help().Key + " to continue • " + + keys.Back.Help().Key + " to go back • " + keys.Quit.Help().Key + " to quit" + + if m.stage == stages { + helpText += "\nPress " + keys.Start.Help().Key + " to start the survey" + } + + b.WriteString(style.HelpStyle.Render(helpText)) + + final := lipgloss.Place(m.width, m.height, lipgloss.Center, lipgloss.Center, b.String()) + + return final } func (m *introModel) SetSize(width, height int) { diff --git a/go.mod b/go.mod index 2d12e00..bf16c65 100644 --- a/go.mod +++ b/go.mod @@ -100,6 +100,7 @@ require ( golang.org/x/sys v0.41.0 // indirect golang.org/x/text v0.34.0 // indirect golang.org/x/tools v0.42.0 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 21bd467..cfc7e34 100644 --- a/go.sum +++ b/go.sum @@ -233,7 +233,8 @@ golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk= golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA= golang.org/x/tools v0.42.0 h1:uNgphsn75Tdz5Ji2q36v/nsFSfR/9BRFvqhGBaJGd5k= golang.org/x/tools v0.42.0/go.mod h1:Ma6lCIwGZvHK6XtgbswSoWroEkhugApmsXyrUmBhfr0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/style/styles.go b/internal/style/styles.go index 7dd47c8..3899269 100644 --- a/internal/style/styles.go +++ b/internal/style/styles.go @@ -24,5 +24,5 @@ var ( TitleStyle = lipgloss.NewStyle().Foreground(PrimaryColor).Bold(true) DescriptionStyle = lipgloss.NewStyle().Foreground(TextColor).Italic(true) DetailStyle = lipgloss.NewStyle().Foreground(SecondaryColor) - HelpStyle = lipgloss.NewStyle().Foreground(AccentColor) + HelpStyle = lipgloss.NewStyle().Align(lipgloss.Center).Foreground(AccentColor) )