Compare commits
No commits in common. 'd90a835a278a4138f22ab45ca9a22b5ee5f958bc' and 'b38d62a787cf48c7333e46367924e6309914b59e' have entirely different histories.
d90a835a27
...
b38d62a787
@ -1,65 +1,18 @@
|
||||
<script setup lang="ts">
|
||||
const userOptionsCard = ref()
|
||||
const userIcon = ref()
|
||||
const showUserOptions = ref<Boolean>(false)
|
||||
|
||||
const toggleUserOptions = () => {
|
||||
showUserOptions.value = !showUserOptions.value
|
||||
const openUrl = (url: string) => {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
onClickOutside(
|
||||
userOptionsCard,
|
||||
() => {
|
||||
toggleUserOptions()
|
||||
},
|
||||
{ ignore: [userIcon] }
|
||||
)
|
||||
|
||||
const logout = async () => {
|
||||
await userLogout()
|
||||
useRouter().push('/login')
|
||||
}
|
||||
|
||||
type UserOption = {
|
||||
title: string
|
||||
function: () => void
|
||||
}
|
||||
|
||||
const userOptions: Array<UserOption> = [
|
||||
{
|
||||
title: 'Github',
|
||||
function: () => {
|
||||
openUrl('https://github.com/TZGyn')
|
||||
toggleUserOptions()
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Log Out',
|
||||
function: async () => {
|
||||
await logout()
|
||||
toggleUserOptions()
|
||||
},
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="fixed top-0 flex h-16 w-screen items-center justify-between border-b-2 border-b-lightgray bg-secondary px-4">
|
||||
class="bg-secondary border-b-lightgray fixed top-0 flex h-16 w-screen items-center justify-between border-b-2 px-4">
|
||||
<div class="flex gap-4">
|
||||
<Icon name="twitter" />
|
||||
<div class="font-bold"> Twitter Clone </div>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<Icon name="user" size="28" ref="userIcon" @click="toggleUserOptions()" />
|
||||
<div v-if="showUserOptions" ref="userOptionsCard"
|
||||
class="absolute right-0 top-8 w-max border border-lightgray bg-secondary">
|
||||
<div v-for="userOption in userOptions"
|
||||
class="w-full min-w-[120px] border border-lightgray p-4 text-center hover:bg-lightgray"
|
||||
@click="userOption.function()">
|
||||
{{ userOption.title }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<Icon name="github" @click="openUrl('https://github.com/TZGyn/twitter-clone')" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
const openUrl = (url: string) => {
|
||||
window.open(url, '_blank')
|
||||
}
|
||||
|
||||
export { openUrl }
|
||||
Loading…
Reference in New Issue