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 @@
77-->
88<script setup lang="ts">
99import { useRouter, withBase } from 'vitepress'
10import { computed, onMounted, onUnmounted, reactive, ref } from 'vue'
10import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
1111import {
1212 feedbackOptions,
1313 type FeedbackType,
@@ -130,7 +130,7 @@ const typeOpen = ref<boolean>(false)
130130const typeRootRef = ref<HTMLDivElement>()
131131const typePlaceholder = {
132132 label: 'Feedback type',
133 icon: 'i-lucide:circle-question-mark',
133 icon: undefined as string | undefined,
134134 value: undefined
135135} as const
136136const selectedType = computed(
@@ -148,7 +148,82 @@ function onTypeDocClick(e: MouseEvent) {
148148 }
149149}
150150
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})
152227onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
153228</script>
154229
@@ -210,7 +285,7 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
210285 :aria-label="`Feedback type: ${selectedType.label}`"
211286 @click="typeOpen = !typeOpen"
212287 >
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" />
214289 <span class="fb-type-label">{{ selectedType.label }}</span>
215290 <span
216291 class="fb-type-chevron i-lucide:chevron-down"
@@ -260,8 +335,25 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
260335 </p>
261336 </div>
262337 </div>
263 <div v-else>
338 <div v-else class="feedback-success">
264339 <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 />
265357 </div>
266358 </Transition>
267359 </div>
@@ -473,8 +565,10 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
473565 transition: background-color 0.15s;
474566}
475567
476.fb-type-option:hover {
477 background-color: var(--vp-c-bg-soft);
568.fb-type-option:hover,
569.fb-type-option:focus-visible {
570 background-color: var(--vp-c-brand-soft);
571 outline: none;
478572}
479573
480574.fb-type-option--selected {
@@ -485,10 +579,6 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
485579 font-weight: 600;
486580}
487581
488.fb-type-option--selected:hover {
489 background-color: var(--vp-c-brand-soft);
490}
491
492582.feedback-send {
493583 display: inline-flex;
494584 align-items: center;
@@ -520,6 +610,62 @@ onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true))
520610 cursor: not-allowed;
521611}
522612
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
523669.fade-enter-active,
524670.fade-leave-active {
525671 transition: opacity 0.25s ease;
docs/.vitepress/types/Feedback.ts +3 −3
@@ -31,17 +31,17 @@ export interface Option {
3131
3232export const feedbackOptions: Option[] = [
3333 {
34 label: 'Submit link',
34 label: 'Submit URL',
3535 icon: 'i-lucide:circle-plus',
3636 value: 'submit'
3737 },
3838 {
39 label: 'Update link',
39 label: 'Update URL',
4040 icon: 'i-lucide:circle-alert',
4141 value: 'update'
4242 },
4343 {
44 label: 'Report bad / dead link',
44 label: 'Report URL',
4545 icon: 'i-lucide:circle-x',
4646 value: 'report'
4747 },
unocss.config.ts +14
@@ -83,6 +83,20 @@ const safelist = [
8383 'i-lucide:languages',
8484 'i-lucide:shield',
8585 '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',
86100 ...Array.from(new Set([...Object.values(LANG_FLAG_ICONS), LANG_FLAG_FALLBACK])).map(
87101 (icon) => `i-twemoji-${icon}`
88102 )