delphi.market/server/router/pages/market.templ

69 lines
2.1 KiB
Plaintext

package pages
import (
"git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components"
"git.ekzyis.com/ekzyis/delphi.market/types"
"github.com/dustin/go-humanize"
)
// TODO: Add countdown? Use or at least show somewhere precise timestamps?
templ Market(m types.Market, p0 []types.Point, p1 []types.Point, quoteNo types.MarketQuote, quoteYes types.MarketQuote, uQuantityNo int, uQuantityYes int) {
<html>
@components.Head()
<body
x-data="{ outcome: undefined }"
class="container"
hx-preserve
>
@components.Nav()
<div id="content" class="flex flex-col">
<div class="text-center font-bold my-1 mt-3">{ m.Question }</div>
<div class="text-center text-muted my-1">{ humanize.Time(m.EndDate) }</div>
<div class="text-center text-muted my-1"></div>
<div
class="none"
id="chart-data"
chart-data-p0={ templ.JSONString(p0) }
chart-data-p1={ templ.JSONString(p1) }
></div>
<div class="flex justify-center w-full max-h-64 my-3"><canvas id="chart"></canvas></div>
<script src="/js/chart.min.js"></script>
<blockquote class="p-4 mb-4 border-s-4 border-muted">
if m.Description != "" {
{ m.Description }
} else {
&lt;empty&gt;
}
<div class="text-muted text-right pt-4">― { m.User.Name }, { humanize.Time(m.CreatedAt) }</div>
</blockquote>
<div class="flex flex-col justify-center my-1">
<div class="flex flex-row justify-center">
<button
class="neon success mx-1"
x-on:click="outcome = outcome === 1 ? undefined : 1"
:class="{ 'active' : outcome === 1 }"
>
BET YES
</button>
<button
class="neon error mx-1"
x-on:click="outcome = outcome === 0 ? undefined : 0"
:class="{ 'active' : outcome === 0 }"
>
BET NO
</button>
</div>
<div class="mx-auto my-5" x-show="outcome === 1">
@components.MarketForm(m, 1, quoteYes, uQuantityYes)
</div>
<div class="mx-auto my-5" x-show="outcome === 0">
@components.MarketForm(m, 0, quoteNo, uQuantityNo)
</div>
</div>
</div>
@components.Modal(nil)
@components.Footer()
</body>
</html>
}