feat: initialize Vue component library and aligned documentation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { inject, onBeforeUnmount, useId, useAttrs } from "vue";
|
||||
import { switchKey } from "../switch/context";
|
||||
const ctx = inject(switchKey, undefined);
|
||||
const attrs = useAttrs();
|
||||
const id = String(attrs.id ?? useId());
|
||||
if (ctx) ctx.descriptionIds.value = [...ctx.descriptionIds.value, id];
|
||||
onBeforeUnmount(() => {
|
||||
if (ctx)
|
||||
ctx.descriptionIds.value = ctx.descriptionIds.value.filter(
|
||||
(value) => value !== id,
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<p :id="id" class="hv-description" data-slot="description"><slot /></p>
|
||||
</template>
|
||||
Reference in New Issue
Block a user