Skip to content

Commit d6110ee

Browse files
authored
more of the christmas. (#159)
1 parent 8dd1765 commit d6110ee

File tree

7 files changed

+101
-31
lines changed

7 files changed

+101
-31
lines changed

app/components/SantaMatthias.vue

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
<template>
22
<img
3-
v-if="
4-
Interval.fromDateTimes(
5-
DateTime.fromISO(`${DateTime.now().year}-10-11T00:00:00Z`),
6-
DateTime.fromISO(`${DateTime.now().year}-12-31T23:59:59Z`)
7-
).contains(DateTime.utc())
8-
"
3+
v-if="isChristmas()"
94
:src="SantaMatthias"
105
alt=""
116
class="santa-matthias absolute right-0.75 -bottom-1.5 -z-10 motion-reduce:animate-none!"
127
/>
138
</template>
149

1510
<script setup lang="ts">
16-
import { DateTime, Interval } from 'luxon';
17-
import SantaMatthias from '~~/public/npc/santa_matthias3.webp';
11+
import isChristmas from '~/utils/isChristmas';
12+
import SantaMatthias from '~~/public/npc/santa_matthias_animated.webp';
1813
</script>
1914

2015
<style scoped>

app/pages/index.vue

Lines changed: 84 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,21 @@
7676
class="row-span-2"
7777
loading="lazy"
7878
format="avif,webp"
79-
src="/illustrations/tinkering-in-the-garden.png"
80-
sizes="150px md:300px"
79+
:src="
80+
isChristmas()
81+
? `/illustrations/tree-needs-power.png`
82+
: `/illustrations/tinkering-in-the-garden.png`
83+
"
84+
:sizes="isChristmas() ? '120px md:200px' : '150px md:300px'"
8185
alt="Mint tinkering in the garden"
8286
/>
8387
<p class="font-bold self-end">Aurrrr naurrr!!!</p>
8488
<p class="col-start-2">
8589
There was an error trying to fetch your scroll. Whack that reload
8690
button and try again.
91+
<NuxtLink to="/statistics#api-requests">
92+
Go here to check if Dragon Cave is having issues</NuxtLink
93+
>.
8794
</p>
8895
</div>
8996
<template v-else>
@@ -276,6 +283,33 @@
276283
/>
277284
</form>
278285

286+
<template v-if="isChristmas()">
287+
<div ref="formEnd" aria-hidden="true" class="h-px !m-0" />
288+
<Transition
289+
class="transition-opacity duration-300"
290+
enter-from-class="opacity-0"
291+
enter-to-class="opacity-100"
292+
>
293+
<div
294+
v-if="scrollUpdated && isChristmas()"
295+
class="px-4 max-w-prose justify-items-center text-center grid items-center gap-x-4 !mx-auto sm:grid-cols-[auto_1fr] sm:text-left sm:justify-items-start"
296+
>
297+
<NuxtPicture
298+
class="row-span-2"
299+
loading="lazy"
300+
format="avif,webp"
301+
src="/illustrations/wrapping-presents.png"
302+
sizes="120px md:200px"
303+
alt="Matthias wrapping eggs"
304+
/>
305+
<p class="font-bold self-end">{{ getUpdatedTexts() }}</p>
306+
<p class="col-start-2">
307+
While you're here... why not give the gift of clicks this Christmas?
308+
</p>
309+
</div>
310+
</Transition>
311+
</template>
312+
279313
<section class="space-y-2">
280314
<h2 class="text-2xl text-white">Seed tray</h2>
281315
<HatcheryView
@@ -364,14 +398,27 @@
364398

365399
<script lang="ts" setup>
366400
import { pluralise } from '#imports';
401+
import { useElementVisibility } from '@vueuse/core';
367402
import ScrollTable from '~/components/ScrollTable.vue';
368403
import WarningNewRelease from '~/components/WarningNewRelease.vue';
404+
import isChristmas from '~/utils/isChristmas';
369405
import type { userNotificationTable } from '~~/database/schema';
370406
import HappyMatthias from '~~/public/npc/happy_matthias.webp';
371407
372408
const { data: authData, signIn } = useAuth();
373409
const { userSettings } = useUserSettings(true);
374410
411+
const scrollUpdated = ref(false);
412+
413+
const savedDragons = reactive({
414+
seedTray: 0,
415+
garden: 0,
416+
});
417+
418+
const formEndVisible = useElementVisibility(useTemplateRef('formEnd'), {
419+
threshold: 0,
420+
});
421+
375422
const {
376423
data: scroll,
377424
execute: fetchScroll,
@@ -418,34 +465,33 @@ const {
418465
inGarden: dragon.inGarden,
419466
}))
420467
),
421-
onResponse({ response }) {
468+
async onResponse({ response }) {
422469
if (!response.ok) {
423470
toast.error('Failed to save your scroll. Please try again.');
471+
scrollUpdated.value = false;
424472
return;
425473
}
426474
427-
const seedTray = scroll.value.dragons.filter((dragon) => dragon.inSeedTray);
428-
const garden = scroll.value.dragons.filter((dragon) => dragon.inGarden);
429-
const texts = [];
475+
savedDragons.seedTray = scroll.value.dragons.filter(
476+
(dragon) => dragon.inSeedTray
477+
).length;
430478
431-
if (seedTray.length > 0) {
432-
texts.push(
433-
`${seedTray.length} ${pluralise('dragon', seedTray.length)} in the seed tray`
479+
savedDragons.garden = scroll.value.dragons.filter(
480+
(dragon) => dragon.inGarden
481+
).length;
482+
483+
scrollUpdated.value = true;
484+
485+
console.log('formEndVisible', formEndVisible.value);
486+
487+
if (!formEndVisible.value) {
488+
toast.success(
489+
`${getUpdatedTexts()} <img class="inline" src="${HappyMatthias}" alt="Happy Matthias" />`,
490+
{
491+
dangerouslyHTMLString: true,
492+
}
434493
);
435494
}
436-
437-
texts.push(
438-
`${garden.length > 0 ? garden.length : 'no'} ${pluralise('dragon', garden.length)} in the garden`
439-
);
440-
toast.success(
441-
'Scroll updated! You have ' +
442-
texts.join(' and ') +
443-
`. <img class="inline" src="${HappyMatthias}" alt="Happy Matthias" />`,
444-
{
445-
dangerouslyHTMLString: true,
446-
}
447-
);
448-
return;
449495
},
450496
});
451497
@@ -553,4 +599,20 @@ function toggleAll(checked: boolean) {
553599
}
554600
});
555601
}
602+
603+
function getUpdatedTexts(): string {
604+
const texts: string[] = [];
605+
606+
if (savedDragons.seedTray > 0) {
607+
texts.push(
608+
`${savedDragons.seedTray} ${pluralise('dragon', savedDragons.seedTray)} in the seed tray`
609+
);
610+
}
611+
612+
texts.push(
613+
`${savedDragons.garden > 0 ? savedDragons.garden : 'no'} ${pluralise('dragon', savedDragons.garden)} in the garden`
614+
);
615+
616+
return 'Scroll updated! You have ' + texts.join(' and ') + `.`;
617+
}
556618
</script>

app/pages/shop.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
front of you, propped up against the counter.
1919
</p>
2020
<img
21-
:src="`${path}/npc/matthias.webp`"
21+
:src="
22+
isChristmas()
23+
? `${path}/npc/santa_matthias_dressed.webp`
24+
: `${path}/npc/matthias.webp`
25+
"
2226
alt="Matthias the mint dragon"
2327
class="opacity-0 animate-[matthias-roll_2s_ease-in-out_forwards_1s]"
2428
height="34"
@@ -199,6 +203,7 @@
199203
import { itemUrl } from '#imports';
200204
import { DateTime } from 'luxon';
201205
import DialogFortuneCookie from '~/components/DialogFortuneCookie.vue';
206+
import isChristmas from '~/utils/isChristmas';
202207
import DragonDollar from '~~/public/other/dragon-dollar.webp';
203208
204209
useHead({

app/utils/isChristmas.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { DateTime, Interval } from 'luxon';
2+
3+
export default function () {
4+
return Interval.fromDateTimes(
5+
DateTime.fromISO(`${DateTime.now().year}-12-01T00:00:00Z`),
6+
DateTime.fromISO(`${DateTime.now().year}-12-31T23:59:59Z`)
7+
).contains(DateTime.utc());
8+
}
351 KB
Loading
1.29 KB
Loading
610 Bytes
Loading

0 commit comments

Comments
 (0)