Skip to content

Commit

Permalink
Use segmented control as tab (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: Thibaud Dauce <[email protected]>
  • Loading branch information
nicolaskempf57 and ThibaudDauce authored Dec 16, 2024
1 parent e9342aa commit 6daf0db
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 29 deletions.
33 changes: 22 additions & 11 deletions components/TabLinks.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<template>
<nav class="flex px-8 border-b space-x-2 font-bold">
<NuxtLinkLocale
v-for="link in links"
:key="link.label"
:to="link.href"
class="bloc bg-blue-light hover:!bg-blue-tint px-4 py-2 no-underline border-x border-t !border-transparent -mb-px outline-none !bg-none aria-current-page:bg-white aria-current-page:!border-gray-200 aria-current-page:hover:!bg-white"
:aria-current="isCurrent(link.href) ? 'page': false"
>
{{ link.label }}
</NuxtLinkLocale>
</nav>
<div class="flex justify-start">
<nav class="flex space-x-1 font-medium rounded border border-neutral-300">
<NuxtLinkLocale
v-for="link in links"
:key="link.label"
:to="link.href"
class="group block rounded !bg-none !bg-transparent !border border-transparent -m-px no-underline outline-none aria-current-page:border aria-current-page:!border-primary aria-current-page:text-primary p-1"
:aria-current="isCurrent(link.href) ? 'page': false"
>
<span class="rounded px-2 ">
{{ link.label }}
</span>
</NuxtLinkLocale>
</nav>
</div>
</template>

<script setup lang="ts">
Expand All @@ -24,3 +28,10 @@ const isCurrent = (href: string) => {
return localePath(href) === route.fullPath
}
</script>

<style scoped>
.group:not([aria-current='page']):hover span {
/* Could maybe be replaced by group-hover-not-aria-current-page:bg-white/50 ? */
background-color: rgba(255, 255, 255, 0.5);
}
</style>
5 changes: 3 additions & 2 deletions pages/beta/admin/datasets/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
</Breadcrumb>

<div v-if="dataset">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataset.title }}
</h1>
<a
Expand All @@ -51,6 +51,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDatasetAdminUrl(dataset), label: t('Metadata') },
{ href: `${getDatasetAdminUrl(dataset)}/files`, label: t('Files') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/me/dataservices/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</Breadcrumb>

<div v-if="dataservice">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataservice.title }}
</h1>
<a
Expand All @@ -41,6 +41,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDataserviceAdminUrl(dataservice), label: t('Metadata') },
{ href: `${getDataserviceAdminUrl(dataservice)}/datasets`, label: t('Datasets') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/me/datasets/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</Breadcrumb>

<div v-if="dataset">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataset.title }}
</h1>
<a
Expand All @@ -33,6 +33,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDatasetAdminUrl(dataset), label: t('Metadata') },
{ href: `${getDatasetAdminUrl(dataset)}/files`, label: t('Files') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/me/reuses/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</Breadcrumb>

<div v-if="reuse">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ reuse.title }}
</h1>
<a
Expand All @@ -41,6 +41,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getReuseAdminUrl(reuse), label: t('Metadata') },
{ href: `${getReuseAdminUrl(reuse)}/datasets`, label: t('Datasets') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/organizations/[oid]/dataservices/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</Breadcrumb>

<div v-if="dataservice">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataservice.title }}
</h1>
<a
Expand All @@ -49,6 +49,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDataserviceAdminUrl(dataservice), label: t('Metadata') },
{ href: `${getDataserviceAdminUrl(dataservice)}/datasets`, label: t('Datasets') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/organizations/[oid]/datasets/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</Breadcrumb>

<div v-if="dataset">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataset.title }}
</h1>
<a
Expand All @@ -49,6 +49,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDatasetAdminUrl(dataset), label: t('Metadata') },
{ href: `${getDatasetAdminUrl(dataset)}/files`, label: t('Files') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/organizations/[oid]/reuses/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
</Breadcrumb>

<div v-if="reuse">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ reuse.title }}
</h1>
<a
Expand All @@ -49,6 +49,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getReuseAdminUrl(reuse), label: t('Metadata') },
{ href: `${getReuseAdminUrl(reuse)}/datasets`, label: t('Datasets') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/site/dataservices/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</Breadcrumb>

<div v-if="dataservice">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ dataservice.title }}
</h1>
<a
Expand All @@ -41,6 +41,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getDataserviceAdminUrl(dataservice), label: t('Metadata') },
{ href: `${getDataserviceAdminUrl(dataservice)}/datasets`, label: t('Datasets') },
Expand Down
5 changes: 3 additions & 2 deletions pages/beta/admin/site/reuses/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
</Breadcrumb>

<div v-if="reuse">
<div class="flex items-center justify-between">
<h1 class="fr-h3 fr-mb-5v">
<div class="flex items-center justify-between mb-5">
<h1 class="fr-h3 !mb-0">
{{ reuse.title }}
</h1>
<a
Expand All @@ -41,6 +41,7 @@
</div>

<TabLinks
class="mb-5"
:links="[
{ href: getReuseAdminUrl(reuse), label: t('Metadata') },
{ href: `${getReuseAdminUrl(reuse)}/datasets`, label: t('Datasets') },
Expand Down

0 comments on commit 6daf0db

Please sign in to comment.