-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devtools): add tabs + fancy glassmorphism background
- Loading branch information
1 parent
63ac9d3
commit 6d4617f
Showing
3 changed files
with
158 additions
and
11 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
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,59 @@ | ||
<template> | ||
<div class="f-debug-tabs"> | ||
<div class="f-debug-tabs__header"> | ||
<div | ||
v-for="tab in tabs" | ||
:key="tab" | ||
class="f-debug-tabs__tab" | ||
:class="{ | ||
active: tab === selectedTabId, | ||
}" | ||
@click="selectTab(tab)" | ||
> | ||
{{ tab }} | ||
</div> | ||
<div ref="selector" class="f-debug-tabs__selector" /> | ||
</div> | ||
<div class="f-debug-tabs__content"> | ||
<slot :name="selectedTabId" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import type { PropType } from 'vue' | ||
import { defineProps, onMounted, ref } from 'vue' | ||
const props = defineProps({ | ||
tabs: { | ||
type: Array as PropType<string[]>, | ||
required: true, | ||
}, | ||
}) | ||
const selectedTabId = ref(props.tabs[0]) | ||
const selector = ref<HTMLElement | null>(null) | ||
function selectTab(id: string) { | ||
selectedTabId.value = id | ||
if (selector.value) { | ||
const tabs = selector.value.parentElement?.querySelectorAll('.f-debug-tabs__tab') | ||
if (tabs) { | ||
const tab = tabs[props.tabs.indexOf(id)] as HTMLElement | ||
selector.value.style.left = `${tab.offsetLeft}px` | ||
} | ||
} | ||
} | ||
onMounted(() => { | ||
if (selector.value) { | ||
const tabs = selector.value.parentElement?.querySelectorAll('.f-debug-tabs__tab') | ||
if (tabs) { | ||
const tab = tabs[0] as HTMLElement | ||
selector.value.style.width = `${tab.offsetWidth}px` | ||
selector.value.style.left = `${tab.offsetLeft}px` | ||
} | ||
} | ||
}) | ||
</script> |