Commit 4d1d81cde0

4d1d81cde074a216a7fe84b178ce0a29c8c7c333

parent: f7327e110c

Unsigned

Duck <57977673+woducku@users.noreply.github.com> · 2026-09-18 06:31 UTC

a

Layout: unified · split

docs/.vitepress/theme/components/Feedback.vue +157 −11
@@ -7,7 +7,7 @@
7--> 7-->
8<script setup lang="ts"> 8<script setup lang="ts">
9import { useRouter, withBase } from 'vitepress' 9import { useRouter, withBase } from 'vitepress'
10import { computed, onMounted, onUnmounted, reactive, ref } from 'vue' 10import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
11import { 11import {
12 feedbackOptions, 12 feedbackOptions,
13 type FeedbackType, 13 type FeedbackType,
@@ -130,7 +130,7 @@ const typeOpen = ref<boolean>(false)
130const typeRootRef = ref<HTMLDivElement>() 130const typeRootRef = ref<HTMLDivElement>()
131const typePlaceholder = { 131const typePlaceholder = {
132 label: 'Feedback type', 132 label: 'Feedback type',
133 icon: 'i-lucide:circle-question-mark', 133 icon: undefined as string | undefined,
134 value: undefined 134 value: undefined
135} as const 135} as const
136const selectedType = computed( 136const selectedType = computed(
@@ -148,7 +148,82 @@ function onTypeDocClick(e: MouseEvent) {
148 } 148 }
149} 149}
150 150
151onMounted(() => document.addEventListener('click', onTypeDocClick, true)) 151// Success celebration: floating twemoji, single ~3s burst with random lanes.
152// Pick an icon + depth layer here; size/opacity/timing derive from the layer.
153type CelebrateLayer = 'front' | 'mid' | 'back'
154
155const CELEBRATE_ICONS: { icon: string; layer: CelebrateLayer }[] = [
156 { icon: 'i-twemoji-red-heart', layer: 'front' },
157 { icon: 'i-twemoji-growing-heart', layer: 'front' },
158 { icon: 'i-twemoji-green-heart', layer: 'front' },
159 { icon: 'i-twemoji-yellow-heart', layer: 'mid' },
160 { icon: 'i-twemoji-folded-hands', layer: 'mid' },
161 { icon: 'i-twemoji-purple-heart', layer: 'mid' },
162 { icon: 'i-twemoji-beating-heart', layer: 'mid' },
163 { icon: 'i-twemoji-orange-heart', layer: 'back' },
164 { icon: 'i-twemoji-blue-heart', layer: 'back' },
165 { icon: 'i-twemoji-brown-heart', layer: 'back' },
166 { icon: 'i-twemoji-white-heart', layer: 'back' },
167 { icon: 'i-twemoji-black-heart', layer: 'back' },
168 { icon: 'i-twemoji-sparkling-heart', layer: 'back' },
169 { icon: 'i-twemoji-glowing-star', layer: 'back' }
170]
171
172const LAYER_STYLE = {
173 front: { minSize: 24, maxSize: 30, minOpacity: 0.95, maxOpacity: 1, z: 2, blur: '0px', minDuration: 1.9, maxDuration: 2.1 },
174 mid: { minSize: 16, maxSize: 22, minOpacity: 0.8, maxOpacity: 0.9, z: 0, blur: '0px', minDuration: 2, maxDuration: 2.3 },
175 back: { minSize: 12, maxSize: 15, minOpacity: 0.4, maxOpacity: 0.55, z: 0, blur: '1px', minDuration: 2.1, maxDuration: 2.3 }
176} as const
177
178interface CelebrationParticle {
179 icon: string
180 left: string
181 delay: string
182 duration: string
183 size: string
184 opacity: string
185 z: number
186 blur: string
187}
188
189function makeParticle(
190 def: (typeof CELEBRATE_ICONS)[number],
191 index: number,
192 randomize: boolean
193): CelebrationParticle {
194 const style = LAYER_STYLE[def.layer]
195 const pick = (min: number, max: number) =>
196 randomize ? min + Math.random() * (max - min) : (min + max) / 2
197 return {
198 icon: def.icon,
199 left: randomize
200 ? `${(2 + Math.random() * 92).toFixed(1)}%`
201 : `${(((index + 0.5) / CELEBRATE_ICONS.length) * 100).toFixed(1)}%`,
202 delay: `${pick(0, 0.7).toFixed(2)}s`,
203 duration: `${pick(style.minDuration, style.maxDuration).toFixed(2)}s`,
204 size: `${Math.round(pick(style.minSize, style.maxSize))}px`,
205 opacity: `${pick(style.minOpacity, style.maxOpacity).toFixed(2)}`,
206 z: style.z,
207 blur: style.blur
208 }
209}
210
211const celebrationIcons = ref<CelebrationParticle[]>(
212 CELEBRATE_ICONS.map((def, i) => makeParticle(def, i, false))
213)
214
215function rollCelebration() {
216 celebrationIcons.value = CELEBRATE_ICONS.map((def, i) => makeParticle(def, i, true))
217}
218
219watch(success, (v) => {
220 if (v) rollCelebration()
221})
222
223onMounted(() => {
224 document.addEventListener('click', onTypeDocClick, true)
225 if (success.value) rollCelebration()
226})
152onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true)) 227onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
153</script> 228</script>
154 229
@@ -210,7 +285,7 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
210 :aria-label="`Feedback type: ${selectedType.label}`" 285 :aria-label="`Feedback type: ${selectedType.label}`"
211 @click="typeOpen = !typeOpen" 286 @click="typeOpen = !typeOpen"
212 > 287 >
213 <span :class="selectedType.icon" class="fb-type-icon" aria-hidden="true" /> 288 <span v-if="selectedType.icon" :class="selectedType.icon" class="fb-type-icon" aria-hidden="true" />
214 <span class="fb-type-label">{{ selectedType.label }}</span> 289 <span class="fb-type-label">{{ selectedType.label }}</span>
215 <span 290 <span
216 class="fb-type-chevron i-lucide:chevron-down" 291 class="fb-type-chevron i-lucide:chevron-down"
@@ -260,8 +335,25 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
260 </p> 335 </p>
261 </div> 336 </div>
262 </div> 337 </div>
263 <div v-else> 338 <div v-else class="feedback-success">
264 <p class="heading">Thanks for your feedback!</p> 339 <p class="heading">Thanks for your feedback!</p>
340 <span
341 v-for="(item, i) in celebrationIcons"
342 :key="i"
343 class="fb-celebrate"
344 :class="item.icon"
345 aria-hidden="true"
346 :style="{
347 left: item.left,
348 width: item.size,
349 height: item.size,
350 zIndex: item.z,
351 filter: `blur(${item.blur})`,
352 '--fb-peak': item.opacity,
353 animationDelay: item.delay,
354 animationDuration: item.duration
355 }"
356 />
265 </div> 357 </div>
266 </Transition> 358 </Transition>
267 </div> 359 </div>
@@ -473,8 +565,10 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
473 transition: background-color 0.15s; 565 transition: background-color 0.15s;
474} 566}
475 567
476.fb-type-option:hover { 568.fb-type-option:hover,
477 background-color: var(--vp-c-bg-soft); 569.fb-type-option:focus-visible {
570 background-color: var(--vp-c-brand-soft);
571 outline: none;
478} 572}
479 573
480.fb-type-option--selected { 574.fb-type-option--selected {
@@ -485,10 +579,6 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
485 font-weight: 600; 579 font-weight: 600;
486} 580}
487 581
488.fb-type-option--selected:hover {
489 background-color: var(--vp-c-brand-soft);
490}
491
492.feedback-send { 582.feedback-send {
493 display: inline-flex; 583 display: inline-flex;
494 align-items: center; 584 align-items: center;
@@ -520,6 +610,62 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
520 cursor: not-allowed; 610 cursor: not-allowed;
521} 611}
522 612
613.feedback-success {
614 border: 2px solid var(--vp-c-brand-1);
615 border-radius: 12px;
616 background-color: var(--vp-c-bg-alt);
617 color: var(--vp-c-text-1);
618 display: flex;
619 align-items: center;
620 justify-content: center;
621 text-align: center;
622 min-height: 120px;
623 padding: 1rem;
624 box-shadow: 0 0 0 2px var(--vp-c-brand-soft);
625 position: relative;
626 overflow: hidden;
627}
628
629.feedback-success .heading {
630 margin: 0;
631 position: relative;
632 z-index: 1;
633}
634
635.fb-celebrate {
636 position: absolute;
637 bottom: -28px;
638 opacity: 0;
639 pointer-events: none;
640 animation-name: fb-float-up;
641 animation-timing-function: linear;
642 animation-iteration-count: 1;
643}
644
645@keyframes fb-float-up {
646 0% {
647 transform: translateY(0);
648 opacity: 0;
649 }
650 15% {
651 opacity: var(--fb-peak, 0.9);
652 }
653 70% {
654 opacity: var(--fb-peak, 0.9);
655 }
656 100% {
657 transform: translateY(-160px);
658 opacity: 0;
659 }
660}
661
662@media (prefers-reduced-motion: reduce) {
663 .fb-celebrate {
664 animation: none;
665 display: none;
666 }
667}
668
523.fade-enter-active, 669.fade-enter-active,
524.fade-leave-active { 670.fade-leave-active {
525 transition: opacity 0.25s ease; 671 transition: opacity 0.25s ease;
docs/.vitepress/types/Feedback.ts +3 −3
@@ -31,17 +31,17 @@ export interface Option {
31 31
32export const feedbackOptions: Option[] = [ 32export const feedbackOptions: Option[] = [
33 { 33 {
34 label: 'Submit link', 34 label: 'Submit URL',
35 icon: 'i-lucide:circle-plus', 35 icon: 'i-lucide:circle-plus',
36 value: 'submit' 36 value: 'submit'
37 }, 37 },
38 { 38 {
39 label: 'Update link', 39 label: 'Update URL',
40 icon: 'i-lucide:circle-alert', 40 icon: 'i-lucide:circle-alert',
41 value: 'update' 41 value: 'update'
42 }, 42 },
43 { 43 {
44 label: 'Report bad / dead link', 44 label: 'Report URL',
45 icon: 'i-lucide:circle-x', 45 icon: 'i-lucide:circle-x',
46 value: 'report' 46 value: 'report'
47 }, 47 },
unocss.config.ts +14
@@ -83,6 +83,20 @@ const safelist = [
83 'i-lucide:languages', 83 'i-lucide:languages',
84 'i-lucide:shield', 84 'i-lucide:shield',
85 'i-twemoji-no-one-under-eighteen', 85 'i-twemoji-no-one-under-eighteen',
86 'i-twemoji-red-heart',
87 'i-twemoji-orange-heart',
88 'i-twemoji-yellow-heart',
89 'i-twemoji-green-heart',
90 'i-twemoji-blue-heart',
91 'i-twemoji-purple-heart',
92 'i-twemoji-brown-heart',
93 'i-twemoji-black-heart',
94 'i-twemoji-white-heart',
95 'i-twemoji-sparkling-heart',
96 'i-twemoji-beating-heart',
97 'i-twemoji-growing-heart',
98 'i-twemoji-folded-hands',
99 'i-twemoji-glowing-star',
86 ...Array.from(new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])).map( 100 ...Array.from(new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])).map(
87 (icon) => `i-twemoji-${icon}` 101 (icon) => `i-twemoji-${icon}`
88 ) 102 )