mirror of
https://github.com/ArthurDanjou/website.git
synced 2026-02-02 21:27:52 +01:00
Use NuxtUI tabs for my talents and bookmarks page
This commit is contained in:
@@ -21,15 +21,20 @@ const {
|
|||||||
watch: [isFavorite, getCategory],
|
watch: [isFavorite, getCategory],
|
||||||
})
|
})
|
||||||
|
|
||||||
function isCategory(category: string) {
|
|
||||||
return getCategory.value === category
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: getCategories,
|
data: getCategories,
|
||||||
} = await useFetch<Array<Category>>('/api/categories', { method: 'GET', query: { type: 'BOOKMARK' } })
|
} = await useFetch<Array<Category>>('/api/categories', { method: 'GET', query: { type: 'BOOKMARK' } })
|
||||||
getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug }))
|
getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug }))
|
||||||
|
|
||||||
|
const selected = computed({
|
||||||
|
get() {
|
||||||
|
return categories.value.findIndex(category => getCategory.value === category.slug) || 0
|
||||||
|
},
|
||||||
|
set(index) {
|
||||||
|
setCategory(categories.value[index].slug || categories.value[0].slug)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
function getColor() {
|
function getColor() {
|
||||||
return `text-${appConfig.ui.primary}-500`
|
return `text-${appConfig.ui.primary}-500`
|
||||||
@@ -46,26 +51,22 @@ function getColor() {
|
|||||||
You will find a selection of some of the most inspiring and complete content I have read through my research and work experience.
|
You will find a selection of some of the most inspiring and complete content I have read through my research and work experience.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="getCategories" class="sticky z-40 top-[4.8rem] pt-2 left-0 bg-white dark:bg-zinc-900 z-100 flex gap-2 w-full items-center justify-between pb-2 border-b border-zinc-100 dark:border-zinc-700/40 mb-4">
|
<div v-if="getCategories" class="sticky z-40 top-[4.8rem] pt-2 left-0 bg-white dark:bg-zinc-900 z-100 flex w-full items-center justify-between border-b border-zinc-100 dark:border-zinc-700/40 mb-4">
|
||||||
<div class="flex gap-2 overflow-x-scroll sm:overflow-x-hidden bg-gray-100 dark:bg-gray-800 rounded-lg p-1 relative">
|
<UTabs v-model="selected" :items="categories">
|
||||||
<div
|
<template #default="{ item, selected }">
|
||||||
v-for="category in categories"
|
<div class="flex items-center gap-2 relative truncate">
|
||||||
:key="category.slug"
|
<span class="truncate">{{ item.label }}</span>
|
||||||
class="relative px-3 py-1 text-sm font-medium rounded-md h-8 text-gray-500 dark:text-gray-400 min-w-fit flex items-center justify-center w-full focus:outline-none transition-colors duration-200 ease-out cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white"
|
<span v-if="selected" class="absolute -right-4 w-2 h-2 rounded-full bg-primary-500 dark:bg-primary-400" />
|
||||||
:class="{ 'text-gray-900 dark:text-white relative !bg-white dark:!bg-stone-900 rounded-md shadow-sm': isCategory(category.slug) }"
|
</div>
|
||||||
@click.prevent="setCategory(category.slug)"
|
</template>
|
||||||
>
|
</UTabs>
|
||||||
<p class="w-full">
|
|
||||||
{{ category.label }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<UPopover>
|
<UPopover>
|
||||||
<UButton
|
<UButton
|
||||||
:icon="isFavorite ? 'i-mdi-filter-variant-remove' : 'i-mdi-filter-variant'"
|
:icon="isFavorite ? 'i-mdi-filter-variant-remove' : 'i-mdi-filter-variant'"
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="soft"
|
variant="soft"
|
||||||
size="lg"
|
size="lg"
|
||||||
|
class="mb-2"
|
||||||
/>
|
/>
|
||||||
<template #panel>
|
<template #panel>
|
||||||
<div
|
<div
|
||||||
@@ -107,9 +108,6 @@ function getColor() {
|
|||||||
</div>
|
</div>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</h2>
|
</h2>
|
||||||
<p class="relative z-10 my-2 text-sm text-zinc-600 dark:text-zinc-400">
|
|
||||||
{{ bookmark.content }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ useHead({
|
|||||||
title: 'Discover new talents • Arthur Danjou',
|
title: 'Discover new talents • Arthur Danjou',
|
||||||
})
|
})
|
||||||
|
|
||||||
const categories = ref<Array<{ label: string, slug: string }>>([{ label: 'All', slug: 'all' }])
|
const categories = ref<Array<{ label: string, slug: string, id: number }>>([{ label: 'All', slug: 'all', id: 0 }])
|
||||||
const { getCategory, setCategory, isFavorite, toggleFavorite } = useTalentsStore()
|
const { getCategory, setCategory, isFavorite, toggleFavorite } = useTalentsStore()
|
||||||
const { loggedIn, clear } = useUserSession()
|
const { loggedIn, clear } = useUserSession()
|
||||||
|
|
||||||
@@ -23,14 +23,19 @@ const {
|
|||||||
watch: [isFavorite, getCategory],
|
watch: [isFavorite, getCategory],
|
||||||
})
|
})
|
||||||
|
|
||||||
function isCategory(category: string) {
|
|
||||||
return getCategory.value === category
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: getCategories,
|
data: getCategories,
|
||||||
} = await useFetch<Array<Category>>('/api/categories', { method: 'GET', query: { type: 'TALENT' } })
|
} = await useFetch<Array<Category>>('/api/categories', { method: 'GET', query: { type: 'TALENT' } })
|
||||||
getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug }))
|
getCategories.value!.forEach((category: any) => categories.value.push({ label: category.name, slug: category.slug, id: category.id }))
|
||||||
|
|
||||||
|
const selected = computed({
|
||||||
|
get() {
|
||||||
|
return categories.value.find(category => getCategory.value === category.slug)?.id || categories.value[0].id
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
setCategory(categories.value.find(category => category.id === value)?.slug || categories.value[0].slug)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
function getColor() {
|
function getColor() {
|
||||||
@@ -123,26 +128,22 @@ async function suggest() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="getCategories" class="sticky z-40 top-[4.8rem] pt-2 left-0 bg-white dark:bg-zinc-900 z-100 flex gap-2 w-full items-center justify-between pb-2 border-b border-zinc-100 dark:border-zinc-700/40 mb-4">
|
<div v-if="getCategories" class="sticky z-40 top-[4.8rem] left-0 bg-white dark:bg-zinc-900 z-100 flex gap-2 w-full items-center justify-between border-b border-zinc-100 dark:border-zinc-700/40">
|
||||||
<div class="flex gap-2 overflow-x-scroll sm:overflow-x-hidden bg-gray-100 dark:bg-gray-800 rounded-lg p-1 relative">
|
<UTabs v-model="selected" :items="categories">
|
||||||
<div
|
<template #default="{ item, selected }">
|
||||||
v-for="category in categories"
|
<div class="flex items-center gap-2 relative truncate">
|
||||||
:key="category.slug"
|
<span class="truncate">{{ item.label }}</span>
|
||||||
class="relative px-3 py-1 text-sm font-medium rounded-md h-8 text-gray-500 dark:text-gray-400 min-w-fit flex items-center justify-center w-full focus:outline-none transition-colors duration-200 ease-out cursor-pointer hover:bg-gray-200 dark:hover:bg-gray-700 hover:text-black dark:hover:text-white"
|
<span v-if="selected" class="absolute -right-4 w-2 h-2 rounded-full bg-primary-500 dark:bg-primary-400" />
|
||||||
:class="{ 'text-gray-900 dark:text-white relative !bg-white dark:!bg-stone-900 rounded-md shadow-sm': isCategory(category.slug) }"
|
</div>
|
||||||
@click.prevent="setCategory(category.slug)"
|
</template>
|
||||||
>
|
</UTabs>
|
||||||
<p class="w-full">
|
|
||||||
{{ category.label }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<UPopover>
|
<UPopover>
|
||||||
<UButton
|
<UButton
|
||||||
:icon="isFavorite ? 'i-mdi-filter-variant-remove' : 'i-mdi-filter-variant'"
|
:icon="isFavorite ? 'i-mdi-filter-variant-remove' : 'i-mdi-filter-variant'"
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="soft"
|
variant="soft"
|
||||||
size="lg"
|
size="lg"
|
||||||
|
class="mb-2"
|
||||||
/>
|
/>
|
||||||
<template #panel>
|
<template #panel>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user