Refactored navbar and added error page
This commit is contained in:
@@ -9,7 +9,7 @@ func HandleRoot() http.Handler {
|
||||
return http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
page.Error("404", "Page not found", "The page or resource you have requested does not exist").Render(r.Context(), w)
|
||||
return
|
||||
}
|
||||
page.Index().Render(r.Context(), w)
|
||||
|
||||
25
view/component/nav/navbar.templ
Normal file
25
view/component/nav/navbar.templ
Normal file
@@ -0,0 +1,25 @@
|
||||
package nav
|
||||
|
||||
templ Navbar() {
|
||||
{{ navItems := getNavItems() }}
|
||||
<div x-data="{ open: false }">
|
||||
<header class="bg-crust">
|
||||
<div
|
||||
class="mx-auto flex h-16 max-w-screen-xl items-center gap-8
|
||||
px-4 sm:px-6 lg:px-8"
|
||||
>
|
||||
<a class="block" href="#">
|
||||
<!-- logo here -->
|
||||
<span class="text-3xl font-bold transition hover:text-green">
|
||||
<span class="hidden sm:inline">Project</span> Reshoot
|
||||
</span>
|
||||
</a>
|
||||
<div class="flex flex-1 items-center justify-end sm:justify-between">
|
||||
@navLeft(navItems)
|
||||
@navRight()
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@sideNav(navItems)
|
||||
</div>
|
||||
}
|
||||
61
view/component/nav/navbar_templ.go
Normal file
61
view/component/nav/navbar_templ.go
Normal file
@@ -0,0 +1,61 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.833
|
||||
package nav
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func Navbar() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
navItems := getNavItems()
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div x-data=\"{ open: false }\"><header class=\"bg-crust\"><div class=\"mx-auto flex h-16 max-w-screen-xl items-center gap-8\n px-4 sm:px-6 lg:px-8\"><a class=\"block\" href=\"#\"><!-- logo here --><span class=\"text-3xl font-bold transition hover:text-green\"><span class=\"hidden sm:inline\">Project</span> Reshoot</span></a><div class=\"flex flex-1 items-center justify-end sm:justify-between\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = navLeft(navItems).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = navRight().Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</div></div></header>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = sideNav(navItems).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
3
view/component/nav/navbar_templ.txt
Normal file
3
view/component/nav/navbar_templ.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
<div x-data=\"{ open: false }\"><header class=\"bg-crust\"><div class=\"mx-auto flex h-16 max-w-screen-xl items-center gap-8\n px-4 sm:px-6 lg:px-8\"><a class=\"block\" href=\"#\"><!-- logo here --><span class=\"text-3xl font-bold transition hover:text-green\"><span class=\"hidden sm:inline\">Project</span> Reshoot</span></a><div class=\"flex flex-1 items-center justify-end sm:justify-between\">
|
||||
</div></div></header>
|
||||
</div>
|
||||
15
view/component/nav/navbaritems.go
Normal file
15
view/component/nav/navbaritems.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package nav
|
||||
|
||||
type NavItem struct {
|
||||
name string
|
||||
href string
|
||||
}
|
||||
|
||||
func getNavItems() []NavItem {
|
||||
return []NavItem{
|
||||
{
|
||||
name: "Movies",
|
||||
href: "/movies",
|
||||
},
|
||||
}
|
||||
}
|
||||
18
view/component/nav/navbarleft.templ
Normal file
18
view/component/nav/navbarleft.templ
Normal file
@@ -0,0 +1,18 @@
|
||||
package nav
|
||||
|
||||
templ navLeft(navItems []NavItem) {
|
||||
<nav aria-label="Global" class="hidden sm:block">
|
||||
<ul class="flex items-center gap-6 text-xl">
|
||||
for _, item := range navItems {
|
||||
<li>
|
||||
<a
|
||||
class="text-subtext1 hover:text-green transition"
|
||||
href={ templ.SafeURL(item.href) }
|
||||
>
|
||||
{ item.name }
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
72
view/component/nav/navbarleft_templ.go
Normal file
72
view/component/nav/navbarleft_templ.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.833
|
||||
package nav
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func navLeft(navItems []NavItem) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<nav aria-label=\"Global\" class=\"hidden sm:block\"><ul class=\"flex items-center gap-6 text-xl\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, item := range navItems {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<li><a class=\"text-subtext1 hover:text-green transition\" href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 templ.SafeURL = templ.SafeURL(item.href)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var2)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(item.name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/component/nav/navbarleft.templ`, Line: 12, Col: 17}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</a></li>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</ul></nav>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
5
view/component/nav/navbarleft_templ.txt
Normal file
5
view/component/nav/navbarleft_templ.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
<nav aria-label=\"Global\" class=\"hidden sm:block\"><ul class=\"flex items-center gap-6 text-xl\">
|
||||
<li><a class=\"text-subtext1 hover:text-green transition\" href=\"
|
||||
\">
|
||||
</a></li>
|
||||
</ul></nav>
|
||||
43
view/component/nav/navbarright.templ
Normal file
43
view/component/nav/navbarright.templ
Normal file
@@ -0,0 +1,43 @@
|
||||
package nav
|
||||
|
||||
templ navRight() {
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="sm:flex sm:gap-2">
|
||||
<a
|
||||
class="hidden rounded-lg px-4 py-2 sm:block
|
||||
bg-green hover:bg-green/75 text-mantle transition"
|
||||
href="/login"
|
||||
>
|
||||
Login
|
||||
</a>
|
||||
<a
|
||||
class="hidden rounded-lg px-4 py-2 sm:block
|
||||
bg-blue text-mantle hover:bg-blue/75 transition"
|
||||
href="/register"
|
||||
>
|
||||
Register
|
||||
</a>
|
||||
</div>
|
||||
<button
|
||||
@click="open = !open"
|
||||
class="block rounded-lg p-2.5 sm:hidden transition
|
||||
bg-surface0 text-subtext0 hover:text-overlay2/75"
|
||||
>
|
||||
<span class="sr-only">Toggle menu</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="size-5"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M4 6h16M4 12h16M4 18h16"
|
||||
></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
40
view/component/nav/navbarright_templ.go
Normal file
40
view/component/nav/navbarright_templ.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.833
|
||||
package nav
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func navRight() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"flex items-center gap-2\"><div class=\"sm:flex sm:gap-2\"><a class=\"hidden rounded-lg px-4 py-2 sm:block \n bg-green hover:bg-green/75 text-mantle transition\" href=\"/login\">Login</a> <a class=\"hidden rounded-lg px-4 py-2 sm:block\n bg-blue text-mantle hover:bg-blue/75 transition\" href=\"/register\">Register</a></div><button @click=\"open = !open\" class=\"block rounded-lg p-2.5 sm:hidden transition\n bg-surface0 text-subtext0 hover:text-overlay2/75\"><span class=\"sr-only\">Toggle menu</span> <svg xmlns=\"http://www.w3.org/2000/svg\" class=\"size-5\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
1
view/component/nav/navbarright_templ.txt
Normal file
1
view/component/nav/navbarright_templ.txt
Normal file
@@ -0,0 +1 @@
|
||||
<div class=\"flex items-center gap-2\"><div class=\"sm:flex sm:gap-2\"><a class=\"hidden rounded-lg px-4 py-2 sm:block \n bg-green hover:bg-green/75 text-mantle transition\" href=\"/login\">Login</a> <a class=\"hidden rounded-lg px-4 py-2 sm:block\n bg-blue text-mantle hover:bg-blue/75 transition\" href=\"/register\">Register</a></div><button @click=\"open = !open\" class=\"block rounded-lg p-2.5 sm:hidden transition\n bg-surface0 text-subtext0 hover:text-overlay2/75\"><span class=\"sr-only\">Toggle menu</span> <svg xmlns=\"http://www.w3.org/2000/svg\" class=\"size-5\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4 6h16M4 12h16M4 18h16\"></path></svg></button></div>
|
||||
@@ -1,4 +1,4 @@
|
||||
package component
|
||||
package nav
|
||||
|
||||
templ sideNav(navItems []NavItem) {
|
||||
<div
|
||||
72
view/component/nav/sidenav_templ.go
Normal file
72
view/component/nav/sidenav_templ.go
Normal file
@@ -0,0 +1,72 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.833
|
||||
package nav
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
func sideNav(navItems []NavItem) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div x-show=\"open\" x-transition class=\"absolute w-full bg-mantle sm:hidden\"><div class=\"px-4 py-6\"><ul class=\"space-y-1\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, item := range navItems {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<li><a href=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 templ.SafeURL = templ.SafeURL(item.href)
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var2)))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\" class=\"block rounded-lg px-4 py-2 text-lg\n bg-surface0 text-text transition hover:bg-surface2\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(item.name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/component/nav/sidenav.templ`, Line: 18, Col: 18}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</a></li>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "</ul></div><div class=\"px-4 pb-6\"><ul class=\"space-y-1\"><li class=\"flex justify-center items-center gap-2\"><a class=\"w-26 px-4 py-2 rounded-lg\n bg-green text-mantle transition hover:bg-green/75\n text-center\" href=\"/login\">Login</a> <a class=\"w-26 px-4 py-2 rounded-lg\n bg-blue text-mantle transition hover:bg-blue/75\n text-center\" href=\"/register\">Register</a></li></ul></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
5
view/component/nav/sidenav_templ.txt
Normal file
5
view/component/nav/sidenav_templ.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
<div x-show=\"open\" x-transition class=\"absolute w-full bg-mantle sm:hidden\"><div class=\"px-4 py-6\"><ul class=\"space-y-1\">
|
||||
<li><a href=\"
|
||||
\" class=\"block rounded-lg px-4 py-2 text-lg\n bg-surface0 text-text transition hover:bg-surface2\">
|
||||
</a></li>
|
||||
</ul></div><div class=\"px-4 pb-6\"><ul class=\"space-y-1\"><li class=\"flex justify-center items-center gap-2\"><a class=\"w-26 px-4 py-2 rounded-lg\n bg-green text-mantle transition hover:bg-green/75\n text-center\" href=\"/login\">Login</a> <a class=\"w-26 px-4 py-2 rounded-lg\n bg-blue text-mantle transition hover:bg-blue/75\n text-center\" href=\"/register\">Register</a></li></ul></div></div>
|
||||
@@ -1,90 +0,0 @@
|
||||
package component
|
||||
|
||||
type NavItem struct {
|
||||
name string
|
||||
href string
|
||||
}
|
||||
|
||||
func getNavItems() []NavItem {
|
||||
return []NavItem{
|
||||
{
|
||||
name: "Movies",
|
||||
href: "/movies",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
templ Navbar() {
|
||||
<div x-data="{ open: false }">
|
||||
<header class="bg-crust">
|
||||
<div
|
||||
class="mx-auto flex h-16 max-w-screen-xl items-center gap-8
|
||||
px-4 sm:px-6 lg:px-8"
|
||||
>
|
||||
<a class="block" href="#">
|
||||
<span class="text-3xl font-bold transition hover:text-green">
|
||||
<span class="hidden sm:inline">Project</span> Reshoot
|
||||
</span>
|
||||
<!-- logo here -->
|
||||
</a>
|
||||
<div class="flex flex-1 items-center justify-end sm:justify-between">
|
||||
<nav aria-label="Global" class="hidden sm:block">
|
||||
<ul class="flex items-center gap-6 text-xl">
|
||||
for _, item := range getNavItems() {
|
||||
<li>
|
||||
<a
|
||||
class="text-subtext1 hover:text-green
|
||||
transition"
|
||||
href={ templ.SafeURL(item.href) }
|
||||
>
|
||||
{ item.name }
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="flex items-center gap-2">
|
||||
<div class="sm:flex sm:gap-2">
|
||||
<a
|
||||
class="hidden rounded-lg px-4 py-2 sm:block
|
||||
bg-green hover:bg-green/75 text-mantle transition"
|
||||
href="/login"
|
||||
>
|
||||
Login
|
||||
</a>
|
||||
<a
|
||||
class="hidden rounded-lg px-4 py-2 sm:block
|
||||
bg-blue text-mantle hover:bg-blue/75 transition"
|
||||
href="/register"
|
||||
>
|
||||
Register
|
||||
</a>
|
||||
</div>
|
||||
<button
|
||||
@click="open = !open"
|
||||
class="block rounded-lg p-2.5 sm:hidden transition
|
||||
bg-surface0 text-subtext0 hover:text-overlay2/75"
|
||||
>
|
||||
<span class="sr-only">Toggle menu</span>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="size-5"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M4 6h16M4 12h16M4 18h16"
|
||||
></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@sideNav(getNavItems())
|
||||
</div>
|
||||
}
|
||||
@@ -1,21 +1,18 @@
|
||||
package layout
|
||||
|
||||
import "projectreshoot/view/component"
|
||||
import "projectreshoot/view/component/nav"
|
||||
|
||||
templ Global() {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Project Reshoot</title>
|
||||
<link href="/static/css/output.css" rel="stylesheet" />
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"
|
||||
integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||
<script>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Project Reshoot</title>
|
||||
<link href="/static/css/output.css" rel="stylesheet"/>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4" integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/alpinejs" defer></script>
|
||||
<script>
|
||||
document.documentElement.classList.toggle(
|
||||
"dark",
|
||||
localStorage.currentTheme === "dark" ||
|
||||
@@ -29,13 +26,10 @@ templ Global() {
|
||||
//localStorage.currentTheme = "dark";
|
||||
//localStorage.removeItem("theme");
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="bg-base text-text ubuntu-mono-regular">
|
||||
@component.Navbar()
|
||||
<h1 class="text-3xl font-bold underline">Hello world! </h1>
|
||||
{ children... }
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</head>
|
||||
<body class="bg-base text-text ubuntu-mono-regular">
|
||||
@nav.Navbar()
|
||||
{ children... }
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
|
||||
30
view/page/error.templ
Normal file
30
view/page/error.templ
Normal file
@@ -0,0 +1,30 @@
|
||||
package page
|
||||
|
||||
import "projectreshoot/view/layout"
|
||||
|
||||
templ Error(code string, err string, message string) {
|
||||
@layout.Global() {
|
||||
<div
|
||||
class="grid absolute left-0 right-0 top-0 bottom-0 z-[-1]
|
||||
place-content-center bg-base px-4"
|
||||
>
|
||||
<div class="text-center">
|
||||
<h1
|
||||
class="text-9xl text-text"
|
||||
>{ code }</h1>
|
||||
<p
|
||||
class="text-2xl font-bold tracking-tight text-subtext1
|
||||
sm:text-4xl"
|
||||
>{ err }</p>
|
||||
<p
|
||||
class="mt-4 text-subtext0"
|
||||
>{ message }</p>
|
||||
<a
|
||||
href="/"
|
||||
class="mt-6 inline-block rounded-lg bg-mauve px-5 py-3
|
||||
text-sm text-crust hover:bg-mauve/75"
|
||||
>Go to homepage</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user