|
1 | 1 | <template> |
2 | 2 | <div class="flex flex-col gap-[1px]"> |
3 | | - <div |
4 | | - v-for="(item, index) in props.items" |
5 | | - :key="index" |
6 | | - class="bg-neutral-950 transition-colors focus-within:bg-neutral-900 hover:bg-neutral-900" |
7 | | - > |
8 | | - <button |
9 | | - class="hover:text-brand-50 focus:text-brand-50 flex w-full cursor-pointer items-center justify-between p-4 outline-0 transition-colors" |
10 | | - @click="toggleAccordion(index)" |
11 | | - @mousedown.prevent |
12 | | - > |
13 | | - <h2> |
14 | | - {{ item.title }} |
15 | | - </h2> |
16 | | - <Icon |
17 | | - name="memory:chevron-up" |
18 | | - :size="24" |
19 | | - :class="{ 'rotate-180': activeIndex !== index }" |
20 | | - mode="svg" |
21 | | - class="transition-transform" |
22 | | - /> |
23 | | - </button> |
| 3 | + <client-only> |
24 | 4 | <div |
25 | | - class="overflow-hidden transition-[max-height] duration-300 ease-in-out" |
26 | | - :style="{ |
27 | | - maxHeight: activeIndex === index ? contentHeights[index] + 'px' : '0', |
28 | | - }" |
| 5 | + v-for="(item, index) in props.items" |
| 6 | + :key="index" |
| 7 | + class="bg-neutral-950 transition-colors focus-within:bg-neutral-900 hover:bg-neutral-900" |
29 | 8 | > |
| 9 | + <button |
| 10 | + class="hover:text-brand-50 focus:text-brand-50 flex w-full cursor-pointer items-center justify-between p-4 outline-0 transition-colors" |
| 11 | + @click="toggleAccordion(index)" |
| 12 | + @mousedown.prevent |
| 13 | + > |
| 14 | + <h2> |
| 15 | + {{ item.title }} |
| 16 | + </h2> |
| 17 | + <Icon |
| 18 | + name="memory:chevron-up" |
| 19 | + :size="24" |
| 20 | + :class="{ 'rotate-180': activeIndex !== index }" |
| 21 | + mode="svg" |
| 22 | + class="transition-transform" |
| 23 | + /> |
| 24 | + </button> |
30 | 25 | <div |
31 | | - :ref="(el) => setContentRef(el as Element | null, index)" |
32 | | - class="text-default-font/75 p-4 pt-0" |
| 26 | + class="overflow-hidden transition-[max-height] duration-300 ease-in-out" |
| 27 | + :style="{ |
| 28 | + maxHeight: |
| 29 | + activeIndex === index ? contentHeights[index] + 'px' : '0', |
| 30 | + }" |
33 | 31 | > |
34 | | - <template v-if="activeIndex == index || oldIndex == index"> |
35 | | - <p v-if="item.text"> |
36 | | - {{ item.text }} |
37 | | - </p> |
38 | | - <template v-else> |
39 | | - <component |
40 | | - v-for="(vnode, vnodeIndex) in (item.inner as Function)()" |
41 | | - :key="vnodeIndex" |
42 | | - :is="vnode" |
43 | | - /> |
| 32 | + <div |
| 33 | + :ref="(el) => setContentRef(el as Element | null, index)" |
| 34 | + class="text-default-font/75 p-4 pt-0" |
| 35 | + > |
| 36 | + <template v-if="activeIndex == index || oldIndex == index"> |
| 37 | + <p v-if="item.text"> |
| 38 | + {{ item.text }} |
| 39 | + </p> |
| 40 | + <template v-else> |
| 41 | + <component |
| 42 | + v-for="(vnode, vnodeIndex) in (item.inner as Function)()" |
| 43 | + :key="vnodeIndex" |
| 44 | + :is="vnode" |
| 45 | + /> |
| 46 | + </template> |
44 | 47 | </template> |
45 | | - </template> |
| 48 | + </div> |
46 | 49 | </div> |
47 | 50 | </div> |
48 | | - </div> |
| 51 | + </client-only> |
49 | 52 | </div> |
50 | 53 | </template> |
51 | 54 |
|
|
0 commit comments