-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.vue
114 lines (103 loc) · 2.86 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<IonApp>
<IonSplitPane content-id="main-content" when="xl">
<IonMenu content-id="main-content" type="overlay">
<IonContent>
<IonList id="inbox-list">
<IonMenuToggle
:auto-hide="false"
v-for="(p, i) in appPages"
:key="i"
>
<IonItem
@click="go(i)"
router-direction="root"
lines="none"
:detail="false"
class="hydrated"
:class="{ selected: selectedIndex === i }"
>
<IonIcon
aria-hidden="true"
slot="start"
:ios="p.iosIcon"
:md="p.mdIcon"
></IonIcon>
<IonLabel>{{ p.title }}</IonLabel>
</IonItem>
<IonItem v-if="!loggedIn" @click="goToLogin">
<IonIcon
aria-hidden="true"
slot="start"
:ios="logInOutline"
></IonIcon>
<IonLabel>Log in</IonLabel>
</IonItem>
</IonMenuToggle>
</IonList>
<IonList id="labels-list" v-if="loggedIn">
<IonItem>
<IonButton @click="doUserLogout">Log out</IonButton>
</IonItem>
<IonItem> Logged in as: {{ data?.user?.email }} </IonItem>
</IonList>
</IonContent>
</IonMenu>
<IonRouterOutlet id="main-content"></IonRouterOutlet>
</IonSplitPane>
</IonApp>
</template>
<script setup>
const router = useIonRouter();
const { auth } = useSupabaseAuthClient();
const { data, error } = await auth.getUser();
const loggedIn = computed(() => {
return !!data?.user;
});
const goToLogin = () => {
router.navigate("/login");
};
const doUserLogout = async () => {
await auth.signOut();
await router.navigate("/login");
};
import { homeOutline, homeSharp, logInOutline } from "ionicons/icons";
const selectedIndex = ref(0);
const appPages = [
{
title: "Events",
url: "/events",
iosIcon: homeOutline,
mdIcon: homeSharp,
},
];
const go = (index) => {
selectedIndex.value = index;
router.navigate(appPages[index].url);
};
//
// const path = window.location.pathname;
// if (typeof path === "undefined") {
// selectedIndex.value = appPages.findIndex(
// (page) => page.path.toLowerCase() === path.toLowerCase()
// );
// }
</script>
<style scoped>
:root {
--ion-color-primary-rgb: rgb(55, 255, 55);
--ion-color-primary: #37ff37;
}
ion-menu.md ion-item.selected {
--background: rgba(var(--ion-color-primary-rgb), 0.14);
}
ion-menu.md ion-item.selected ion-icon {
color: var(--ion-color-primary);
}
ion-item.selected ion-label {
--color: var(--ion-color-primary) !important;
}
ion-menu.ios ion-item.selected ion-icon {
color: var(--ion-color-primary);
}
</style>