-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
82 lines (70 loc) · 2.79 KB
/
app.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
<template>
<Html v-bind:class="colorMode.value">
<!-- Made with ❤️ by Amelia (@[email protected]). -->
<!-- Using Nuxt, Tailwind, Vue and Vite. -->
<!-- Color maps & Gradient Logic are taken from Xenni's color helper. -->
<Head>
<Title>Amelia's Nickname Helper :D</Title>
</Head>
<Body class="latte dark:macchiato bg-crust text-text h-[100vh]">
<div v-if="!randomGradient" class="h-4 w-full bg-mantle"></div>
<div v-if="randomGradient" class="h-4 w-full" :style="getGradient(randomGradient.colors)"></div>
<div class="mx-auto max-w-5xl p-2" :class="modal ? `overflow-clip` : `overflow-x-scroll`">
<h1 class="mb-2 text-center text-4xl font-bold">
<span class="font-extrabold text-pink">Amelia</span>'s Nickname Helper
</h1>
<nuxt-page />
<div class="h-4"></div>
<block>
<div class="flex items-center justify-between">
<p class="text-center font-semibold">
Made with ❤️ by Amelia.
</p>
<Switch v-model="vModel" @update:model-value="updatePref" :class="$colorMode.preference === 'dark' ? 'bg-pink' : 'bg-text dark:bg-base'
" class="relative inline-flex h-8 w-14 items-center rounded-full">
<span class="sr-only">Theme</span>
<span :class="$colorMode.preference === 'dark'
? 'translate-x-7'
: 'translate-x-1'
" class="inline-block h-6 w-6 transform items-center rounded-full bg-mantle dark:bg-text transition">
<div class="flex h-full w-full items-center justify-center">
<Icon :name="colorMode.preference === 'dark'
? 'material-symbols:dark-mode-rounded'
: 'material-symbols:light-mode'
" class="text-lg font-semibold text-text dark:text-mantle transition-all duration-500" size="20" />
</div>
</span>
</Switch>
</div>
</block>
</div>
</Body>
</Html>
</template>
<script setup lang="ts">
import "@/assets/css/tailwind.css";
import type { PrideColor } from "./utils/types";
import { Switch } from "@headlessui/vue";
const colorMode = useColorMode();
const modal = useModal();
const randomGradient = useState<PrideColor | null>("random", () => null);
const updatePref = () => {
colorMode.preference = colorMode.preference === "dark" ? "light" : "dark";
};
const vModel = colorMode.preference === "dark";
onMounted(() => {
const all = [...usePrideColors()];
randomGradient.value = all[Math.floor(Math.random() * all.length)];
});
const getGradient = (colors: string[]) => {
return `background: linear-gradient(90deg, ${colors
.map((x, index) => {
const color = useRGB(x).join(",");
const firstPercentage = index === 0 ? 0 : (100 / colors.length) * index;
const lastPercentage =
index === colors.length - 1 ? 100 : (100 / colors.length) * (index + 1);
return `rgb(${color}) ${firstPercentage}% ${lastPercentage}%`;
})
.join(",")});`;
}
</script>