|
1 | 1 | <template> |
2 | | - <div class="font-patrick flex flex-col h-full overflow-y-auto"> |
| 2 | + <div class="menu-items-container"> |
3 | 3 | <div |
4 | 4 | v-for="list, index in items" |
5 | 5 | :key="index" |
6 | | - class="space-y-2" |
| 6 | + class="menu-section" |
7 | 7 | > |
8 | | - <div class="font-bold mb-2"> |
9 | | - {{ list.title }} |
10 | | - </div> |
11 | 8 | <div |
12 | | - v-for="item in list.links" |
13 | | - :key="item.name" |
14 | | - class="w-full flex justify-between items-center font-sans text-sm" |
| 9 | + class="section-header" |
| 10 | + @click="toggleSection(list.title)" |
15 | 11 | > |
16 | | - <a |
17 | | - :href="item.link" |
18 | | - >{{ item.name }}</a> |
19 | | - <PUBadge |
20 | | - v-if="item.new" |
21 | | - label="new" |
22 | | - /> |
| 12 | + <div class="section-title"> |
| 13 | + {{ list.title }} |
| 14 | + </div> |
| 15 | + <div class="section-toggle"> |
| 16 | + <div |
| 17 | + class="toggle-icon" |
| 18 | + :class="{ rotated: isSectionOpen(list.title) }" |
| 19 | + > |
| 20 | + <PUIcon |
| 21 | + name="chevron-down" |
| 22 | + size="small" |
| 23 | + /> |
| 24 | + </div> |
| 25 | + </div> |
23 | 26 | </div> |
| 27 | + <Transition |
| 28 | + name="accordion" |
| 29 | + @enter="onEnter" |
| 30 | + @leave="onLeave" |
| 31 | + > |
| 32 | + <div |
| 33 | + v-show="isSectionOpen(list.title)" |
| 34 | + class="section-content" |
| 35 | + > |
| 36 | + <div class="section-links"> |
| 37 | + <div |
| 38 | + v-for="item in list.links" |
| 39 | + :key="item.name" |
| 40 | + class="menu-link-item group" |
| 41 | + > |
| 42 | + <a |
| 43 | + :href="item.link" |
| 44 | + class="menu-link" |
| 45 | + >{{ item.name }}</a> |
| 46 | + <PUBadge |
| 47 | + v-if="item.new" |
| 48 | + label="new" |
| 49 | + class="new-badge" |
| 50 | + /> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + </div> |
| 54 | + </Transition> |
24 | 55 | <div |
25 | 56 | v-if="index !== items.length - 1" |
26 | | - class="separator py-2" |
| 57 | + class="section-separator" |
27 | 58 | > |
28 | | - <div class="border-[1px] border-primary-light-500/10 " /> |
| 59 | + <div class="separator-line"></div> |
29 | 60 | </div> |
30 | 61 | </div> |
31 | 62 | </div> |
32 | 63 | </template> |
33 | 64 |
|
34 | 65 | <script setup lang="ts"> |
| 66 | +import { useAccordion } from '../composables/useAccordion' |
| 67 | +
|
35 | 68 | defineProps<{ |
36 | 69 | items: { |
37 | 70 | title: string |
38 | 71 | links: { name: string, link: string, new?: boolean }[] |
39 | 72 | }[] |
40 | 73 | }>() |
| 74 | +
|
| 75 | +const { toggleSection, isSectionOpen } = useAccordion() |
| 76 | +
|
| 77 | +const onEnter = (el: Element) => { |
| 78 | + const target = el as HTMLElement |
| 79 | + target.style.height = '0px' |
| 80 | + target.style.height = `${target.scrollHeight}px` |
| 81 | +} |
| 82 | +
|
| 83 | +const onLeave = (el: Element) => { |
| 84 | + const target = el as HTMLElement |
| 85 | + target.style.height = `${target.scrollHeight}px` |
| 86 | + target.style.height = '0px' |
| 87 | +} |
41 | 88 | </script> |
| 89 | + |
| 90 | +<style scoped> |
| 91 | +.menu-items-container { |
| 92 | + @apply flex flex-col h-full overflow-y-auto p-6 space-y-4; |
| 93 | + scrollbar-width: thin; |
| 94 | + scrollbar-color: #cbd5e1 transparent; |
| 95 | +} |
| 96 | +
|
| 97 | +.menu-items-container::-webkit-scrollbar { |
| 98 | + width: 6px; |
| 99 | +} |
| 100 | +
|
| 101 | +.menu-items-container::-webkit-scrollbar-track { |
| 102 | + background: transparent; |
| 103 | +} |
| 104 | +
|
| 105 | +.menu-items-container::-webkit-scrollbar-thumb { |
| 106 | + background: #cbd5e1; |
| 107 | + border-radius: 3px; |
| 108 | +} |
| 109 | +
|
| 110 | +.menu-items-container::-webkit-scrollbar-thumb:hover { |
| 111 | + background: #94a3b8; |
| 112 | +} |
| 113 | +
|
| 114 | +.menu-section { |
| 115 | + @apply space-y-2; |
| 116 | +} |
| 117 | +
|
| 118 | +.section-header { |
| 119 | + @apply flex justify-between items-center cursor-pointer p-2 rounded-lg transition-all duration-200; |
| 120 | + background: linear-gradient(135deg, rgba(241, 245, 249, 0.5) 0%, rgba(226, 232, 240, 0.5) 100%); |
| 121 | +} |
| 122 | +
|
| 123 | +.section-header:hover { |
| 124 | + background: linear-gradient(135deg, rgba(241, 245, 249, 0.8) 0%, rgba(226, 232, 240, 0.8) 100%); |
| 125 | + transform: translateX(2px); |
| 126 | +} |
| 127 | +
|
| 128 | +.section-title { |
| 129 | + @apply font-bold text-lg text-primary-light-600 dark:text-primary-dark-400; |
| 130 | + text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5); |
| 131 | + transform: rotate(-0.5deg); |
| 132 | + position: relative; |
| 133 | +} |
| 134 | +
|
| 135 | +
|
| 136 | +.section-toggle { |
| 137 | + @apply flex items-center justify-center w-6 h-6; |
| 138 | +} |
| 139 | +
|
| 140 | +.toggle-icon { |
| 141 | + @apply text-primary-light-500 text-sm font-bold transition-transform duration-300; |
| 142 | + transform: rotate(0deg); |
| 143 | +} |
| 144 | +
|
| 145 | +.toggle-icon.rotated { |
| 146 | + transform: rotate(180deg); |
| 147 | +} |
| 148 | +
|
| 149 | +.section-content { |
| 150 | + @apply overflow-hidden; |
| 151 | + transition: height 0.3s ease; |
| 152 | +} |
| 153 | +
|
| 154 | +.section-links { |
| 155 | + @apply space-y-2 ml-2 mt-2; |
| 156 | +} |
| 157 | +
|
| 158 | +.menu-link-item { |
| 159 | + @apply flex justify-between items-center; |
| 160 | + transition: all 0.2s ease; |
| 161 | +} |
| 162 | +
|
| 163 | +.menu-link-item:hover { |
| 164 | + transform: translateX(4px); |
| 165 | +} |
| 166 | +
|
| 167 | +.menu-link { |
| 168 | + @apply text-sm text-primary-light-700 dark:text-primary-dark-300 transition-all duration-200; |
| 169 | + position: relative; |
| 170 | + padding: 4px 8px; |
| 171 | + border-radius: 6px; |
| 172 | + background: transparent; |
| 173 | + transition: all 0.2s ease; |
| 174 | +} |
| 175 | +
|
| 176 | +.menu-link:hover { |
| 177 | + @apply text-primary-light-500 dark:text-primary-dark-200; |
| 178 | + background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(147, 197, 253, 0.1) 100%); |
| 179 | + box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15); |
| 180 | + transform: scale(1.02); |
| 181 | +} |
| 182 | +
|
| 183 | +.menu-link::before { |
| 184 | + content: ''; |
| 185 | + @apply absolute left-0 top-1/2 w-0 h-0.5 bg-primary-light-500 rounded-full; |
| 186 | + transform: translateY(-50%); |
| 187 | + transition: width 0.2s ease; |
| 188 | +} |
| 189 | +
|
| 190 | +.menu-link:hover::before { |
| 191 | + width: 100%; |
| 192 | +} |
| 193 | +
|
| 194 | +.new-badge { |
| 195 | + transform: scale(0.8) rotate(5deg); |
| 196 | + transition: all 0.2s ease; |
| 197 | +} |
| 198 | +
|
| 199 | +.menu-link-item:hover .new-badge { |
| 200 | + transform: scale(0.9) rotate(0deg); |
| 201 | +} |
| 202 | +
|
| 203 | +.section-separator { |
| 204 | + @apply py-2; |
| 205 | +} |
| 206 | +
|
| 207 | +.separator-line { |
| 208 | + @apply h-px bg-gradient-to-r from-transparent via-primary-light-500/30 to-transparent; |
| 209 | + position: relative; |
| 210 | +} |
| 211 | +
|
| 212 | +.separator-line::before { |
| 213 | + content: ''; |
| 214 | + @apply absolute top-0 left-1/2 w-2 h-px bg-primary-light-500; |
| 215 | + transform: translateX(-50%); |
| 216 | +} |
| 217 | +
|
| 218 | +.separator-line::after { |
| 219 | + content: ''; |
| 220 | + @apply absolute top-0 left-1/2 w-1 h-px bg-primary-light-500; |
| 221 | + transform: translateX(-50%); |
| 222 | +} |
| 223 | +
|
| 224 | +.accordion-enter-active, |
| 225 | +.accordion-leave-active { |
| 226 | + transition: all 0.3s ease; |
| 227 | +} |
| 228 | +
|
| 229 | +.accordion-enter-from, |
| 230 | +.accordion-leave-to { |
| 231 | + opacity: 0; |
| 232 | + transform: translateY(-10px); |
| 233 | +} |
| 234 | +
|
| 235 | +@media (prefers-color-scheme: dark) { |
| 236 | + .section-header { |
| 237 | + background: linear-gradient(135deg, rgba(51, 65, 85, 0.5) 0%, rgba(71, 85, 105, 0.5) 100%); |
| 238 | + } |
| 239 | +
|
| 240 | + .section-header:hover { |
| 241 | + background: linear-gradient(135deg, rgba(51, 65, 85, 0.8) 0%, rgba(71, 85, 105, 0.8) 100%); |
| 242 | + } |
| 243 | +
|
| 244 | + .section-title { |
| 245 | + text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.3); |
| 246 | + } |
| 247 | +
|
| 248 | + .menu-link:hover { |
| 249 | + background: linear-gradient(135deg, rgba(59, 130, 246, 0.2) 0%, rgba(147, 197, 253, 0.2) 100%); |
| 250 | + box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25); |
| 251 | + } |
| 252 | +} |
| 253 | +</style> |
0 commit comments