Skip to content

Commit 50f41bd

Browse files
authored
Frontend (#17)
1 parent 95f1833 commit 50f41bd

File tree

10 files changed

+775
-3
lines changed

10 files changed

+775
-3
lines changed

go.mod

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,36 @@ module github.com/maniac-en/req
33
go 1.24.4
44

55
require (
6+
github.com/charmbracelet/bubbles v0.21.0
7+
github.com/charmbracelet/bubbletea v1.3.6
8+
github.com/charmbracelet/lipgloss v1.1.0
69
github.com/mattn/go-sqlite3 v1.14.29
710
github.com/pressly/goose/v3 v3.24.3
811
gopkg.in/natefinch/lumberjack.v2 v2.2.1
912
)
1013

1114
require (
15+
github.com/atotto/clipboard v0.1.4 // indirect
16+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
17+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
18+
github.com/charmbracelet/x/ansi v0.9.3 // indirect
19+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
20+
github.com/charmbracelet/x/term v0.2.1 // indirect
21+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
22+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
23+
github.com/mattn/go-isatty v0.0.20 // indirect
24+
github.com/mattn/go-localereader v0.0.1 // indirect
25+
github.com/mattn/go-runewidth v0.0.16 // indirect
1226
github.com/mfridman/interpolate v0.0.2 // indirect
27+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
28+
github.com/muesli/cancelreader v0.2.2 // indirect
29+
github.com/muesli/termenv v0.16.0 // indirect
30+
github.com/rivo/uniseg v0.4.7 // indirect
31+
github.com/sahilm/fuzzy v0.1.1 // indirect
1332
github.com/sethvargo/go-retry v0.3.0 // indirect
33+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
1434
go.uber.org/multierr v1.11.0 // indirect
15-
golang.org/x/sync v0.14.0 // indirect
35+
golang.org/x/sync v0.15.0 // indirect
36+
golang.org/x/sys v0.33.0 // indirect
37+
golang.org/x/text v0.25.0 // indirect
1638
)

go.sum

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,53 @@
1+
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
2+
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
3+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
4+
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
5+
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
6+
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
7+
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
8+
github.com/charmbracelet/bubbles v0.21.0/go.mod h1:HF+v6QUR4HkEpz62dx7ym2xc71/KBHg+zKwJtMw+qtg=
9+
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
10+
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
11+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
12+
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
13+
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
14+
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
15+
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
16+
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
17+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
18+
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
19+
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
20+
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
21+
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
22+
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
123
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
224
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
325
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
426
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
27+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
28+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
529
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
630
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
31+
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
32+
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
33+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
34+
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
735
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
836
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
37+
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
38+
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
39+
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
40+
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
941
github.com/mattn/go-sqlite3 v1.14.29 h1:1O6nRLJKvsi1H2Sj0Hzdfojwt8GiGKm+LOfLaBFaouQ=
1042
github.com/mattn/go-sqlite3 v1.14.29/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
1143
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
1244
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
45+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
46+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
47+
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
48+
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
49+
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
50+
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
1351
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
1452
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
1553
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -18,18 +56,29 @@ github.com/pressly/goose/v3 v3.24.3 h1:DSWWNwwggVUsYZ0X2VitiAa9sKuqtBfe+Jr9zFGwW
1856
github.com/pressly/goose/v3 v3.24.3/go.mod h1:v9zYL4xdViLHCUUJh/mhjnm6JrK7Eul8AS93IxiZM4E=
1957
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
2058
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
59+
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
60+
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
61+
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
62+
github.com/sahilm/fuzzy v0.1.1 h1:ceu5RHF8DGgoi+/dR5PsECjCDH1BE3Fnmpo7aVXOdRA=
63+
github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
2164
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
2265
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
2366
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
2467
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
68+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
69+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
2570
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
2671
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
2772
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
2873
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
29-
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
30-
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
74+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
75+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
76+
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
77+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3178
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
3279
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
80+
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
81+
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
3382
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
3483
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
3584
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

internal/app/model.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package app
2+
3+
import (
4+
tea "github.com/charmbracelet/bubbletea"
5+
"github.com/charmbracelet/lipgloss"
6+
"github.com/maniac-en/req/internal/messages"
7+
"github.com/maniac-en/req/internal/tabs"
8+
)
9+
10+
type Model struct {
11+
tabs []tabs.Tab
12+
activeTab int
13+
width int
14+
height int
15+
}
16+
17+
func InitialModel() Model {
18+
tabList := []tabs.Tab{
19+
tabs.NewCollectionsTab(),
20+
tabs.NewAddCollectionTab(),
21+
tabs.NewEditCollectionTab(),
22+
}
23+
24+
return Model{
25+
tabs: tabList,
26+
activeTab: 0,
27+
}
28+
}
29+
30+
func (m Model) Init() tea.Cmd {
31+
return m.tabs[m.activeTab].Init()
32+
}
33+
34+
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
35+
var cmd tea.Cmd
36+
switch msg := msg.(type) {
37+
38+
case messages.SwitchTabMsg:
39+
if msg.TabIndex >= 0 && msg.TabIndex < len(m.tabs) {
40+
m.activeTab = msg.TabIndex
41+
return m, m.tabs[m.activeTab].OnFocus()
42+
}
43+
return m, nil
44+
45+
case messages.EditCollectionMsg:
46+
if editTab, ok := m.tabs[2].(*tabs.EditCollectionTab); ok {
47+
editTab.SetEditingCollection(msg.Label, msg.Value)
48+
}
49+
return m, nil
50+
51+
case tea.KeyMsg:
52+
switch msg.String() {
53+
// removed q here because that was causing issues with input fields
54+
case "ctrl+c":
55+
return m, tea.Quit
56+
default:
57+
m.tabs[m.activeTab], cmd = m.tabs[m.activeTab].Update(msg)
58+
return m, cmd
59+
}
60+
case tea.WindowSizeMsg:
61+
m.width = msg.Width
62+
m.height = msg.Height
63+
return m, nil
64+
default:
65+
m.tabs[m.activeTab], cmd = m.tabs[m.activeTab].Update(msg)
66+
return m, cmd
67+
}
68+
}
69+
70+
func (m Model) View() string {
71+
const headerFooterHeight = 1
72+
const padding = 1
73+
headerText := m.tabs[m.activeTab].Name()
74+
instructions := m.tabs[m.activeTab].Instructions()
75+
76+
headerStyle := lipgloss.NewStyle().
77+
Padding(1, 0).
78+
Background(lipgloss.Color("62")).
79+
Foreground(lipgloss.Color("230")).
80+
Height(headerFooterHeight).
81+
Width(len(headerText)+10).
82+
Align(lipgloss.Center, lipgloss.Top)
83+
84+
footerStyle := lipgloss.NewStyle().
85+
Foreground(lipgloss.Color("45")).
86+
Width(m.width-50).
87+
PaddingBottom(1).
88+
Height(headerFooterHeight).
89+
Align(lipgloss.Center, lipgloss.Center)
90+
91+
renderedHeader := headerStyle.Render(headerText)
92+
renderedFooter := footerStyle.Render(instructions)
93+
94+
headerHeight := lipgloss.Height(renderedHeader)
95+
footerHeight := lipgloss.Height(renderedFooter)
96+
97+
contentHeight := m.height - headerHeight - footerHeight
98+
contentStyle := lipgloss.NewStyle().
99+
Width(m.width).
100+
Height(contentHeight).
101+
Align(lipgloss.Center, lipgloss.Center)
102+
103+
content := m.tabs[m.activeTab].View()
104+
105+
return lipgloss.JoinVertical(lipgloss.Center, renderedHeader, contentStyle.Render(content), renderedFooter)
106+
}

internal/messages/messages.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package messages
2+
3+
type SwitchTabMsg struct {
4+
TabIndex int
5+
}
6+
7+
type EditCollectionMsg struct {
8+
Label string
9+
Value string
10+
}

internal/tabs/add-collections.go

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package tabs
2+
3+
import (
4+
"github.com/charmbracelet/bubbles/textinput"
5+
tea "github.com/charmbracelet/bubbletea"
6+
"github.com/charmbracelet/lipgloss"
7+
"github.com/maniac-en/req/internal/messages"
8+
)
9+
10+
type AddCollectionTab struct {
11+
name string
12+
nameInput textinput.Model
13+
focused bool
14+
}
15+
16+
func NewAddCollectionTab() *AddCollectionTab {
17+
textInput := textinput.New()
18+
textInput.Placeholder = "Enter your collection's name... "
19+
textInput.Focus()
20+
21+
textInput.CharLimit = 100
22+
textInput.Width = 50
23+
24+
return &AddCollectionTab{
25+
name: "Add Collection",
26+
nameInput: textInput,
27+
focused: true,
28+
}
29+
}
30+
31+
func (a *AddCollectionTab) Name() string {
32+
return a.name
33+
}
34+
35+
func (a *AddCollectionTab) Instructions() string {
36+
return "Enter - create • Esc - cancel"
37+
}
38+
39+
func (a *AddCollectionTab) Init() tea.Cmd {
40+
return textinput.Blink
41+
}
42+
43+
func (a *AddCollectionTab) OnFocus() tea.Cmd {
44+
a.nameInput.Focus()
45+
a.focused = true
46+
return textinput.Blink
47+
}
48+
49+
func (a *AddCollectionTab) OnBlur() tea.Cmd {
50+
a.nameInput.Blur()
51+
a.focused = false
52+
return nil
53+
}
54+
55+
func (a *AddCollectionTab) Update(msg tea.Msg) (Tab, tea.Cmd) {
56+
57+
switch msg := msg.(type) {
58+
case tea.KeyMsg:
59+
switch msg.String() {
60+
case "enter":
61+
if a.nameInput.Value() != "" {
62+
return a.addCollection(a.nameInput.Value())
63+
}
64+
case "esc":
65+
return a, func() tea.Msg {
66+
return messages.SwitchTabMsg{TabIndex: 0}
67+
}
68+
}
69+
}
70+
71+
a.nameInput, _ = a.nameInput.Update(msg)
72+
return a, nil
73+
}
74+
75+
func (a *AddCollectionTab) View() string {
76+
titleStyle := lipgloss.NewStyle().
77+
Bold(true).
78+
Foreground(lipgloss.Color("205")).
79+
MarginBottom(2)
80+
81+
inputStyle := lipgloss.NewStyle().
82+
Border(lipgloss.RoundedBorder()).
83+
BorderForeground(lipgloss.Color("62")).
84+
Padding(1, 2).
85+
MarginBottom(2)
86+
87+
form := lipgloss.JoinVertical(lipgloss.Center,
88+
titleStyle.Render("Create New Collection"),
89+
inputStyle.Render(a.nameInput.View()),
90+
)
91+
92+
containerStyle := lipgloss.NewStyle().
93+
Width(60).
94+
Height(20).
95+
Align(lipgloss.Center, lipgloss.Center)
96+
97+
return containerStyle.Render(form)
98+
}
99+
100+
func (a *AddCollectionTab) addCollection(name string) (Tab, tea.Cmd) {
101+
newOption := OptionPair{
102+
Label: name,
103+
Value: name,
104+
}
105+
106+
GlobalCollections = append(GlobalCollections, newOption)
107+
108+
a.nameInput.SetValue("")
109+
110+
return a, func() tea.Msg {
111+
return messages.SwitchTabMsg{TabIndex: 0}
112+
}
113+
}

0 commit comments

Comments
 (0)