CI / test (pull_request) Successful in 8m23s
Render reply trees with permission-aware inline controls, and move hunt, profile, voting, submission, and hiding flows to post storage.
38 lines
2.5 KiB
HTML
38 lines
2.5 KiB
HTML
{{define "vote"}}
|
|
<div id="vote-{{.Post.ID}}" class="vote">
|
|
{{if .User}}
|
|
<form method="post" action="/questions/{{.Post.ID}}/vote"
|
|
hx-post="/questions/{{.Post.ID}}/vote"
|
|
{{if eq .View "list"}}hx-target="#leaderboard" hx-swap="outerHTML"{{else}}hx-target="#vote-{{.Post.ID}}" hx-swap="outerHTML"{{end}}>
|
|
<input type="hidden" name="_csrf" value="{{.CSRF}}">
|
|
{{if eq .Post.UserVote 1}}<input type="hidden" name="value" value="0">{{else}}<input type="hidden" name="value" value="1">{{end}}
|
|
<input type="hidden" name="view" value="{{.View}}">
|
|
<input type="hidden" name="date" value="{{.Date}}">
|
|
<button type="submit" class="vote-btn{{if eq .Post.UserVote 1}} is-up{{end}}" aria-label="Upvote" aria-pressed="{{if eq .Post.UserVote 1}}true{{else}}false{{end}}">
|
|
<svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 3.5 15 12H3z" fill="currentColor"/></svg>
|
|
</button>
|
|
</form>
|
|
<span class="score" aria-label="Net score {{.Post.Score}}">{{.Post.Score}}</span>
|
|
<form method="post" action="/questions/{{.Post.ID}}/vote"
|
|
hx-post="/questions/{{.Post.ID}}/vote"
|
|
{{if eq .View "list"}}hx-target="#leaderboard" hx-swap="outerHTML"{{else}}hx-target="#vote-{{.Post.ID}}" hx-swap="outerHTML"{{end}}>
|
|
<input type="hidden" name="_csrf" value="{{.CSRF}}">
|
|
{{if eq .Post.UserVote -1}}<input type="hidden" name="value" value="0">{{else}}<input type="hidden" name="value" value="-1">{{end}}
|
|
<input type="hidden" name="view" value="{{.View}}">
|
|
<input type="hidden" name="date" value="{{.Date}}">
|
|
<button type="submit" class="vote-btn{{if eq .Post.UserVote -1}} is-down{{end}}" aria-label="Downvote" aria-pressed="{{if eq .Post.UserVote -1}}true{{else}}false{{end}}">
|
|
<svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 14.5 3 6h12z" fill="currentColor"/></svg>
|
|
</button>
|
|
</form>
|
|
{{else}}
|
|
<a class="vote-btn" href="/login" hx-get="/auth/prompt" hx-target="#flash" aria-label="Sign in to upvote">
|
|
<svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 3.5 15 12H3z" fill="currentColor"/></svg>
|
|
</a>
|
|
<span class="score" aria-label="Net score {{.Post.Score}}">{{.Post.Score}}</span>
|
|
<a class="vote-btn" href="/login" hx-get="/auth/prompt" hx-target="#flash" aria-label="Sign in to downvote">
|
|
<svg width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M9 14.5 3 6h12z" fill="currentColor"/></svg>
|
|
</a>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|