Skip to content

Commit

Permalink
Add link to contest in jacob pb stats (#360)
Browse files Browse the repository at this point in the history
* link to contest in jacob pb stats

* remove popout

* format

* Cleanup and remove "Best Scores" label

---------

Co-authored-by: ptlthg <[email protected]>
Not-a-cowfr and ptlthg authored Jan 16, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent eef4ec3 commit 47289f4
Showing 2 changed files with 13 additions and 17 deletions.
28 changes: 12 additions & 16 deletions src/components/stats/jacob/jacob-crop-stats.svelte
Original file line number Diff line number Diff line change
@@ -20,8 +20,10 @@
}
function pb(crop: string) {
const amount = jacob?.stats?.personalBests?.[crop.replace(' ', '') as keyof typeof jacob.stats.personalBests];
return amount ? +amount : undefined;
const key = crop.replace(' ', '');
const amount = jacob?.stats?.personalBests?.[key as keyof typeof jacob.stats.personalBests];
const timestamp = jacob?.stats?.crops?.[key as keyof typeof jacob.stats.crops]?.personalBestTimestamp;
return { amount: amount ? +amount : undefined, timestamp: timestamp ? +timestamp : undefined };
}
const medals = ['bronze', 'silver', 'gold', 'platinum', 'diamond'];
@@ -32,8 +34,8 @@
}
const unique = $derived(medal(crop));
const score = $derived(pb(crop));
const ff = $derived(fortune(crop, score ?? 0));
const pbData = $derived(pb(crop));
const ff = $derived(fortune(crop, pbData?.amount ?? 0));
</script>

<div
@@ -43,18 +45,12 @@
<img src={PROPER_CROP_TO_IMG[crop]} alt="Crop" class="pixelated h-12 w-12 p-1" />

<div class="flex flex-col items-start gap-1">
<div>
<Popover.Mobile>
{#snippet trigger()}
<p class="text-lg font-semibold leading-none">
{score?.toLocaleString() ?? 'Not Set!'}
</p>
{/snippet}
<div>
<p>The highest placement earned for {crop}!</p>
</div>
</Popover.Mobile>
</div>
<a
href="/contest/{pbData.timestamp}"
class="text-lg font-semibold leading-none no-underline hover:underline"
>
{pbData.amount?.toLocaleString() ?? 'Not Set!'}
</a>

<Popover.Mobile>
{#snippet trigger()}
2 changes: 1 addition & 1 deletion src/components/stats/jacob/jacobinfo.svelte
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
</script>

<section class="mx-2 mb-8 flex-col justify-center gap-4 py-4 align-middle" aria-labelledby="Jacob">
<h1 id="Jacob" class="pt-2 text-center text-3xl">{ign} &nbsp;-&nbsp; Jacob Stats</h1>
<h1 id="Jacob" class="pt-2 text-center text-4xl">{ign} &nbsp;-&nbsp; Jacob Stats</h1>

<div class="my-8 flex flex-row items-center justify-center">
<Cropstats {jacob} />

0 comments on commit 47289f4

Please sign in to comment.