From 1e9c33bc89ac150f7db49a37619e44fd30ddd056 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 2 Oct 2024 16:32:45 -0500 Subject: [PATCH] Colorize potential earn --- .../router/pages/components/marketForm.templ | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/server/router/pages/components/marketForm.templ b/server/router/pages/components/marketForm.templ index 9ca09a0..ef51ebf 100644 --- a/server/router/pages/components/marketForm.templ +++ b/server/router/pages/components/marketForm.templ @@ -4,6 +4,7 @@ import ( "fmt" "git.ekzyis.com/ekzyis/delphi.market/types" "strconv" + "math" ) templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) { @@ -18,14 +19,16 @@ templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) { >
- -
{ formatPrice(q.AvgPrice) }
- + +
{ formatPrice(q.AvgPrice, 3) }
+ - -
{ formatPrice(q.TotalPrice) }
- -
+{ formatPrice(q.Reward) }
+ +
{ formatPrice(q.TotalPrice, 3) }
+ + +{ formatPrice(q.Reward, 3) }
{ fmt.Sprint(uQ) }
@@ -61,6 +64,17 @@ func hxIndicator(outcome int) string { formId(outcome), formId(outcome), formId(outcome)) } -func formatPrice(p float64) string { - return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', 3, 64)) +func formatPrice(p float64, n int) string { + if p == 0 || math.IsNaN(p) { + return "0 sats" + } + return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', n, 64)) } + +func colorize(f float64) string { + eps := 1e-5 + if f-eps > 0 { + return "text-success" + } + return "text-reset" +} \ No newline at end of file