From 64bcead0b2884de91de1547cb543e28d5607d69b Mon Sep 17 00:00:00 2001 From: wireless_purple Date: Fri, 4 Oct 2024 20:25:22 +0000 Subject: [PATCH] show offers on /markets, fixes for pairs without trades --- src/lib/formatPrice.js | 1 + src/routes/+layout.svelte | 13 +++++---- src/routes/market/[market]/+page.svelte | 12 ++++---- src/routes/markets/+page.server.js | 4 +-- src/routes/markets/+page.svelte | 38 ++++++++++++++++++++----- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/lib/formatPrice.js b/src/lib/formatPrice.js index 6c98ae6..aba4143 100644 --- a/src/lib/formatPrice.js +++ b/src/lib/formatPrice.js @@ -37,6 +37,7 @@ const formatPrice = ( showSign = false, useQuote = true, ) => { + if (!price) return Number.NaN; const calculatedPrice = getPrice(price, currency, useQuote); return ( (showSign diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 9a6d9ae..9639a03 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -71,7 +71,7 @@ Object.groupBy ||= (values, keyFinder) => { margin-top:auto; text-align:center; } - .col{ + .col { display:flex; flex-direction: column; align-items: center; @@ -108,12 +108,15 @@ Object.groupBy ||= (values, keyFinder) => { text-align:right; padding:.3em; } - th:first-child, td:first-child{ + th:first-child, td:first-child { text-align:left; } - tr:nth-child(2n){ + tbody tr:nth-child(2n) { background-color: #0002; } + tfoot { + border-top: #0004 double 4px; + } } } @@ -121,7 +124,7 @@ Object.groupBy ||= (values, keyFinder) => { text-decoration: none; color:#f60; } - a:hover{ + a:hover { text-decoration: underline; } .price { @@ -159,7 +162,7 @@ Object.groupBy ||= (values, keyFinder) => { justify-content: center; gap:.2em; } - @media only screen and (max-width: 600px){ + @media only screen and (max-width: 600px) { .header > * { width:initial; } diff --git a/src/routes/market/[market]/+page.svelte b/src/routes/market/[market]/+page.svelte index e67aeb1..2125983 100644 --- a/src/routes/market/[market]/+page.svelte +++ b/src/routes/market/[market]/+page.svelte @@ -72,11 +72,13 @@ const BUY_SELL = isMoneroQuote(market) ? ["SELL", "BUY"] : ["BUY", "SELL"];

{marketPair}

- {formatPrice(data.trades?.[0]?.price, market, true, false)} - - - - + {formatPrice(data.trades?.[0]?.price, market, true, false) || "-"} + {#if data.trades?.length} + + + + + {/if}
diff --git a/src/routes/markets/+page.server.js b/src/routes/markets/+page.server.js index a86a2b6..84f7fa0 100644 --- a/src/routes/markets/+page.server.js +++ b/src/routes/markets/+page.server.js @@ -1,6 +1,6 @@ -import { trades } from "$lib/server/context"; +import { offers, trades } from "$lib/server/context"; import { get } from "svelte/store"; export function load() { - return { trades: get(trades) }; + return { trades: get(trades), offers: get(offers) }; } diff --git a/src/routes/markets/+page.svelte b/src/routes/markets/+page.svelte index 15f077a..fd52582 100644 --- a/src/routes/markets/+page.svelte +++ b/src/routes/markets/+page.svelte @@ -1,6 +1,6 @@