feat: bootstrap styling
This commit is contained in:
parent
d6e2008823
commit
67c46febca
|
|
@ -8,10 +8,11 @@ import (
|
|||
)
|
||||
|
||||
type ForeignWishlistProps struct {
|
||||
CurrentUserId string
|
||||
Username string
|
||||
UserReference string
|
||||
Gifts []db.Gift
|
||||
CurrentUserId string
|
||||
CurrentUserName string
|
||||
Username string
|
||||
UserReference string
|
||||
Gifts []db.Gift
|
||||
}
|
||||
|
||||
func (ctx *Context) ViewForeignWishlist(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -37,6 +38,6 @@ func (ctx *Context) ViewForeignWishlist(w http.ResponseWriter, r *http.Request)
|
|||
http.Error(w, "An error occurred while fetching this user's wishlist :(", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
p := ForeignWishlistProps{CurrentUserId: user.Id, Username: otherUser.Name, UserReference: userReference, Gifts: gifts}
|
||||
p := ForeignWishlistProps{CurrentUserId: user.Id, CurrentUserName: user.Name, Username: otherUser.Name, UserReference: userReference, Gifts: gifts}
|
||||
templates.Execute(w, "foreign_wishlist.gotmpl", p)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,20 @@
|
|||
<head>
|
||||
<title>Lishwist</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function getSubmissionNames(form) {
|
||||
return Array.from(new FormData(form).keys());
|
||||
|
|
@ -18,7 +32,21 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
{{template "body" .}}
|
||||
<div style="height: 100svh;" class="d-flex flex-column">
|
||||
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-brand">Lishwist</div>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||
{{template "navbar" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{template "body" .}}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -1,54 +1,83 @@
|
|||
{{define "body"}}
|
||||
<h1>Lishwist</h1>
|
||||
{{define "navbar"}}
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/">Home</a>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<section>
|
||||
<h2>{{.Username}}'s list</h2>
|
||||
{{with .Gifts}}
|
||||
<form method="post" action="/{{$.UserReference}}/update" autocomplete="off"
|
||||
onchange="acceptNames(this, 'claimSubmit', 'claimed', 'unclaimed'); acceptNames(this, 'completeSubmit', 'claimed');">
|
||||
<button id="claimSubmit" type="submit" name="mode" value="claim" disabled>Claim/Unclaim</button>
|
||||
<button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button>
|
||||
<ul>
|
||||
{{range .}}
|
||||
<li>
|
||||
<label>
|
||||
{{if .ClaimantId}}
|
||||
{{if eq .ClaimantId $.CurrentUserId}}
|
||||
<input type="checkbox" aria-describedby="wish_detail_{{.Id}}" name="claimed" value="{{.Id}}" {{if
|
||||
.Sent}}disabled{{end}}>
|
||||
{{else}}
|
||||
<input type="checkbox" aria-describedby="wish_detail_{{.Id}}" disabled>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<input type="checkbox" aria-describedby="wish_detail_{{.Id}}" name="unclaimed" value="{{.Id}}" {{if
|
||||
.Sent}}disabled{{end}}>
|
||||
{{end}}
|
||||
{{if .Sent}}
|
||||
<s>{{.Name}}</s>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
{{end}}
|
||||
</label>
|
||||
{{if .ClaimantId}}
|
||||
{{if eq .ClaimantId $.CurrentUserId}}
|
||||
<span id="wish_detail_{{.Id}}" style="color: blue;">{{if .Sent}}Completed{{else}}Claimed{{end}} by you</span>
|
||||
{{else}}
|
||||
<span id="wish_detail_{{.Id}}" style="color: red;">{{if .Sent}}Completed{{else}}Claimed{{end}} by
|
||||
{{.ClaimantName}}</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>They haven't wished for anything. Ask them to think of some stuff!</p>
|
||||
{{end}}
|
||||
</section>
|
||||
<div class="flex-grow-1"></div>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Logged in as '{{.CurrentUserName}}'
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<form class="d-contents" method="post" action="/logout">
|
||||
<button class="dropdown-item" type="submit">Logout</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
{{define "body"}}
|
||||
<div class="overflow-y-scroll">
|
||||
<div class="container pt-5">
|
||||
<section class="card">
|
||||
<div class="card-body">
|
||||
<h2>{{.Username}}'s list</h2>
|
||||
{{with .Gifts}}
|
||||
<form method="post" action="/{{$.UserReference}}/update" autocomplete="off"
|
||||
onchange="acceptNames(this, 'claimSubmit', 'claimed', 'unclaimed'); acceptNames(this, 'completeSubmit', 'claimed');">
|
||||
<button id="claimSubmit" class="btn btn-primary" type="submit" name="mode" value="claim"
|
||||
disabled>Claim/Unclaim</button>
|
||||
<button id="completeSubmit" class="btn btn-primary" type="submit" name="mode" value="complete"
|
||||
disabled>Complete</button>
|
||||
<ul class="list-group mt-3">
|
||||
{{range .}}
|
||||
<li class="list-group-item{{if .Sent}} list-group-item-light{{end}}">
|
||||
{{if .ClaimantId}}
|
||||
{{if eq .ClaimantId $.CurrentUserId}}
|
||||
<input id="foreignlist_select_{{.Id}}" class="form-check-input" type="checkbox"
|
||||
aria-describedby="wish_detail_{{.Id}}" name="claimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}>
|
||||
{{else}}
|
||||
<input id="foreignlist_select_{{.Id}}" class="form-check-input" type="checkbox"
|
||||
aria-describedby="wish_detail_{{.Id}}" disabled>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<input id="foreignlist_select_{{.Id}}" class="form-check-input" type="checkbox"
|
||||
aria-describedby="wish_detail_{{.Id}}" name="unclaimed" value="{{.Id}}" {{if .Sent}}disabled{{end}}>
|
||||
{{end}}
|
||||
<label class="form-check-label" for="foreignlist_select_{{.Id}}">
|
||||
{{if .Sent}}
|
||||
<s>{{.Name}}</s>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
{{end}}
|
||||
</label>
|
||||
{{if .ClaimantId}}
|
||||
{{if eq .ClaimantId $.CurrentUserId}}
|
||||
<span id="wish_detail_{{.Id}}" style="color: blue;">{{if .Sent}}Completed{{else}}Claimed{{end}} by
|
||||
you</span>
|
||||
{{else}}
|
||||
<span id="wish_detail_{{.Id}}" style="color: red;">{{if .Sent}}Completed{{else}}Claimed{{end}} by
|
||||
{{.ClaimantName}}</span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>They haven't wished for anything. Ask them to think of some stuff!</p>
|
||||
{{end}}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
@ -1,68 +1,95 @@
|
|||
{{define "navbar"}}
|
||||
<div class="flex-grow-1"></div>
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item"><button class="btn btn-success"
|
||||
onclick="navigator.clipboard.writeText('{{.HostUrl}}/{{.Reference}}'); alert('The share link to your wishlist has been copied to your clipboard. Share it with someone!');">Get
|
||||
a link to your wishlist</button></li>
|
||||
<li class="nav-item">
|
||||
<div class="dropdown">
|
||||
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Logged in as '{{.Username}}'
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<form class="d-contents" method="post" action="/logout">
|
||||
<button class="dropdown-item" type="submit">Logout</button>
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{{end}}
|
||||
|
||||
{{define "body"}}
|
||||
<p>Logged in as '{{.Username}}'</p>
|
||||
<form method="post" action="/logout">
|
||||
<input type="submit" value="Logout">
|
||||
</form>
|
||||
<h1>Lishwist</h1>
|
||||
<button
|
||||
onclick="navigator.clipboard.writeText('{{.HostUrl}}/{{.Reference}}'); alert('The share link to your wishlist has been copied to your clipboard.');">Get
|
||||
a link to your wishlist</button>
|
||||
<section>
|
||||
<h2>Your wishlist</h2>
|
||||
{{with .Gifts}}
|
||||
<form method="post" action="/wishlist/delete" onchange="acceptNames(this, 'deleteSubmit', 'gift')" autocomplete="off">
|
||||
<button id="deleteSubmit" type="submit" name="mode" value="delete" disabled>Delete</button>
|
||||
<ul>
|
||||
{{range .}}
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" name="gift" value="{{.Id}}">
|
||||
{{.Name}}
|
||||
</label>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>Your list is empty. Think of some things to add!</p>
|
||||
{{end}}
|
||||
<form method="post" action="/wishlist/add">
|
||||
<input name="gift_name" required>
|
||||
<button type="submit">Add gift idea</button>
|
||||
</form>
|
||||
</section>
|
||||
{{with .Todo}}
|
||||
<section>
|
||||
<h2>Your todo list</h2>
|
||||
<form method="post" action="/todo/update"
|
||||
onchange="acceptNames(this, 'unclaimSubmit', 'gift'); acceptNames(this, 'completeSubmit', 'gift')"
|
||||
autocomplete="off">
|
||||
<button id="unclaimSubmit" type="submit" name="mode" value="unclaim" disabled>Unclaim</button>
|
||||
<button id="completeSubmit" type="submit" name="mode" value="complete" disabled>Complete</button>
|
||||
<ul>
|
||||
{{range .}}
|
||||
<li>
|
||||
<label>
|
||||
{{if .Sent}}
|
||||
<input aria-describedby="todo_detail_{{.Id}}" type="checkbox" disabled>
|
||||
{{else}}
|
||||
<input type="checkbox" name="gift" value="{{.Id}}">
|
||||
{{end}}
|
||||
<em>
|
||||
{{if .Sent}}
|
||||
<s>{{.Name}}</s>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
<div class="overflow-y-scroll">
|
||||
<div class="container pt-5">
|
||||
<section class="card mb-4">
|
||||
<div class="card-body">
|
||||
<h2>Your wishlist</h2>
|
||||
{{with .Gifts}}
|
||||
<form method="post" action="/wishlist/delete" onchange="acceptNames(this, 'deleteSubmit', 'gift')"
|
||||
autocomplete="off">
|
||||
<button id="deleteSubmit" class="btn btn-primary mb-3" type="submit" name="mode" value="delete"
|
||||
disabled>Delete</button>
|
||||
<ul class="list-group mb-3">
|
||||
{{range .}}
|
||||
<li class="list-group-item">
|
||||
<input id="wishlist_select_{{.Id}}" class="form-check-input" type="checkbox" name="gift" value="{{.Id}}">
|
||||
<label class="form-check-label stretched-link" for="wishlist_select_{{.Id}}">
|
||||
{{.Name}}
|
||||
</label>
|
||||
</li>
|
||||
{{end}}
|
||||
</em>
|
||||
</label>
|
||||
<span id="todo_detail_{{.Id}}">
|
||||
for <a href="/{{.RecipientRef}}">{{.RecipientName}}</a>
|
||||
</span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
</section>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>Your list is empty. Think of some things to add!</p>
|
||||
{{end}}
|
||||
<form method="post" action="/wishlist/add">
|
||||
<div class="input-group">
|
||||
<input class="form-control" name="gift_name" required>
|
||||
<button class="btn btn-primary" type="submit">Add gift idea</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{{with .Todo}}
|
||||
<section class="card">
|
||||
<div class="card-body">
|
||||
<h2>Your todo list</h2>
|
||||
<form method="post" action="/todo/update"
|
||||
onchange="acceptNames(this, 'unclaimSubmit', 'gift'); acceptNames(this, 'completeSubmit', 'gift')"
|
||||
autocomplete="off">
|
||||
<button id="unclaimSubmit" class="btn btn-primary" type="submit" name="mode" value="unclaim"
|
||||
disabled>Unclaim</button>
|
||||
<button id="completeSubmit" class="btn btn-primary" type="submit" name="mode" value="complete"
|
||||
disabled>Complete</button>
|
||||
<ul class="list-group mt-3">
|
||||
{{range .}}
|
||||
<li class="list-group-item{{if .Sent}} list-group-item-light{{end}}">
|
||||
<input id="todo_select_{{.Id}}" class="form-check-input" type="checkbox" {{if .Sent}}
|
||||
aria-describedby="todo_detail_{{.Id}}" disabled{{else}} name="gift" value="{{.Id}}" {{end}}>
|
||||
<label for="todo_select_{{.Id}}" class="form-check-label">
|
||||
<em>
|
||||
{{if .Sent}}
|
||||
<s>{{.Name}}</s>
|
||||
{{else}}
|
||||
{{.Name}}
|
||||
{{end}}
|
||||
</em>
|
||||
</label>
|
||||
<span id="todo_detail_{{.Id}}">
|
||||
for <a href="/{{.RecipientRef}}">{{.RecipientName}}</a>
|
||||
</span>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
@ -1,14 +1,23 @@
|
|||
{{define "body"}}
|
||||
<form method="post">
|
||||
<label>
|
||||
Username
|
||||
<input name="username" required>
|
||||
</label>
|
||||
<label>
|
||||
Password
|
||||
<input name="password" type="password" required>
|
||||
</label>
|
||||
<input type="submit" value="Login">
|
||||
</form>
|
||||
<a href="/register">Register</a>
|
||||
{{define "navbar"}}
|
||||
{{end}}
|
||||
|
||||
{{define "body"}}
|
||||
<div class="flex-grow-1 d-flex justify-content-center align-items-center">
|
||||
<form method="post">
|
||||
<div class="d-flex flex-column gap-3">
|
||||
<label>
|
||||
Username
|
||||
<input class="form-control" name="username" required>
|
||||
</label>
|
||||
<label>
|
||||
Password
|
||||
<input class="form-control" name="password" type="password" required>
|
||||
</label>
|
||||
<div>
|
||||
<a href="/register">Register</a>
|
||||
</div>
|
||||
<input class="btn btn-primary" type="submit" value="Login">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
@ -1,17 +1,24 @@
|
|||
{{define "body"}}
|
||||
<form method="post" autocomplete="off">
|
||||
<label>
|
||||
Username
|
||||
<input name="username" required>
|
||||
</label>
|
||||
<label>
|
||||
Password
|
||||
<input name="newPassword" type="password" required>
|
||||
</label>
|
||||
<label>
|
||||
Confirm password
|
||||
<input name="confirmPassword" type="password" required>
|
||||
</label>
|
||||
<input type="submit" value="Register">
|
||||
</form>
|
||||
{{define "navbar"}}
|
||||
{{end}}
|
||||
|
||||
{{define "body"}}
|
||||
<div class="flex-grow-1 d-flex justify-content-center align-items-center">
|
||||
<form method="post">
|
||||
<div class="d-flex flex-column gap-3">
|
||||
<label>
|
||||
Username
|
||||
<input class="form-control" name="username" required>
|
||||
</label>
|
||||
<label>
|
||||
Password
|
||||
<input class="form-control" name="newPassword" type="password" required>
|
||||
</label>
|
||||
<label>
|
||||
Confirm password
|
||||
<input class="form-control" name="confirmPassword" type="password" required>
|
||||
</label>
|
||||
<input class="btn btn-primary" type="submit" value="Register">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{end}}
|
||||
Loading…
Reference in New Issue