-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.vue
144 lines (126 loc) · 3.85 KB
/
index.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<script setup lang="ts">
/* eslint-disable import/first, import/no-duplicates */
import { ref, useMeta as useHead, useContext } from '@nuxtjs/composition-api';
import confetti from 'canvas-confetti';
import sleep from 'sleep-promise';
import useGtag from '~/composables/useGtag';
import useDarkMode from '~/composables/useDarkMode';
import useGameInfo from '~/composables/useGameInfo';
import useSheetDialog from '~/composables/useSheetDialog';
import sites from '~/data/sites.json';
import { RICK_SHEET } from '~/utils';
const context = useContext();
const gtag = useGtag();
const { isDarkMode } = useDarkMode();
const { gameCode } = useGameInfo();
const { viewSheet } = useSheetDialog();
const toggleDuration = 5000;
const toggle = ref(isDarkMode.value);
const toggleTimeoutId = ref<number | undefined>(undefined);
async function toggleLightSwitch(buttonPressed: boolean) {
if (Math.random() < 1) return;
window.clearTimeout(toggleTimeoutId.value);
toggleTimeoutId.value = undefined;
toggle.value = buttonPressed ? !isDarkMode.value : isDarkMode.value;
toggleTimeoutId.value = window.setTimeout(async () => {
if (isDarkMode.value === toggle.value) return;
isDarkMode.value = toggle.value;
if (isDarkMode.value) {
await sleep(1000);
viewSheet(RICK_SHEET);
confetti({ particleCount: 100, spread: 60, origin: { y: 0.6 }, zIndex: 999 });
gtag('event', 'SecretFound', { gameCode: gameCode.value, eventSource: 'IndexPage', no: 1 });
}
}, toggleDuration);
}
useHead(() => ({
titleTemplate: '%s',
title: `${context.$config.siteTitle}`,
}));
</script>
<script lang="ts">
import { defineComponent } from '@nuxtjs/composition-api';
export default defineComponent({
name: 'IndexPage',
head: {},
});
</script>
<template>
<v-container class="fill-height pa-4 pa-sm-8">
<v-row class="align-center">
<v-col cols="12" md="6" class="text-center" style="user-select: none;">
<link v-if="toggle" rel="preload" :href="RICK_SHEET.imageUrl" as="image">
<v-icon
:size="120"
class="MagicLogo__icon my-6"
:class="{ 'MagicLogo__icon--active': toggle, 'MagicLogo__icon--dark': isDarkMode }"
:style="{ 'transition': `transform ${toggleDuration}ms !important` }"
@pointerdown="toggleLightSwitch(true);"
@pointerup="toggleLightSwitch(false);"
@pointerleave="toggleLightSwitch(false);"
>
mdi-music-box-multiple
</v-icon>
<h1 class="mb-5">
<span>arcade-songs</span>
</h1>
<p v-text="$t('page.index.description')" />
</v-col>
<v-col cols="12" md="6">
<v-list
nav
max-width="500px"
class="mx-auto"
>
<v-list-item
v-for="(site, i) in sites.filter((e) => !e.isHidden || isDarkMode)"
:key="i"
:to="{ name: 'gameCode', params: { gameCode: site.gameCode }}"
class="SiteList__item px-4"
>
<v-list-item-icon>
<v-icon :color="site.themeColor">
mdi-music-box-multiple
</v-icon>
</v-list-item-icon>
<v-list-item-title>
{{ site.gameTitle }}
</v-list-item-title>
<v-list-item-icon class="SiteList__arrow">
<v-icon>mdi-arrow-right</v-icon>
</v-list-item-icon>
</v-list-item>
</v-list>
</v-col>
</v-row>
</v-container>
</template>
<style lang="scss">
.SiteList {
&__arrow {
opacity: 0;
transition: opacity 0.5s;
}
&__item:hover &__arrow {
opacity: 1;
}
}
.MagicLogo {
&__icon {
&::before {
transition: color 1000ms;
}
&::after {
display: none !important;
}
&--dark {
&::before {
color: yellow;
}
}
&--active {
transform: rotateZ(+5.125turn);
}
}
}
</style>