-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rework(AraTabs): tabs go to nested routes
* Each tab has its slug as a route parameter * Default redirect to first tab * History management between tabs * Better scroll behavior: * generally try to display tabs at the top of the screen when navigating between tabs * remember saved positions (mimics native browser behavior) * Dynamic scroll margin to always scroll to the proper position * Add a "useResizeObserver" (taken from vueuse project)
- Loading branch information
Showing
18 changed files
with
957 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script setup lang="ts"> | ||
/** Types */ | ||
interface AraTabsPanelSlots { | ||
default: () => void; | ||
} | ||
/** Slots */ | ||
defineSlots<AraTabsPanelSlots>(); | ||
/** Props */ | ||
const { panelId, labelledBy } = defineProps<{ | ||
panelId: string; | ||
labelledBy: string; | ||
}>(); | ||
</script> | ||
|
||
<template> | ||
<div | ||
:id="panelId" | ||
:aria-labelledby="labelledBy" | ||
role="tabpanel" | ||
tabindex="0" | ||
class="visible" | ||
> | ||
<slot name="default"></slot> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { type Component } from "vue"; | ||
|
||
import LayoutIcon from "../../components/icons/LayoutIcon.vue"; | ||
import { slugify } from "../../utils"; | ||
|
||
export class AraTabsTabData { | ||
label: string; | ||
#slug: string; // do not allow slug to be defined from outside | ||
icon: typeof LayoutIcon | undefined; | ||
component: Component; | ||
componentParams: object | undefined; | ||
|
||
constructor(data: { | ||
label: string; | ||
icon?: typeof LayoutIcon; | ||
component: Component; | ||
componentParams?: object; | ||
}) { | ||
const label = data.label; | ||
this.label = label; | ||
this.#slug = slugify(label); | ||
this.icon = data.icon; | ||
this.component = data.component; | ||
this.componentParams = data.componentParams; | ||
} | ||
|
||
// TODO: check how to expose "slug" to DevTools | ||
// Currently it is not exposed because #slug is private | ||
public get slug(): string { | ||
return this.#slug; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.