diff options
Diffstat (limited to 'cmd/web/templates/components')
-rw-r--r-- | cmd/web/templates/components/error-message.tmpl | 15 | ||||
-rw-r--r-- | cmd/web/templates/components/head.tmpl | 5 | ||||
-rw-r--r-- | cmd/web/templates/components/navbar.tmpl | 90 | ||||
-rw-r--r-- | cmd/web/templates/components/redirect.tmpl | 6 |
4 files changed, 116 insertions, 0 deletions
diff --git a/cmd/web/templates/components/error-message.tmpl b/cmd/web/templates/components/error-message.tmpl new file mode 100644 index 0000000..e4a913e --- /dev/null +++ b/cmd/web/templates/components/error-message.tmpl @@ -0,0 +1,15 @@ +<div id="form-message" + {{ if .IsOob }} + hx-swap-oob="true" + {{ end }} +> + {{ if .Errors }} + <div class="alert alert-danger"> + <ul> + {{ range $error := .Errors }} + <li>{{ $error }}</li> + {{ end }} + </ul> + </div> + {{ end }} +</div>
\ No newline at end of file diff --git a/cmd/web/templates/components/head.tmpl b/cmd/web/templates/components/head.tmpl new file mode 100644 index 0000000..235ae63 --- /dev/null +++ b/cmd/web/templates/components/head.tmpl @@ -0,0 +1,5 @@ +<head> + {{ if ne .PageTitle "" }} + <title>{{ .PageTitle }} — Projecty</title> + {{ end }} +</head> diff --git a/cmd/web/templates/components/navbar.tmpl b/cmd/web/templates/components/navbar.tmpl new file mode 100644 index 0000000..f9cdc2a --- /dev/null +++ b/cmd/web/templates/components/navbar.tmpl @@ -0,0 +1,90 @@ +<ul id="navbar" class="nav navbar-nav pull-xs-right" + hx-swap-oob="true" +> + <li class="nav-item"> + <a id="nav-link-home" + {{ if ne .NavBarActive "home" }} + href="/" + hx-get="/htmx/home" + hx-target="#app-body" + hx-push-url="/" + {{ end }} + class="nav-link{{ if eq .NavBarActive "home" }} active {{ end }}" + > + Home + </a> + </li> + + {{ if not (IsAuthenticated .FiberCtx) }} + <li class="nav-item"> + <a id="nav-link-sign-in" + {{ if ne .NavBarActive "sign-in" }} + href="/sign-in" + hx-get="/htmx/sign-in" + hx-target="#app-body" + hx-push-url="/sign-in" + {{ end }} + class="nav-link {{ if eq .NavBarActive "sign-in" }} active {{ end }}" + > + Sign in + </a> + </li> + <li class="nav-item"> + <a id="nav-link-sign-up" + {{ if ne .NavBarActive "sign-up" }} + href="/sign-up" + hx-get="/htmx/sign-up" + hx-target="#app-body" + hx-push-url="/sign-up" + {{ end }} + class="nav-link {{ if eq .NavBarActive "sign-up" }} active {{ end }}" + > + Sign up + </a> + </li> + {{ end }} + + {{ if IsAuthenticated .FiberCtx }} + <li class="nav-item"> + <a id="nav-link-editor" + {{ if ne .NavBarActive "editor" }} + href="/editor" + hx-get="/htmx/editor" + hx-target="#app-body" + hx-push-url="/editor" + {{ end }} + class="nav-link {{ if eq .NavBarActive "editor" }} active {{ end }}" + > + <i class="ion-compose"></i> + New Article + </a> + </li> + <li class="nav-item"> + <a id="nav-link-settings" + {{ if ne .NavBarActive "settings" }} + href="/settings" + hx-get="/htmx/settings" + hx-target="#app-body" + hx-push-url="/settings" + {{ end }} + class="nav-link {{ if eq .NavBarActive "settings" }} active {{ end }}" + > + Settings + </a> + </li> + <li class="nav-item"> + <a id="nav-link-profile" + {{ if ne .NavBarActive "profile" }} + href="/users/{{ .AuthenticatedUser.Username }}" + hx-get="/htmx/users/{{ .AuthenticatedUser.Username }}" + hx-target="#app-body" + hx-push-url="/users/{{ .AuthenticatedUser.Username }}" + {{ end }} + class="nav-link {{ if eq .NavBarActive "profile" }} active {{ end }}" + > + <img class="user-pic" src="{{ .AuthenticatedUser.Image }}"> + {{ .AuthenticatedUser.Name }} + </a> + </li> + {{ end }} +</ul>
\ No newline at end of file diff --git a/cmd/web/templates/components/redirect.tmpl b/cmd/web/templates/components/redirect.tmpl new file mode 100644 index 0000000..1a706db --- /dev/null +++ b/cmd/web/templates/components/redirect.tmpl @@ -0,0 +1,6 @@ +<div id="htmx-redirect" + hx-target="{{ .HXTarget }}" + hx-trigger="{{ .HXTrigger }}" + hx-get="{{ .HXGet }}" + hx-swap-oob="true" +></div>
\ No newline at end of file |