diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-17 18:26:54 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-17 18:26:54 +0200 |
commit | bdce74729c3529d7b5b1465bd23a079a3ec0caab (patch) | |
tree | 597829ccd339c288eacb15aac75bae9c3637b4fd | |
parent | 70031d8971136583647125d967ace7b9c831ed00 (diff) | |
download | gosten-bdce74729c3529d7b5b1465bd23a079a3ec0caab.tar.gz gosten-bdce74729c3529d7b5b1465bd23a079a3ec0caab.tar.bz2 gosten-bdce74729c3529d7b5b1465bd23a079a3ec0caab.zip |
Show user name in user drop down
-rw-r--r-- | pages/base.templ | 5 | ||||
-rw-r--r-- | pages/base_templ.go | 35 |
2 files changed, 27 insertions, 13 deletions
diff --git a/pages/base.templ b/pages/base.templ index 5b06fda..33edd65 100644 --- a/pages/base.templ +++ b/pages/base.templ @@ -42,6 +42,7 @@ templ navlinks() { } templ userlinks() { + <li><h4 class="dropdown-header">{getUser(ctx).Name}</h4></li> <li><a class="dropdown-item" href="/logout">Logout</a></li> } @@ -69,11 +70,11 @@ templ navbar() { <ul class="navbar-nav nav-underline me-auto"> @navlinks() </ul> - <form class="d-flex" role="search"> + <form class="d-flex mt-3 mt-lg-0" role="search"> <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-dark" type="submit"><svg class="svg"><use xlink:href="#search"></use></svg></button> </form> - <div class="dropdown ms-3"> + <div class="dropdown mt-3 ms-lg-3 mt-lg-0"> <button class="btn btn-outline-primary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> <svg class="svg"><use xlink:href="#person"></use></svg> </button> diff --git a/pages/base_templ.go b/pages/base_templ.go index d8d149f..d871263 100644 --- a/pages/base_templ.go +++ b/pages/base_templ.go @@ -223,7 +223,20 @@ func userlinks() templ.Component { templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li><a class=\"dropdown-item\" href=\"/logout\">Logout</a></li>") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li><h4 class=\"dropdown-header\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(getUser(ctx).Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/base.templ`, Line: 45, Col: 54} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h4></li><li><a class=\"dropdown-item\" href=\"/logout\">Logout</a></li>") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -247,9 +260,9 @@ func navbar() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var10 := templ.GetChildren(ctx) - if templ_7745c5c3_Var10 == nil { - templ_7745c5c3_Var10 = templ.NopComponent + templ_7745c5c3_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"d-none\"><symbol id=\"search\" viewBox=\"0 0 16 16\"><path d=\"M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z\"></path></symbol> <symbol id=\"person\" viewBox=\"0 0 16 16\"><path d=\"M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10s-3.516.68-4.168 1.332c-.678.678-.83 1.418-.832 1.664z\"></path></symbol></svg><nav class=\"navbar sticky-top bg-dark-subtle navbar-expand-lg shadow mb-2\"><div class=\"container-fluid\"><a class=\"navbar-brand\" href=\"/\"><img src=\"/static/euro-money.svg\" alt=\"Logo\" width=\"32\" height=\"32\" class=\"d-inline-block\"> Kosten</a> <button class=\"navbar-toggler\" type=\"button\" data-bs-toggle=\"collapse\" data-bs-target=\"#navbarNav\" aria-controls=\"navbarNav\" aria-expanded=\"false\" aria-label=\"Toggle navigation\"><span class=\"navbar-toggler-icon\"></span></button><div class=\"collapse navbar-collapse\" id=\"navbarNav\"><ul class=\"navbar-nav nav-underline me-auto\">") @@ -260,7 +273,7 @@ func navbar() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul><form class=\"d-flex\" role=\"search\"><input class=\"form-control me-2\" type=\"search\" placeholder=\"Search\" aria-label=\"Search\"> <button class=\"btn btn-outline-dark\" type=\"submit\"><svg class=\"svg\"><use xlink:href=\"#search\"></use></svg></button></form><div class=\"dropdown ms-3\"><button class=\"btn btn-outline-primary dropdown-toggle\" type=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"><svg class=\"svg\"><use xlink:href=\"#person\"></use></svg></button><ul class=\"dropdown-menu dropdown-menu-lg-end\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul><form class=\"d-flex mt-3 mt-lg-0\" role=\"search\"><input class=\"form-control me-2\" type=\"search\" placeholder=\"Search\" aria-label=\"Search\"> <button class=\"btn btn-outline-dark\" type=\"submit\"><svg class=\"svg\"><use xlink:href=\"#search\"></use></svg></button></form><div class=\"dropdown mt-3 ms-lg-3 mt-lg-0\"><button class=\"btn btn-outline-primary dropdown-toggle\" type=\"button\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\"><svg class=\"svg\"><use xlink:href=\"#person\"></use></svg></button><ul class=\"dropdown-menu dropdown-menu-lg-end\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -292,12 +305,12 @@ func content() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var11 := templ.GetChildren(ctx) - if templ_7745c5c3_Var11 == nil { - templ_7745c5c3_Var11 = templ.NopComponent + templ_7745c5c3_Var12 := templ.GetChildren(ctx) + if templ_7745c5c3_Var12 == nil { + templ_7745c5c3_Var12 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -317,7 +330,7 @@ func content() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var11.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var12.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -327,7 +340,7 @@ func content() templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } |