-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.vue
94 lines (88 loc) · 3.08 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
83
84
85
86
87
88
89
90
91
92
93
94
<script setup lang="ts">
import MenuItem from '@/components/MenuItem.vue'
import ActionButton from '@/components/ActionButton.vue'
import { login, logout, useUser } from '@/store/auth'
import type { GithubUser, AnonymousUser } from '@/server/trpc/context'
const { pending, data } = await useUser()
// Hopefully there is a better way to do this
// Looks like nuxt-trpc infers the type incorrectly
const user = computed<GithubUser | AnonymousUser | null>(() => {
const user = data.value as GithubUser | AnonymousUser | null
if (user && 'githubId' in user) {
return user as GithubUser
}
return user
})
useHead({
title: 'Karteikasten | Atomic Learning',
})
</script>
<template>
<div class="min-h-screen bg-slate-100">
<header
class="flex items-center gap-3 p-2 justify-between sticky top-0 z-10 bg-slate-50 border-b border-slate-200"
>
<NuxtLink to="/" class="text-purple-600 flex gap-1 items-center pl-2">
<div
class="bg-fuchsia-600 h-7 w-7 flex items-center shrink-0 justify-center mr-1 rounded-md text-fuchsia-100 border border-fuchsia-700"
>
<mdicon name="school" size="20" />
</div>
<span class="font-bold text-purple-800 inline-block">Karteikasten</span>
<span class="hidden sm:inline">|</span>
<span class="hidden sm:inline">Atomic Learning</span>
</NuxtLink>
<div class="flex items-center gap-8">
<nav class="flex items-center gap-2 hidden md:block">
<MenuItem to="/">Your Boxes</MenuItem>
<MenuItem to="/about">About</MenuItem>
</nav>
<nav class="flex items-center justify-end gap-2 w-48">
<Transition
enter-active-class="duration-200 ease-in"
enter-from-class="transform opacity-0"
enter-to-class="opacity-100"
>
<div v-if="!pending && user">
<ActionButton
@click="login"
size="small"
v-if="!user || !('githubId' in user)"
>
Login with GitHub
</ActionButton>
<ActionButton @click="logout" size="small" v-else>
<img
:src="user.avatarUrl"
class="w-5 rounded-full border border-slate-300 mr-2"
/>
Logout
</ActionButton>
</div>
</Transition>
<a
href="https://github.com/visualjerk/karteikasten"
class="flex px-2 py-1 text-slate-600 hover:text-slate-800"
title="Open GitHub Repo"
target="_blank"
>
<mdicon name="github" />
</a>
</nav>
</div>
</header>
<main class="py-6 sm:py-10 px-4 max-w-screen-md m-auto">
<NuxtPage />
</main>
<footer class="p-8 flex justify-center items-center gap-1 text-slate-500">
Built by
<a
href="https://twitter.com/visual_jerk"
target="_blank"
class="inline-flex items-center"
>
<mdicon name="twitter" size="20" /> visualjerk
</a>
</footer>
</div>
</template>