Skip to content

Commit 97cd530

Browse files
committed
refactor: move charm_theme into internal/style
1 parent fbeb4f3 commit 97cd530

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

internal/iostreams/charm.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"slices"
2323

2424
"github.com/charmbracelet/huh"
25+
"github.com/slackapi/slack-cli/internal/style"
2526
)
2627

2728
// buildInputForm constructs a huh form for text input prompts.
@@ -32,7 +33,7 @@ func buildInputForm(message string, cfg InputPromptConfig, input *string) *huh.F
3233
if cfg.Required {
3334
field.Validate(huh.ValidateMinLength(1))
3435
}
35-
return huh.NewForm(huh.NewGroup(field)).WithTheme(ThemeSlack())
36+
return huh.NewForm(huh.NewGroup(field)).WithTheme(style.ThemeSlack())
3637
}
3738

3839
// charmInputPrompt prompts for text input using a charm huh form
@@ -50,7 +51,7 @@ func buildConfirmForm(message string, choice *bool) *huh.Form {
5051
field := huh.NewConfirm().
5152
Title(message).
5253
Value(choice)
53-
return huh.NewForm(huh.NewGroup(field)).WithTheme(ThemeSlack())
54+
return huh.NewForm(huh.NewGroup(field)).WithTheme(style.ThemeSlack())
5455
}
5556

5657
// charmConfirmPrompt prompts for a yes/no confirmation using a charm huh form
@@ -85,7 +86,7 @@ func buildSelectForm(msg string, options []string, cfg SelectPromptConfig, selec
8586
field.Height(cfg.PageSize + 2)
8687
}
8788

88-
return huh.NewForm(huh.NewGroup(field)).WithTheme(ThemeSlack())
89+
return huh.NewForm(huh.NewGroup(field)).WithTheme(style.ThemeSlack())
8990
}
9091

9192
// charmSelectPrompt prompts the user to select one option using a charm huh form
@@ -109,7 +110,7 @@ func buildPasswordForm(message string, cfg PasswordPromptConfig, input *string)
109110
if cfg.Required {
110111
field.Validate(huh.ValidateMinLength(1))
111112
}
112-
return huh.NewForm(huh.NewGroup(field)).WithTheme(ThemeSlack())
113+
return huh.NewForm(huh.NewGroup(field)).WithTheme(style.ThemeSlack())
113114
}
114115

115116
// charmPasswordPrompt prompts for a password (hidden input) using a charm huh form
@@ -134,7 +135,7 @@ func buildMultiSelectForm(message string, options []string, selected *[]string)
134135
Options(opts...).
135136
Value(selected)
136137

137-
return huh.NewForm(huh.NewGroup(field)).WithTheme(ThemeSlack())
138+
return huh.NewForm(huh.NewGroup(field)).WithTheme(style.ThemeSlack())
138139
}
139140

140141
// charmMultiSelectPrompt prompts the user to select multiple options using a charm huh form

internal/iostreams/charm_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func TestCharmSelect(t *testing.T) {
121121
f.Update(f.Init())
122122

123123
view := ansi.Strip(f.View())
124-
assert.Contains(t, view, "> Foo")
124+
assert.Contains(t, view, " Foo")
125125
})
126126

127127
t.Run("cursor navigation moves selection", func(t *testing.T) {
@@ -132,8 +132,8 @@ func TestCharmSelect(t *testing.T) {
132132

133133
m, _ := f.Update(tea.KeyMsg{Type: tea.KeyDown})
134134
view := ansi.Strip(m.View())
135-
assert.Contains(t, view, "> Bar")
136-
assert.False(t, strings.Contains(view, "> Foo"))
135+
assert.Contains(t, view, " Bar")
136+
assert.False(t, strings.Contains(view, " Foo"))
137137
})
138138

139139
t.Run("submit selects the hovered option", func(t *testing.T) {
@@ -280,7 +280,7 @@ func TestCharmFormsUseSlackTheme(t *testing.T) {
280280
f.Update(f.Init())
281281

282282
view := ansi.Strip(f.View())
283-
assert.Contains(t, view, "> A")
283+
assert.Contains(t, view, " A")
284284
})
285285

286286
t.Run("multi-select form renders themed prefixes", func(t *testing.T) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package iostreams
15+
package style
1616

1717
// Slack brand theme for charmbracelet/huh prompts.
1818
// Uses official Slack brand colors to give the CLI a fun, playful feel.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package iostreams
15+
package style
1616

1717
import (
1818
"testing"
@@ -34,13 +34,13 @@ func TestThemeSlack(t *testing.T) {
3434

3535
t.Run("focused title uses aubergine foreground", func(t *testing.T) {
3636
theme := ThemeSlack()
37-
assert.Equal(t, lipgloss.Color("#4a154b"), theme.Focused.Title.GetForeground())
37+
assert.Equal(t, lipgloss.Color("#7C2852"), theme.Focused.Title.GetForeground())
3838
})
3939

4040
t.Run("focused select selector renders cursor", func(t *testing.T) {
4141
theme := ThemeSlack()
4242
rendered := theme.Focused.SelectSelector.Render()
43-
assert.Contains(t, rendered, ">")
43+
assert.Contains(t, rendered, "")
4444
})
4545

4646
t.Run("focused multi-select selected prefix renders checkmark", func(t *testing.T) {
@@ -62,7 +62,7 @@ func TestThemeSlack(t *testing.T) {
6262

6363
t.Run("focused button uses aubergine background", func(t *testing.T) {
6464
theme := ThemeSlack()
65-
assert.Equal(t, lipgloss.Color("#4a154b"), theme.Focused.FocusedButton.GetBackground())
65+
assert.Equal(t, lipgloss.Color("#7C2852"), theme.Focused.FocusedButton.GetBackground())
6666
})
6767

6868
t.Run("focused button is bold", func(t *testing.T) {
@@ -74,14 +74,14 @@ func TestThemeSlack(t *testing.T) {
7474
theme := ThemeSlack()
7575
rendered := theme.Blurred.SelectSelector.Render()
7676
assert.Contains(t, rendered, " ")
77-
assert.NotContains(t, rendered, ">")
77+
assert.NotContains(t, rendered, "")
7878
})
7979

8080
t.Run("blurred multi-select selector is blank", func(t *testing.T) {
8181
theme := ThemeSlack()
8282
rendered := theme.Blurred.MultiSelectSelector.Render()
8383
assert.Contains(t, rendered, " ")
84-
assert.NotContains(t, rendered, ">")
84+
assert.NotContains(t, rendered, "")
8585
})
8686

8787
t.Run("blurred border is hidden", func(t *testing.T) {
@@ -90,9 +90,9 @@ func TestThemeSlack(t *testing.T) {
9090
assert.Equal(t, lipgloss.HiddenBorder(), borderStyle)
9191
})
9292

93-
t.Run("focused border uses bright aubergine", func(t *testing.T) {
93+
t.Run("focused border uses aubergine", func(t *testing.T) {
9494
theme := ThemeSlack()
95-
assert.Equal(t, lipgloss.Color("#611f69"), theme.Focused.Base.GetBorderLeftForeground())
95+
assert.Equal(t, lipgloss.Color("#7C2852"), theme.Focused.Base.GetBorderLeftForeground())
9696
})
9797

9898
t.Run("focused text input prompt uses blue", func(t *testing.T) {

0 commit comments

Comments
 (0)