From 6b7eda750275445f0f6112363a87792fd5584da7 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 16:23:13 -0500 Subject: Show player's sold auctions --- src/lib/sections/Auctions.svelte | 120 ++++++++++++++++++++++++++++ src/routes/player/[player]/[profile].svelte | 11 ++- 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 src/lib/sections/Auctions.svelte (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte new file mode 100644 index 0000000..63fe4a7 --- /dev/null +++ b/src/lib/sections/Auctions.svelte @@ -0,0 +1,120 @@ + + + +
+ {#if showingSoldAuctions} + {#await fetchApi(`playerauctions/${data.member.uuid}`, fetch).then(r => r.json())} + Loading... + {:then auctions} + {#if auctions.length > 0} +
+ {#each auctions as auction} + {#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid} +
+
+ +
+ +

+ {removeFormattingCode(auction.item.display.name)} + x{auction.item.count} +

+ {#if auction.bin} + Bin + {/if} +
+

Coins: {auction.coins.toLocaleString()}

+

{millisecondsToTime(auction.creationTimestamp)} ago

+ Buyer: +
+
+ {/if} + {/each} +
+ {/if} + {/await} + {:else} + + {/if} +
+ + + + diff --git a/src/routes/player/[player]/[profile].svelte b/src/routes/player/[player]/[profile].svelte index 82d5471..27e61de 100644 --- a/src/routes/player/[player]/[profile].svelte +++ b/src/routes/player/[player]/[profile].svelte @@ -83,6 +83,7 @@ import Toc from '$lib/Toc.svelte' import Achievements from '$lib/sections/Achievements.svelte' import Essence from '$lib/sections/Essence.svelte' + import Auctions from '$lib/sections/Auctions.svelte' export let data: CleanMemberProfile export let pack: MatcherFile @@ -203,7 +204,15 @@

{cleanId(category)}

- s.category === category)} /> + {#if category == 'auctions'} + s.category === category)} + {data} + {pack} + /> + {:else} + s.category === category)} /> + {/if}
{/if} -- cgit From c98d4c8ac700b89e10c785d887d49f078a6bb228 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 16:32:44 -0500 Subject: Make button toggle & redundant remove count --- src/lib/sections/Auctions.svelte | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index 63fe4a7..cf128c9 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -20,6 +20,12 @@
+ + {#if showingSoldAuctions} {#await fetchApi(`playerauctions/${data.member.uuid}`, fetch).then(r => r.json())} Loading... @@ -35,15 +41,14 @@

{removeFormattingCode(auction.item.display.name)} - x{auction.item.count}

{#if auction.bin} Bin {/if}

Coins: {auction.coins.toLocaleString()}

+

Buyer:

{millisecondsToTime(auction.creationTimestamp)} ago

- Buyer:
{/if} @@ -51,12 +56,6 @@ {/if} {/await} - {:else} - {/if} @@ -110,10 +109,6 @@ .item-slot-container { float: right; } - .auction-item-count { - color: var(--theme-darker-text); - font-weight: normal; - } .player-auctions-list-container { margin-top: 0.5em; } -- cgit From b4817dc7391beafa80e69c8e4ecc46e522be1962 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 16:37:57 -0500 Subject: Improve hide/show auctions button --- src/lib/sections/Auctions.svelte | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index cf128c9..827b06b 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -20,17 +20,17 @@
- - {#if showingSoldAuctions} {#await fetchApi(`playerauctions/${data.member.uuid}`, fetch).then(r => r.json())} Loading... {:then auctions} {#if auctions.length > 0} + +
{#each auctions as auction} {#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid} @@ -56,6 +56,12 @@
{/if} {/await} + {:else} + {/if}
-- cgit From ea48632e42370579580aabf57be4d5f3d895b951 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 16:41:18 -0500 Subject: Add commas to millisecondsToTime --- src/lib/utils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c094db4..be8c0fb 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -129,11 +129,11 @@ export function millisecondsToTime(totalMilliseconds: number, opts: Milliseconds const smallestUnit = opts.smallestUnit ?? 0 - if (totalDays > 1 && smallestUnit <= 4) stringUnits.push(days === 1 ? `${days} day` : `${days} days`) - if (totalHours > 1 && smallestUnit <= 3) stringUnits.push(hours === 1 ? `${hours} hour` : `${hours} hours`) - if (totalMinutes > 1 && smallestUnit <= 2) stringUnits.push(minutes === 1 ? `${minutes} minute` : `${minutes} minutes`) - if (totalSeconds > 1 && smallestUnit <= 1) stringUnits.push(seconds === 1 ? `${seconds} second` : `${seconds} seconds`) - if (totalMilliseconds > 0 && smallestUnit <= 0) stringUnits.push(`${milliseconds} ms`) + if (totalDays > 1 && smallestUnit <= 4) stringUnits.push(days === 1 ? `${days.toLocaleString()} day` : `${days.toLocaleString()} days`) + if (totalHours > 1 && smallestUnit <= 3) stringUnits.push(hours === 1 ? `${hours.toLocaleString()} hour` : `${hours.toLocaleString()} hours`) + if (totalMinutes > 1 && smallestUnit <= 2) stringUnits.push(minutes === 1 ? `${minutes.toLocaleString()} minute` : `${minutes.toLocaleString()} minutes`) + if (totalSeconds > 1 && smallestUnit <= 1) stringUnits.push(seconds === 1 ? `${seconds.toLocaleString()} second` : `${seconds.toLocaleString()} seconds`) + if (totalMilliseconds > 0 && smallestUnit <= 0) stringUnits.push(`${milliseconds.toLocaleString()} ms`) // comma separated, "and" before last -- cgit From 504c34660c80f605da38426a7e18b9849e1e9923 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 17:34:46 -0500 Subject: Put auctions sold list next to auction stats --- src/lib/sections/Auctions.svelte | 69 ++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index 827b06b..38fcbe9 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -16,21 +16,31 @@ export let pack: MatcherFile let onlyThisProfile = true - let showingSoldAuctions = false -
- {#if showingSoldAuctions} +
+
    + {#each stats.sort((a, b) => b.value - a.value) as stat} +
  • + {cleanId(stat.categorizedName)}: + + {#if stat.unit === 'time'} + {millisecondsToTime(stat.value)} + {:else} + {stat.value.toLocaleString()} + {/if} + +
  • + {/each} +
+ +
{#await fetchApi(`playerauctions/${data.member.uuid}`, fetch).then(r => r.json())} +

Auctions sold

Loading... {:then auctions} {#if auctions.length > 0} - - +

Auctions sold

{#each auctions as auction} {#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid} @@ -39,16 +49,16 @@
-

+

{removeFormattingCode(auction.item.display.name)} -

+ {#if auction.bin} Bin {/if}

Coins: {auction.coins.toLocaleString()}

Buyer:

-

{millisecondsToTime(auction.creationTimestamp)} ago

+

{millisecondsToTime(Date.now() - auction.creationTimestamp)} ago

{/if} @@ -56,30 +66,9 @@
{/if} {/await} - {:else} - - {/if} +
-
    - {#each stats.sort((a, b) => b.value - a.value) as stat} -
  • - {cleanId(stat.categorizedName)}: - - {#if stat.unit === 'time'} - {millisecondsToTime(stat.value)} - {:else} - {stat.value.toLocaleString()} - {/if} - -
  • - {/each} -
- -- cgit From 1a9887df01f8112c3c47f9cb0f4b28e69bdb7141 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 19:00:37 -0500 Subject: add pagination to auctions --- src/lib/Auction.svelte | 56 ++++++++++++++++++++++++ src/lib/sections/Auctions.svelte | 92 ++++++++++++++++------------------------ src/routes/items.svelte | 8 ++-- 3 files changed, 98 insertions(+), 58 deletions(-) create mode 100644 src/lib/Auction.svelte (limited to 'src') diff --git a/src/lib/Auction.svelte b/src/lib/Auction.svelte new file mode 100644 index 0000000..57d8cee --- /dev/null +++ b/src/lib/Auction.svelte @@ -0,0 +1,56 @@ + + +
+
+ +
+ +

+ {removeFormattingCode(auction.item.display.name)} +

+ {#if auction.bin} + Bin + {/if} +
+

Coins: {auction.coins.toLocaleString()}

+

Buyer:

+

{millisecondsToTime(Date.now() - auction.creationTimestamp)} ago

+
+
+ + diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index 38fcbe9..54f7cfe 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -10,12 +10,33 @@ import Item from '$lib/minecraft/Item.svelte' import type { MatcherFile } from 'skyblock-assets' import Username from '$lib/minecraft/Username.svelte' + import Auction from '$lib/Auction.svelte' + import { onMount } from 'svelte' export let data: CleanMemberProfile export let stats: StatItem[] export let pack: MatcherFile let onlyThisProfile = true + + let auctions: any[] = [] + let loading = true + + let page = 0 + + async function updateAuctions() { + loading = true + const thisPage = page + page += 1 + const auctionsResponse = await fetchApi( + `playerauctions/${data.member.uuid}?page=${thisPage}`, + fetch + ).then(r => r.json()) + loading = false + auctions = [...auctions, ...auctionsResponse.auctions] + } + + updateAuctions()
@@ -35,37 +56,24 @@
- {#await fetchApi(`playerauctions/${data.member.uuid}`, fetch).then(r => r.json())} + {#if loading || auctions.length > 0}

Auctions sold

- Loading... - {:then auctions} - {#if auctions.length > 0} -

Auctions sold

-
- {#each auctions as auction} - {#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid} -
-
- -
- -

- {removeFormattingCode(auction.item.display.name)} -

- {#if auction.bin} - Bin - {/if} -
-

Coins: {auction.coins.toLocaleString()}

-

Buyer:

-

{millisecondsToTime(Date.now() - auction.creationTimestamp)} ago

-
-
- {/if} - {/each} -
+ {/if} + {#if auctions.length > 0} +
+ {#each auctions as auction} + {#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid} + + {/if} + {/each} +
+ {#if !loading} + {/if} - {/await} + {/if} + {#if loading} + Loading... + {/if}
@@ -78,43 +86,17 @@ margin-top: 0.5em; width: max-content; } - p { - margin: 0; - } - .auction-stats-and-list-container { display: grid; grid-template-columns: 1fr auto; } - .auction-info-text { - color: var(--theme-darker-text); - } - .auction-info-text b { - color: var(--theme-main-text); - } - - .auction-item-name { - font-size: 1.5rem; - margin: 0; - } - - .auction { - border: 1px solid rgba(255, 255, 255, 0.1); - background: rgba(0, 0, 0, 0.1); - padding: 0.75em; - border-radius: 1em; - width: 18em; - } .player-auctions-list { display: flex; flex-wrap: wrap; column-gap: 0.5rem; row-gap: 0.5rem; } - .item-slot-container { - float: right; - } .player-auctions-list-container { margin-top: 0.5em; margin-left: 0.5em; diff --git a/src/routes/items.svelte b/src/routes/items.svelte index f836de0..82b3ee3 100644 --- a/src/routes/items.svelte +++ b/src/routes/items.svelte @@ -71,9 +71,11 @@

SkyBlock Item List

{filteredItems.length.toLocaleString()} items

-- cgit From 65a06e7c67292eaa18cb6c28956fa8744ef932e6 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 19:13:18 -0500 Subject: don't overflow for blurred background --- src/routes/player/[player]/[profile].svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/routes/player/[player]/[profile].svelte b/src/routes/player/[player]/[profile].svelte index 27e61de..de30c21 100644 --- a/src/routes/player/[player]/[profile].svelte +++ b/src/routes/player/[player]/[profile].svelte @@ -136,7 +136,7 @@ blurred={data.customization?.blurBackground ?? false} /> -
+
{#if data.customization?.blurBackground && backgroundUrl}
@@ -409,4 +409,8 @@ color: var(--theme-darker-text); font-size: 0.9rem; } + + .has-blurred-background #categories { + width: 47rem; + } -- cgit From 566fdbd2df59bdd5a68d6e29f121ba8d89d0ab59 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 19:13:46 -0500 Subject: Don't show "show more" button on last page --- src/lib/sections/Auctions.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index 54f7cfe..3db7cc0 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -23,6 +23,7 @@ let loading = true let page = 0 + let totalPages: number | undefined = undefined async function updateAuctions() { loading = true @@ -34,6 +35,7 @@ ).then(r => r.json()) loading = false auctions = [...auctions, ...auctionsResponse.auctions] + totalPages = auctionsResponse.pages } updateAuctions() @@ -67,7 +69,7 @@ {/if} {/each}
- {#if !loading} + {#if !loading && page != totalPages} {/if} {/if} -- cgit From 56a5049fe3aba1049b375f4838985404f0e0c354 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 19:25:55 -0500 Subject: Wrap "auctions sold" on small screens --- src/lib/sections/Auctions.svelte | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/lib/sections/Auctions.svelte b/src/lib/sections/Auctions.svelte index 3db7cc0..15c809f 100644 --- a/src/lib/sections/Auctions.svelte +++ b/src/lib/sections/Auctions.svelte @@ -93,6 +93,12 @@ grid-template-columns: 1fr auto; } + @media (max-width: 600px) { + .auction-stats-and-list-container { + grid-template-columns: 1fr; + } + } + .player-auctions-list { display: flex; flex-wrap: wrap; -- cgit From 84b6abd732d32b2a29a581faab19ba0fce86563f Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 1 Jul 2022 19:36:14 -0500 Subject: say if there's no buyer --- src/lib/Auction.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/Auction.svelte b/src/lib/Auction.svelte index 57d8cee..39f4904 100644 --- a/src/lib/Auction.svelte +++ b/src/lib/Auction.svelte @@ -21,7 +21,11 @@ {/if}

Coins: {auction.coins.toLocaleString()}

-

Buyer:

+ {#if auction.buyer} +

Buyer:

+ {:else} +

No buyer

+ {/if}

{millisecondsToTime(Date.now() - auction.creationTimestamp)} ago

-- cgit