Skip to content

Commit 212e1c6

Browse files
feat(package): add section toggle
1 parent 803a38f commit 212e1c6

2 files changed

Lines changed: 416 additions & 384 deletions

File tree

app/components/PackageSection.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
title: string
4+
toggleable?: boolean
5+
isVisible?: boolean
6+
scrollToId?: string
7+
}>()
8+
9+
const isVisible = defineModel('isVisible', {
10+
default: true,
11+
})
12+
13+
function toggleVisibility() {
14+
isVisible.value = !isVisible.value
15+
}
16+
</script>
17+
18+
<template>
19+
<section class="overflow-hidden scroll-mt-20">
20+
<header class="group flex items-center justify-between gap-2 mb-3">
21+
<h2 class="group text-xs text-fg-subtle uppercase tracking-wider">
22+
<a
23+
v-if="scrollToId"
24+
:href="`#${scrollToId}`"
25+
class="inline-flex items-center gap-1.5 text-fg-subtle hover:text-fg-muted transition-colors duration-200 no-underline"
26+
>
27+
{{ title }}
28+
<span
29+
class="i-carbon-link w-3 h-3 block opacity-0 group-hover:opacity-100 transition-opacity duration-200"
30+
aria-hidden="true"
31+
/>
32+
</a>
33+
<template v-else>{{ title }}</template>
34+
</h2>
35+
36+
<button
37+
v-if="toggleable"
38+
@click="toggleVisibility"
39+
class="text-xs text-fg-subtle hover:text-fg opacity-0 group-hover:opacity-100 transition-opacity duration-200"
40+
>
41+
{{ isVisible ? 'hide' : 'show' }}
42+
</button>
43+
</header>
44+
45+
<div v-if="isVisible" class="space-y-0.5 min-w-0">
46+
<slot />
47+
</div>
48+
</section>
49+
</template>

0 commit comments

Comments
 (0)