Skip to content

Commit eb1fa71

Browse files
committed
input extracted into its own package to make it more reusable
1 parent 74ba653 commit eb1fa71

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package input
2+
3+
type InputConfig struct {
4+
Prompt string
5+
Placeholder string
6+
CharLimit int
7+
Width int
8+
}

internal/tui/components/OptionsProvider/input.go renamed to internal/tui/components/Input/input.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package optionsProvider
1+
package input
22

33
import (
44
"github.com/charmbracelet/bubbles/key"

internal/tui/components/OptionsProvider/component.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
tea "github.com/charmbracelet/bubbletea"
99
"github.com/charmbracelet/lipgloss"
1010
"github.com/maniac-en/req/internal/log"
11+
input "github.com/maniac-en/req/internal/tui/components/Input"
1112
"github.com/maniac-en/req/internal/tui/keybinds"
1213
"github.com/maniac-en/req/internal/tui/messages"
1314
)
@@ -21,7 +22,7 @@ const (
2122

2223
type OptionsProvider[T, U any] struct {
2324
list list.Model
24-
input OptionsInput
25+
input input.OptionsInput
2526
onSelectAction tea.Msg
2627
width int
2728
height int
@@ -151,7 +152,7 @@ func initList[T, U any](config *ListConfig[T, U]) list.Model {
151152

152153
func NewOptionsProvider[T, U any](config *ListConfig[T, U]) OptionsProvider[T, U] {
153154

154-
inputConfig := InputConfig{
155+
inputConfig := input.InputConfig{
155156
CharLimit: 100,
156157
Placeholder: "Add A New Collection...",
157158
Width: 22,
@@ -161,7 +162,7 @@ func NewOptionsProvider[T, U any](config *ListConfig[T, U]) OptionsProvider[T, U
161162
return OptionsProvider[T, U]{
162163
list: initList(config),
163164
focused: listComponent,
164-
input: NewOptionsInput(&inputConfig),
165+
input: input.NewOptionsInput(&inputConfig),
165166
getItems: config.GetItemsFunc,
166167
itemMapper: config.ItemMapper,
167168
// onSelectAction: config.OnSelectAction,

internal/tui/components/OptionsProvider/config.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,3 @@ type ListConfig[T, U any] struct {
2626
GetItemsFunc func(context.Context) ([]T, error)
2727
// Style lipgloss.Style
2828
}
29-
30-
type InputConfig struct {
31-
Prompt string
32-
Placeholder string
33-
CharLimit int
34-
Width int
35-
}

0 commit comments

Comments
 (0)