navbar_templ.go
7159 bytes
1// Code generated by templ - DO NOT EDIT.
2
3// templ: version: v0.3.1020
4package pages
5
6//lint:file-ignore SA4006 This context is only used if a nested component is present.
7
8import "github.com/a-h/templ"
9import templruntime "github.com/a-h/templ/runtime"
10
11import "fmt"
12
13type NavButton struct {
14 link string
15 text string
16 icon string
17}
18
19func navButtons(route string) []*NavButton {
20 newVideos := &NavButton{"/", "New Videos", "collection-play"}
21 watched := &NavButton{"/watched", "Watched", "check-circle"}
22 channels := &NavButton{"/channels", "Channels", "people"}
23 switch route {
24 case "channels":
25 return []*NavButton{newVideos, watched}
26 case "new":
27 return []*NavButton{channels, watched}
28 case "watched":
29 return []*NavButton{channels, newVideos}
30 default:
31 return []*NavButton{channels, newVideos, watched}
32 }
33}
34
35func navbar(route string) templ.Component {
36 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
37 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
38 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
39 return templ_7745c5c3_CtxErr
40 }
41 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
42 if !templ_7745c5c3_IsBuffer {
43 defer func() {
44 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
45 if templ_7745c5c3_Err == nil {
46 templ_7745c5c3_Err = templ_7745c5c3_BufErr
47 }
48 }()
49 }
50 ctx = templ.InitializeContext(ctx)
51 templ_7745c5c3_Var1 := templ.GetChildren(ctx)
52 if templ_7745c5c3_Var1 == nil {
53 templ_7745c5c3_Var1 = templ.NopComponent
54 }
55 ctx = templ.ClearChildren(ctx)
56 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<nav class=\"navbar navbar-expand-lg bg-body-tertiary\"><div class=\"container-fluid\"><a class=\"navbar-brand\" href=\"/\"><img src=\"/assets/ytrssil.svg\" alt=\"ytrssil\" width=\"32\" height=\"32\"></a> ")
57 if templ_7745c5c3_Err != nil {
58 return templ_7745c5c3_Err
59 }
60 if route != "auth" {
61 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<ul id=\"nav-buttons\" class=\"navbar-nav me-auto mb-0 flex-row\"><li class=\"nav-item me-1 me-lg-2 d-lg-none\"><button type=\"button\" class=\"btn btn-primary\" onClick=\"window.location.reload();\"><i class=\"bi bi-arrow-clockwise\"></i></button></li><li class=\"nav-item me-1 me-lg-2\"><button type=\"button\" class=\"btn btn-outline-secondary\" style=\"--bs-btn-color: var(--bs-body-color);\" data-bs-toggle=\"modal\" data-bs-target=\"#add-video-modal\"><span class=\"d-none d-lg-inline\">Add Video </span><i class=\"bi bi-camera-video\"></i></button></li><li class=\"nav-item me-1 me-lg-2\"><button type=\"button\" class=\"btn btn-outline-secondary\" style=\"--bs-btn-color: var(--bs-body-color);\" data-on:click=\"@post('/fetch')\"><span class=\"d-none d-lg-inline\">Fetch </span><i class=\"bi bi-cloud-download\"></i></button></li><li class=\"nav-item me-1 me-lg-2\"><button type=\"button\" class=\"btn btn-outline-secondary\" style=\"--bs-btn-color: var(--bs-body-color);\" data-bs-toggle=\"modal\" data-bs-target=\"#subscription-modal\"><span class=\"d-none d-lg-inline\">Subscribe </span><i class=\"bi bi-bookmark-plus\"></i></button></li>")
62 if templ_7745c5c3_Err != nil {
63 return templ_7745c5c3_Err
64 }
65 for _, button := range navButtons(route) {
66 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<li class=\"nav-item me-1 me-lg-2\"><a href=\"")
67 if templ_7745c5c3_Err != nil {
68 return templ_7745c5c3_Err
69 }
70 var templ_7745c5c3_Var2 templ.SafeURL
71 templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinURLErrs(button.link)
72 if templ_7745c5c3_Err != nil {
73 return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/navbar.templ`, Line: 76, Col: 28}
74 }
75 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
76 if templ_7745c5c3_Err != nil {
77 return templ_7745c5c3_Err
78 }
79 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" class=\"btn btn-outline-secondary\" style=\"--bs-btn-color: var(--bs-body-color);\"><span class=\"d-none d-lg-inline\">")
80 if templ_7745c5c3_Err != nil {
81 return templ_7745c5c3_Err
82 }
83 var templ_7745c5c3_Var3 string
84 templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(button.text)
85 if templ_7745c5c3_Err != nil {
86 return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/navbar.templ`, Line: 77, Col: 54}
87 }
88 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
89 if templ_7745c5c3_Err != nil {
90 return templ_7745c5c3_Err
91 }
92 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</span> ")
93 if templ_7745c5c3_Err != nil {
94 return templ_7745c5c3_Err
95 }
96 var templ_7745c5c3_Var4 = []any{fmt.Sprintf("bi bi-%s", button.icon)}
97 templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var4...)
98 if templ_7745c5c3_Err != nil {
99 return templ_7745c5c3_Err
100 }
101 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<i class=\"")
102 if templ_7745c5c3_Err != nil {
103 return templ_7745c5c3_Err
104 }
105 var templ_7745c5c3_Var5 string
106 templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.ResolveAttributeValue(templ.CSSClasses(templ_7745c5c3_Var4).String())
107 if templ_7745c5c3_Err != nil {
108 return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/navbar.templ`, Line: 1, Col: 0}
109 }
110 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
111 if templ_7745c5c3_Err != nil {
112 return templ_7745c5c3_Err
113 }
114 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "\"></i></a></li>")
115 if templ_7745c5c3_Err != nil {
116 return templ_7745c5c3_Err
117 }
118 }
119 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</ul><div class=\"d-flex\" role=\"search\"><input id=\"video-search\" class=\"form-control me-2 d-lg-block d-none\" type=\"search\" placeholder=\"Search videos...\"> <button type=\"button\" class=\"btn btn-outline-secondary d-lg-none\" style=\"--bs-btn-color: var(--bs-body-color);\" onclick=\"\n\t\t\t\t\t\t\tconst buttons = document.getElementById('nav-buttons');\n\t\t\t\t\t\t\tconst search = document.getElementById('video-search');\n\t\t\t\t\t\t\tif (search.classList.contains('d-none')) {\n\t\t\t\t\t\t\t\tbuttons.classList.add('d-none');\n\t\t\t\t\t\t\t\tsearch.classList.remove('d-none');\n\t\t\t\t\t\t\t\tsearch.focus();\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tbuttons.classList.remove('d-none');\n\t\t\t\t\t\t\t\tsearch.classList.add('d-none');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\"><i class=\"bi bi-search\"></i></button></div>")
120 if templ_7745c5c3_Err != nil {
121 return templ_7745c5c3_Err
122 }
123 }
124 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</div></nav>")
125 if templ_7745c5c3_Err != nil {
126 return templ_7745c5c3_Err
127 }
128 return nil
129 })
130}
131
132var _ = templruntime.GeneratedTemplate