Commit f7327e110c
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/Feedback.vue +282 −163
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | --> |
| 8 | 8 | <script setup lang="ts"> |
| 9 | 9 | import { useRouter, withBase } from 'vitepress' |
| 10 | import { computed, reactive, ref } from 'vue' | |
| 10 | import { computed, onMounted, onUnmounted, reactive, ref } from 'vue' | |
| 11 | 11 | import { |
| 12 | 12 | feedbackOptions, |
| 13 | 13 | type FeedbackType, |
| @@ -60,6 +60,7 @@ function getVisitorId(): string { | ||
| 60 | 60 | |
| 61 | 61 | const isDisabled = computed(() => { |
| 62 | 62 | return ( |
| 63 | !feedback.type || | |
| 63 | 64 | !feedback.content.length || |
| 64 | 65 | feedback.content.length < 5 || |
| 65 | 66 | feedback.content.length > 2000 |
| @@ -72,18 +73,12 @@ const feedback = reactive< | ||
| 72 | 73 | >({ |
| 73 | 74 | page: getURL(props.heading!), |
| 74 | 75 | content: '', |
| 75 | name: '' | |
| 76 | name: '', | |
| 77 | type: undefined | |
| 76 | 78 | }) |
| 77 | 79 | |
| 78 | const selectedOption = ref(feedbackOptions[0]) | |
| 79 | ||
| 80 | function selectType(type: FeedbackType['type']) { | |
| 81 | feedback.type = type | |
| 82 | selectedOption.value = getFeedbackOption(type)! | |
| 83 | error.value = null | |
| 84 | } | |
| 85 | ||
| 86 | 80 | async function handleSubmit() { |
| 81 | if (!feedback.type) return | |
| 87 | 82 | loading.value = true |
| 88 | 83 | success.value = true |
| 89 | 84 | error.value = null |
| @@ -120,11 +115,41 @@ async function handleSubmit() { | ||
| 120 | 115 | } |
| 121 | 116 | |
| 122 | 117 | const isCardShown = ref<boolean>(false) |
| 123 | const helpfulText = props.heading | |
| 124 | ? 'What do you think about this section?' | |
| 125 | : 'What do you think about this page?' | |
| 126 | 118 | const prompt = computed(() => getPrompt()) |
| 127 | const toggleCard = () => (isCardShown.value = !isCardShown.value) | |
| 119 | const toggleCard = () => { | |
| 120 | isCardShown.value = !isCardShown.value | |
| 121 | if (!isCardShown.value && success.value) { | |
| 122 | success.value = false | |
| 123 | feedback.content = '' | |
| 124 | feedback.type = undefined | |
| 125 | error.value = null | |
| 126 | } | |
| 127 | } | |
| 128 | ||
| 129 | const typeOpen = ref<boolean>(false) | |
| 130 | const typeRootRef = ref<HTMLDivElement>() | |
| 131 | const typePlaceholder = { | |
| 132 | label: 'Feedback type', | |
| 133 | icon: 'i-lucide:circle-question-mark', | |
| 134 | value: undefined | |
| 135 | } as const | |
| 136 | const selectedType = computed( | |
| 137 | () => (feedback.type ? getFeedbackOption(feedback.type) : undefined) ?? typePlaceholder | |
| 138 | ) | |
| 139 | ||
| 140 | function selectFeedbackType(type: FeedbackType['type']) { | |
| 141 | feedback.type = type | |
| 142 | typeOpen.value = false | |
| 143 | } | |
| 144 | ||
| 145 | function onTypeDocClick(e: MouseEvent) { | |
| 146 | if (typeRootRef.value && !typeRootRef.value.contains(e.target as Node)) { | |
| 147 | typeOpen.value = false | |
| 148 | } | |
| 149 | } | |
| 150 | ||
| 151 | onMounted(() => document.addEventListener('click', onTypeDocClick, true)) | |
| 152 | onUnmounted(() => document.removeEventListener('click', onTypeDocClick, true)) | |
| 128 | 153 | </script> |
| 129 | 154 | |
| 130 | 155 | <template> |
| @@ -154,152 +179,86 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value) | ||
| 154 | 179 | </template> |
| 155 | 180 | |
| 156 | 181 | <Transition name="fade" mode="out-in"> |
| 157 | <div | |
| 158 | v-if="isCardShown" | |
| 159 | :class="['border-$vp-c-divider bg-$vp-c-bg-alt b-rd-4 m-[2rem 0] mt-4 border-2 border-solid px-6 pt-3', success ? 'pb-3' : 'pb-6']" | |
| 160 | > | |
| 182 | <div v-if="isCardShown" class="feedback-wrap"> | |
| 161 | 183 | <Transition name="fade" mode="out-in"> |
| 162 | <div v-if="!feedback.type"> | |
| 163 | <p class="heading"> | |
| 164 | {{ helpfulText }} | |
| 165 | </p> | |
| 166 | <div class="flex flex-wrap gap-2"> | |
| 167 | <button | |
| 168 | v-for="item in feedbackOptions" | |
| 169 | :key="item.value" | |
| 170 | class="bg-bg border-$vp-c-default-soft hover:border-primary mt-2 select-none rounded border-2 border-solid font-bold transition-all duration-250 rounded-lg text-[14px] font-500 leading-normal m-0 px-3 py-1.5 text-center align-middle whitespace-nowrap" | |
| 171 | @click="selectType(item.value)" | |
| 172 | > | |
| 173 | <span :class="[item.icon, 'mr-1 inline-block align-middle']" /> | |
| 174 | <span class="align-middle">{{ item.label }}</span> | |
| 175 | </button> | |
| 176 | </div> | |
| 177 | </div> | |
| 178 | <div v-else-if="feedback.type && !success" class="pt-2"> | |
| 179 | <div class="mb-3"> | |
| 180 | <span class="text-[22px] font-bold flex items-center gap-2"> | |
| 181 | <span :class="getFeedbackOption(feedback.type)?.icon" /> | |
| 182 | {{ getFeedbackOption(feedback.type)?.label }} | |
| 183 | </span> | |
| 184 | </div> | |
| 185 | ||
| 186 | <div v-if="feedback.type === 'submit'" class="mb-2 text-sm"> | |
| 187 | <details> | |
| 188 | <summary class="flex items-center gap-1"> | |
| 189 | <span class="i-iconoir-nav-arrow-right arrow-right" /> | |
| 190 | <span class="i-iconoir-nav-arrow-down arrow-down" /> | |
| 191 | <span class="i-lucide-shield-x bg-cerise-400" /> | |
| 192 | Things we won't add in the wiki | |
| 193 | </summary> | |
| 194 | <ol> | |
| 195 | <li> | |
| 196 | Websites that are only or primarily for generative AI | |
| 197 | (Chatbot, roleplaying bot, ai art generator etc.) | |
| 198 | </li> | |
| 199 | <li> | |
| 200 | Sites that | |
| 201 | <ul> | |
| 202 | <li>imitate other websites</li> | |
| 203 | <li>have very small libraries</li> | |
| 204 | <li>only feature MTL'd works</li> | |
| 205 | <li>are mostly paywalled</li> | |
| 206 | <li>sell unofficial merch</li> | |
| 207 | <li>exlusively sell sex toys</li> | |
| 208 | </ul> | |
| 209 | </li> | |
| 210 | <li>Adult content sites similar to OnlyFans</li> | |
| 211 | <li> | |
| 212 | Software that's too general (for example Windows OS related or | |
| 213 | Tweaking for privacy) | |
| 214 | </li> | |
| 215 | <li>Sites focused on lolicon or furry stuff</li> | |
| 216 | <li> | |
| 217 | Sites scraping only a couple popular sources | |
| 218 | </li> | |
| 219 | <li> | |
| 220 | Sites scraping the servers of other scrapers | |
| 221 | </li> | |
| 222 | <li> | |
| 223 | Sites found in the Unsafe lists of | |
| 224 | <a | |
| 225 | href="https://privateers.wiki/unsafe" | |
| 226 | class="text-primary text-underline font-semibold" | |
| 227 | > | |
| 228 | Privateersclub | |
| 229 | </a> | |
| 230 | and/or | |
| 231 | <a | |
| 232 | href="https://rentry.org/pgames#untrusted-sites" | |
| 233 | class="text-primary text-underline font-semibold" | |
| 234 | > | |
| 235 | r/PiratedGames | |
| 236 | </a> | |
| 237 | . | |
| 238 | </li> | |
| 239 | </ol> | |
| 240 | </details> | |
| 241 | <details> | |
| 242 | <summary class="flex items-center gap-1"> | |
| 243 | <span class="i-iconoir-nav-arrow-right arrow-right" /> | |
| 244 | <span class="i-iconoir-nav-arrow-down arrow-down" /> | |
| 245 | <span class="i-lucide-shield-alert bg-yellow-400" /> | |
| 246 | Things we will try to avoid | |
| 247 | </summary> | |
| 248 | <ol> | |
| 249 | <li>Closed source software (with good FOSS alternatives)</li> | |
| 250 | <li> | |
| 251 | Sites that only use hosters such Katfile, Nitroflare, | |
| 252 | DDownload and Rapidgator | |
| 253 | </li> | |
| 254 | <li> | |
| 255 | Sites that aren't primarily for anime but have it as a side | |
| 256 | product | |
| 257 | </li> | |
| 258 | <li>Things that are too niche and/or have a small userbase</li> | |
| 259 | </ol> | |
| 260 | </details> | |
| 261 | </div> | |
| 184 | <div v-if="!success"> | |
| 262 | 185 | <textarea |
| 263 | 186 | v-model="feedback.content" |
| 264 | 187 | autofocus |
| 265 | class="feedback-textarea bg-$vp-c-bg-alt text-$vp-c-text-2 w-full h-[100px] border border-$vp-c-divider rounded px-3 py-1.5 border-$vp-c-divider bg-$vp-c-bg-alt b-rd-4 border-2 border-solid" | |
| 188 | class="feedback-textarea" | |
| 266 | 189 | :placeholder="prompt" |
| 267 | 190 | /> |
| 268 | <input | |
| 269 | v-model="feedback.name" | |
| 270 | maxlength="50" | |
| 271 | class="bg-$vp-c-bg-alt text-$vp-c-text-2 w-full border border-$vp-c-divider rounded px-3 py-1.5 mt-2 b-rd-4 border-2 border-solid text-sm" | |
| 272 | placeholder="Name (optional)" | |
| 273 | /> | |
| 274 | <p v-if="error" class="text-red-400 text-sm mt-1"> | |
| 275 | Failed to send: {{ String(error) }} | |
| 276 | </p> | |
| 277 | <p class="desc mb-2"> | |
| 278 | If you want a reply to your feedback, feel free to mention a contact | |
| 279 | in the message or join our | |
| 280 | <a | |
| 281 | class="text-primary text-underline font-semibold" | |
| 282 | href="https://discord.gg/wZMuSGpZ8s" | |
| 283 | > | |
| 284 | Discord. | |
| 285 | </a> | |
| 286 | </p> | |
| 287 | <div class="flex flex-row gap-2"> | |
| 288 | <button | |
| 289 | class="bg-$vp-c-default-soft text-primary border-$vp-c-default-soft inline-flex h-7 items-center justify-center whitespace-nowrap rounded-md border-2 border-solid px-1.5 py-3.5 text-sm font-medium transition-all duration-300 sm:h-6" | |
| 290 | @click="feedback.type = undefined" | |
| 191 | ||
| 192 | <div class="feedback-row"> | |
| 193 | <input | |
| 194 | v-model="feedback.name" | |
| 195 | maxlength="50" | |
| 196 | class="feedback-name" | |
| 197 | placeholder="Name (optional)" | |
| 198 | /> | |
| 199 | <div | |
| 200 | ref="typeRootRef" | |
| 201 | class="fb-type-select" | |
| 202 | :class="{ 'fb-type-select--open': typeOpen }" | |
| 291 | 203 | > |
| 292 | <span class="i-lucide:arrow-left-from-line">close</span> | |
| 293 | </button> | |
| 204 | <button | |
| 205 | type="button" | |
| 206 | class="fb-type-trigger" | |
| 207 | :class="{ 'fb-type-trigger--placeholder': !feedback.type }" | |
| 208 | aria-haspopup="listbox" | |
| 209 | :aria-expanded="typeOpen" | |
| 210 | :aria-label="`Feedback type: ${selectedType.label}`" | |
| 211 | @click="typeOpen = !typeOpen" | |
| 212 | > | |
| 213 | <span :class="selectedType.icon" class="fb-type-icon" aria-hidden="true" /> | |
| 214 | <span class="fb-type-label">{{ selectedType.label }}</span> | |
| 215 | <span | |
| 216 | class="fb-type-chevron i-lucide:chevron-down" | |
| 217 | :class="{ 'fb-type-chevron--open': typeOpen }" | |
| 218 | aria-hidden="true" | |
| 219 | /> | |
| 220 | </button> | |
| 221 | ||
| 222 | <div v-show="typeOpen" class="fb-type-options" role="listbox"> | |
| 223 | <button | |
| 224 | v-for="item in feedbackOptions" | |
| 225 | :key="item.value" | |
| 226 | type="button" | |
| 227 | role="option" | |
| 228 | class="fb-type-option" | |
| 229 | :class="{ 'fb-type-option--selected': feedback.type === item.value }" | |
| 230 | :aria-selected="feedback.type === item.value" | |
| 231 | :aria-label="item.label" | |
| 232 | @click="selectFeedbackType(item.value)" | |
| 233 | > | |
| 234 | <span :class="item.icon" class="fb-type-icon" aria-hidden="true" /> | |
| 235 | <span class="fb-type-label">{{ item.label }}</span> | |
| 236 | </button> | |
| 237 | </div> | |
| 238 | </div> | |
| 294 | 239 | <button |
| 295 | 240 | type="submit" |
| 296 | style="background-color: #438afe; border-color: #438afe;" class="border rounded-lg transition-colors duration-250 inline-flex items-center gap-1 text-14px font-500 leading-1.5 px-3 py-1.5 text-center align-middle whitespace-nowrap disabled:opacity-50 text-white hover:brightness-110 disabled:opacity-50" | |
| 297 | :disabled="isDisabled" | |
| 241 | class="feedback-send" | |
| 242 | :disabled="isDisabled || loading" | |
| 298 | 243 | @click="handleSubmit()" |
| 299 | 244 | > |
| 300 | Send Feedback <span class="i-lucide:mail-check" /> | |
| 245 | {{ loading ? 'Sending...' : 'Send' }} | |
| 246 | <span class="i-lucide:mail-check" /> | |
| 301 | 247 | </button> |
| 302 | 248 | </div> |
| 249 | <p v-if="error" class="text-red-400 text-sm mt-1"> | |
| 250 | Failed to send: {{ String(error) }} | |
| 251 | </p> | |
| 252 | <div class="tip custom-block mt-2"> | |
| 253 | <p class="custom-block-title">README</p> | |
| 254 | <p> | |
| 255 | Read the | |
| 256 | <a href="https://i.wotaku.wiki/p/rules" target="_blank" rel="noopener noreferrer"><strong>RULES</strong></a> | |
| 257 | before submitting URLs. If you want a reply to your feedback, | |
| 258 | feel free to join our | |
| 259 | <a href="https://discord.gg/wZMuSGpZ8s" target="_blank" rel="noopener noreferrer">Discord server.</a> | |
| 260 | </p> | |
| 261 | </div> | |
| 303 | 262 | </div> |
| 304 | 263 | <div v-else> |
| 305 | 264 | <p class="heading">Thanks for your feedback!</p> |
| @@ -363,42 +322,202 @@ const toggleCard = () => (isCardShown.value = !isCardShown.value) | ||
| 363 | 322 | opacity: 0.75; |
| 364 | 323 | } |
| 365 | 324 | |
| 366 | .feedback-textarea { | |
| 325 | .feedback-wrap { | |
| 326 | width: 100%; | |
| 327 | margin-top: 1rem; | |
| 328 | } | |
| 329 | ||
| 330 | .feedback-textarea, | |
| 331 | .feedback-name, | |
| 332 | .fb-type-trigger { | |
| 333 | border: 2px solid var(--vp-c-brand-soft); | |
| 334 | border-radius: 12px; | |
| 335 | background-color: var(--vp-c-bg-alt); | |
| 336 | color: var(--vp-c-text-1); | |
| 367 | 337 | font-size: 14px; |
| 338 | outline: none; | |
| 339 | transition: border-color 0.25s, box-shadow 0.25s; | |
| 340 | } | |
| 341 | ||
| 342 | .feedback-textarea:hover, | |
| 343 | .feedback-name:hover, | |
| 344 | .fb-type-trigger:hover { | |
| 345 | border-color: var(--vp-c-brand-1); | |
| 346 | } | |
| 347 | ||
| 348 | .feedback-textarea:focus, | |
| 349 | .feedback-name:focus, | |
| 350 | .fb-type-select--open .fb-type-trigger { | |
| 351 | border-color: var(--vp-c-brand-1); | |
| 352 | box-shadow: 0 0 0 2px var(--vp-c-brand-soft); | |
| 353 | } | |
| 354 | ||
| 355 | .feedback-textarea { | |
| 356 | width: 100%; | |
| 357 | min-height: 160px; | |
| 358 | padding: 0.75rem 0.9rem; | |
| 359 | resize: vertical; | |
| 368 | 360 | } |
| 369 | 361 | |
| 370 | 362 | .feedback-textarea::placeholder { |
| 371 | font-size: 12px; | |
| 363 | font-size: 14px; | |
| 364 | color: var(--vp-c-text-2); | |
| 365 | opacity: 0.55; | |
| 366 | } | |
| 367 | ||
| 368 | .feedback-name::placeholder { | |
| 369 | font-size: 14px; | |
| 370 | color: var(--vp-c-text-2); | |
| 371 | opacity: 0.55; | |
| 372 | } | |
| 373 | ||
| 374 | .feedback-row { | |
| 375 | display: grid; | |
| 376 | grid-template-columns: 1fr 1fr auto; | |
| 377 | gap: 8px; | |
| 378 | margin-top: 8px; | |
| 379 | align-items: stretch; | |
| 372 | 380 | } |
| 373 | 381 | |
| 374 | details summary { | |
| 382 | @media (max-width: 640px) { | |
| 383 | .feedback-row { | |
| 384 | grid-template-columns: 1fr; | |
| 385 | } | |
| 386 | } | |
| 387 | ||
| 388 | .feedback-name { | |
| 389 | width: 100%; | |
| 390 | padding: 0.5rem 0.75rem; | |
| 391 | line-height: 1.4; | |
| 392 | } | |
| 393 | ||
| 394 | .fb-type-select { | |
| 395 | position: relative; | |
| 396 | width: 100%; | |
| 397 | } | |
| 398 | ||
| 399 | .fb-type-trigger { | |
| 375 | 400 | display: flex; |
| 376 | 401 | align-items: center; |
| 377 | gap: 0.25rem; | |
| 402 | gap: 8px; | |
| 403 | width: 100%; | |
| 404 | height: 100%; | |
| 405 | min-height: 0; | |
| 406 | padding: 0.5rem 0.75rem; | |
| 407 | line-height: 1.4; | |
| 378 | 408 | cursor: pointer; |
| 379 | list-style: none; | |
| 380 | 409 | } |
| 381 | 410 | |
| 382 | details summary::-webkit-details-marker { | |
| 383 | display: none; | |
| 411 | .fb-type-icon { | |
| 412 | flex-shrink: 0; | |
| 413 | width: 16px; | |
| 414 | height: 16px; | |
| 384 | 415 | } |
| 385 | 416 | |
| 386 | details summary .arrow-right { | |
| 387 | display: inline-block; | |
| 388 | flex-shrink: 0; | |
| 417 | .fb-type-label { | |
| 418 | flex: 1; | |
| 419 | text-align: left; | |
| 420 | white-space: nowrap; | |
| 421 | overflow: hidden; | |
| 422 | text-overflow: ellipsis; | |
| 423 | } | |
| 424 | ||
| 425 | .fb-type-trigger--placeholder .fb-type-icon, | |
| 426 | .fb-type-trigger--placeholder .fb-type-label { | |
| 427 | opacity: 0.55; | |
| 389 | 428 | } |
| 390 | 429 | |
| 391 | details summary .arrow-down { | |
| 392 | display: none; | |
| 430 | .fb-type-chevron { | |
| 393 | 431 | flex-shrink: 0; |
| 432 | width: 16px; | |
| 433 | height: 16px; | |
| 434 | color: var(--vp-c-text-2); | |
| 435 | transition: transform 0.2s ease; | |
| 394 | 436 | } |
| 395 | 437 | |
| 396 | details[open] summary .arrow-right { | |
| 397 | display: none; | |
| 438 | .fb-type-chevron--open { | |
| 439 | transform: rotate(180deg); | |
| 398 | 440 | } |
| 399 | 441 | |
| 400 | details[open] summary .arrow-down { | |
| 401 | display: inline-block; | |
| 442 | .fb-type-options { | |
| 443 | position: absolute; | |
| 444 | z-index: 20; | |
| 445 | top: calc(100% + 6px); | |
| 446 | left: 0; | |
| 447 | right: 0; | |
| 448 | max-height: 240px; | |
| 449 | overflow-y: auto; | |
| 450 | overscroll-behavior: contain; | |
| 451 | display: grid; | |
| 452 | grid-template-columns: repeat(2, 1fr); | |
| 453 | gap: 2px; | |
| 454 | padding: 4px; | |
| 455 | border-radius: 12px; | |
| 456 | border: 2px solid var(--vp-c-brand-1); | |
| 457 | background: var(--vp-c-bg-elv); | |
| 458 | box-shadow: var(--vp-shadow-2); | |
| 459 | } | |
| 460 | ||
| 461 | .fb-type-option { | |
| 462 | display: flex; | |
| 463 | align-items: center; | |
| 464 | gap: 8px; | |
| 465 | padding: 5px 8px; | |
| 466 | border-radius: 8px; | |
| 467 | border: none; | |
| 468 | background: transparent; | |
| 469 | cursor: pointer; | |
| 470 | color: var(--vp-c-text-1); | |
| 471 | font-size: 13px; | |
| 472 | width: 100%; | |
| 473 | transition: background-color 0.15s; | |
| 474 | } | |
| 475 | ||
| 476 | .fb-type-option:hover { | |
| 477 | background-color: var(--vp-c-bg-soft); | |
| 478 | } | |
| 479 | ||
| 480 | .fb-type-option--selected { | |
| 481 | background-color: var(--vp-c-brand-soft); | |
| 482 | } | |
| 483 | ||
| 484 | .fb-type-option--selected .fb-type-label { | |
| 485 | font-weight: 600; | |
| 486 | } | |
| 487 | ||
| 488 | .fb-type-option--selected:hover { | |
| 489 | background-color: var(--vp-c-brand-soft); | |
| 490 | } | |
| 491 | ||
| 492 | .feedback-send { | |
| 493 | display: inline-flex; | |
| 494 | align-items: center; | |
| 495 | justify-content: center; | |
| 496 | gap: 0.4rem; | |
| 497 | padding: 0.5rem 1rem; | |
| 498 | border: 2px solid var(--vp-c-brand-1); | |
| 499 | border-radius: 12px; | |
| 500 | background-color: var(--vp-c-brand-1); | |
| 501 | color: #fff; | |
| 502 | font-size: 14px; | |
| 503 | font-weight: 600; | |
| 504 | line-height: 1.4; | |
| 505 | white-space: nowrap; | |
| 506 | cursor: pointer; | |
| 507 | transition: filter 0.25s, opacity 0.25s; | |
| 508 | } | |
| 509 | ||
| 510 | :global(html.dark) .feedback-send { | |
| 511 | color: #000; | |
| 512 | } | |
| 513 | ||
| 514 | .feedback-send:hover:not(:disabled) { | |
| 515 | filter: brightness(1.1); | |
| 516 | } | |
| 517 | ||
| 518 | .feedback-send:disabled { | |
| 519 | opacity: 0.5; | |
| 520 | cursor: not-allowed; | |
| 402 | 521 | } |
| 403 | 522 | |
| 404 | 523 | .fade-enter-active, |