Added Header.vue

main
TZGyn 3 years ago
parent 675199c569
commit 3517dfae69
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -5,6 +5,8 @@ export default defineAppConfig({
aliases: { aliases: {
nuxt: 'logos:nuxt-icon', nuxt: 'logos:nuxt-icon',
loading: 'svg-spinners:90-ring-with-bg', loading: 'svg-spinners:90-ring-with-bg',
twitter: 'logos:twitter',
github: 'mdi:github',
}, },
}, },
}) })

@ -0,0 +1,18 @@
<script setup lang="ts">
const openUrl = (url: string) => {
window.open(url, '_blank')
}
</script>
<template>
<div
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>
<Icon name="github" @click="openUrl('https://github.com/TZGyn/twitter-clone')" />
</div>
</div>
</template>

@ -9,7 +9,7 @@ const props = defineProps<Post>()
<template> <template>
<div> <div>
<div class="flex w-full flex-col gap-6 bg-secondary p-6"> <div class="flex w-full flex-col gap-6 rounded-md border border-lightgray bg-secondary p-6">
<div class="h-full truncate text-xl font-bold"> <div class="h-full truncate text-xl font-bold">
{{ props.title }} {{ props.title }}
</div> </div>

@ -4,6 +4,7 @@ definePageMeta({
}) })
import { z } from 'zod' import { z } from 'zod'
type Posts = z.infer<typeof PostsValidator> type Posts = z.infer<typeof PostsValidator>
const posts = ref<Posts>([]) const posts = ref<Posts>([])
@ -29,6 +30,11 @@ const getPosts = async () => {
lastPost.value = posts.value[posts.value.length - 1].sequence lastPost.value = posts.value[posts.value.length - 1].sequence
} }
const logout = async () => {
await userLogout()
useRouter().push('/login')
}
onMounted(() => { onMounted(() => {
getPosts() getPosts()
}) })
@ -36,9 +42,9 @@ onMounted(() => {
<template> <template>
<div> <div>
<!-- {{ posts }} --> <Header />
<div class="flex w-full items-center justify-center"> <div class="mt-16 flex w-full items-center justify-center">
<div class="flex w-1/2 flex-col gap-4 px-4 pb-10 pt-2 2xl:w-1/3"> <div class="flex w-1/2 flex-col gap-4 px-4 pb-10 pt-4 2xl:w-1/3">
<div v-if="posts" v-for="post in posts"> <div v-if="posts" v-for="post in posts">
<PostCard :title="post.title" :description="post.description" /> <PostCard :title="post.title" :description="post.description" />
</div> </div>

Loading…
Cancel
Save