-
Notifications
You must be signed in to change notification settings - Fork 32
feat: add accessible flag and environment variable for screen reader friendly forms #455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9c26894
7a747ba
f39d175
6dc0c1a
504bfcf
09c76d0
0417f40
907f5ec
2318e16
95a713e
4f13099
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,7 @@ package iostreams | |||||
| import ( | ||||||
| "context" | ||||||
| "errors" | ||||||
| "fmt" | ||||||
| "slices" | ||||||
|
|
||||||
| huh "charm.land/huh/v2" | ||||||
|
|
@@ -39,13 +40,20 @@ func newForm(io *IOStreams, field huh.Field) *huh.Form { | |||||
| } else { | ||||||
| form = form.WithTheme(style.ThemeSurvey()) | ||||||
| } | ||||||
| if io != nil && io.config.Accessible { | ||||||
| form = form.WithAccessible(true) | ||||||
| } | ||||||
| return form | ||||||
| } | ||||||
|
|
||||||
| // buildInputForm constructs an interactive form for text input prompts. | ||||||
| func buildInputForm(io *IOStreams, message string, cfg InputPromptConfig, input *string) *huh.Form { | ||||||
| title := message | ||||||
| if io != nil && io.config.Accessible && cfg.Placeholder != "" { | ||||||
| title = fmt.Sprintf("%s (default: %s)", message, cfg.Placeholder) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🔭 suggestion: This might not be the right syntax but I think formatting input ends best with a colon: - Name your app: (default: flamboyant-salamander-784)
+ Name your app (default: flamboyant-salamander-784):
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎨 ramble: We don't have a comment on this in the |
||||||
| } | ||||||
| field := huh.NewInput(). | ||||||
| Title(message). | ||||||
| Title(title). | ||||||
| Prompt(style.Chevron() + " "). | ||||||
| Placeholder(cfg.Placeholder). | ||||||
| Value(input) | ||||||
|
|
@@ -100,8 +108,13 @@ func buildSelectForm(io *IOStreams, msg string, options []string, cfg SelectProm | |||||
| opts = append(opts, huh.NewOption(key, opt)) | ||||||
| } | ||||||
|
|
||||||
| title := msg | ||||||
| if io != nil && io.config.Accessible && len(options) > 0 { | ||||||
| title = fmt.Sprintf("%s (press Enter for 1)", msg) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
🪬 suggestion: Similar to the |
||||||
| } | ||||||
|
|
||||||
| field := huh.NewSelect[string](). | ||||||
| Title(msg). | ||||||
| Title(title). | ||||||
| Description(cfg.Help). | ||||||
| Options(opts...). | ||||||
| Value(selected) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌲 thought: As we're introducing this, should we include the environment variable similar?
🔗 https://github.com/charmbracelet/huh?tab=readme-ov-file#accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 ramble: We might find this adjacent file most useful!
slack-cli/internal/config/dotenv.go
Lines 23 to 24 in f39d175