|
| 1 | +<script lang="ts"> |
| 2 | + import type { PdfSearchUpdate } from "$lib/types/MessageUpdate"; |
| 3 | + import CarbonCaretRight from "~icons/carbon/caret-right"; |
| 4 | +
|
| 5 | + import CarbonCheckmark from "~icons/carbon/checkmark-filled"; |
| 6 | + import CarbonError from "~icons/carbon/error-filled"; |
| 7 | +
|
| 8 | + import EosIconsLoading from "~icons/eos-icons/loading"; |
| 9 | +
|
| 10 | + export let loading = false; |
| 11 | + export let classNames = ""; |
| 12 | + export let pdfSearchMessages: PdfSearchUpdate[] = []; |
| 13 | +
|
| 14 | + let detailsOpen: boolean; |
| 15 | + let error: boolean; |
| 16 | + $: error = pdfSearchMessages[pdfSearchMessages.length - 1]?.messageType === "error"; |
| 17 | +</script> |
| 18 | + |
| 19 | +<details |
| 20 | + class="flex w-fit rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-800 dark:bg-gray-900 {classNames} max-w-full" |
| 21 | + bind:open={detailsOpen} |
| 22 | +> |
| 23 | + <summary |
| 24 | + class="align-center flex cursor-pointer select-none list-none py-1 pl-2.5 pr-2 align-text-top transition-all" |
| 25 | + > |
| 26 | + {#if error} |
| 27 | + <CarbonError class="my-auto text-red-700 dark:text-red-500" /> |
| 28 | + {:else if loading} |
| 29 | + <EosIconsLoading class="my-auto text-gray-500" /> |
| 30 | + {:else} |
| 31 | + <CarbonCheckmark class="my-auto text-gray-500" /> |
| 32 | + {/if} |
| 33 | + <span class="px-2 font-medium" class:text-red-700={error} class:dark:text-red-500={error} |
| 34 | + >PDF search |
| 35 | + </span> |
| 36 | + <div class="my-auto transition-all" class:rotate-90={detailsOpen}> |
| 37 | + <CarbonCaretRight /> |
| 38 | + </div> |
| 39 | + </summary> |
| 40 | + |
| 41 | + <div class="content px-5 pb-5 pt-4"> |
| 42 | + {#if pdfSearchMessages.length === 0} |
| 43 | + <div class="mx-auto w-fit"> |
| 44 | + <EosIconsLoading class="mb-3 h-4 w-4" /> |
| 45 | + </div> |
| 46 | + {:else} |
| 47 | + <ol> |
| 48 | + {#each pdfSearchMessages as message} |
| 49 | + {#if message.messageType === "update"} |
| 50 | + <li class="group border-l pb-6 last:!border-transparent last:pb-0 dark:border-gray-800"> |
| 51 | + <div class="flex items-start"> |
| 52 | + <div |
| 53 | + class="-ml-1.5 h-3 w-3 flex-none rounded-full bg-gray-200 dark:bg-gray-600 {loading |
| 54 | + ? 'group-last:animate-pulse group-last:bg-gray-300 group-last:dark:bg-gray-500' |
| 55 | + : ''}" |
| 56 | + /> |
| 57 | + <h3 class="text-md -mt-1.5 pl-2.5 text-gray-800 dark:text-gray-100"> |
| 58 | + {message.message} |
| 59 | + </h3> |
| 60 | + </div> |
| 61 | + {#if message.args} |
| 62 | + <p class="mt-1.5 pl-4 text-gray-500 dark:text-gray-400"> |
| 63 | + {message.args} |
| 64 | + </p> |
| 65 | + {/if} |
| 66 | + </li> |
| 67 | + {:else if message.messageType === "error"} |
| 68 | + <li class="group border-l pb-6 last:!border-transparent last:pb-0 dark:border-gray-800"> |
| 69 | + <div class="flex items-start"> |
| 70 | + <CarbonError |
| 71 | + class="-ml-1.5 h-3 w-3 flex-none scale-110 text-red-700 dark:text-red-500" |
| 72 | + /> |
| 73 | + <h3 class="text-md -mt-1.5 pl-2.5 text-red-700 dark:text-red-500"> |
| 74 | + {message.message} |
| 75 | + </h3> |
| 76 | + </div> |
| 77 | + {#if message.args} |
| 78 | + <p class="mt-1.5 pl-4 text-gray-500 dark:text-gray-400"> |
| 79 | + {message.args} |
| 80 | + </p> |
| 81 | + {/if} |
| 82 | + </li> |
| 83 | + {/if} |
| 84 | + {/each} |
| 85 | + </ol> |
| 86 | + {/if} |
| 87 | + </div> |
| 88 | +</details> |
| 89 | + |
| 90 | +<style> |
| 91 | + @keyframes grow { |
| 92 | + 0% { |
| 93 | + font-size: 0; |
| 94 | + opacity: 0; |
| 95 | + } |
| 96 | + 30% { |
| 97 | + font-size: 1em; |
| 98 | + opacity: 0; |
| 99 | + } |
| 100 | + 100% { |
| 101 | + opacity: 1; |
| 102 | + } |
| 103 | + } |
| 104 | +
|
| 105 | + details[open] .content { |
| 106 | + animation-name: grow; |
| 107 | + animation-duration: 300ms; |
| 108 | + animation-delay: 0ms; |
| 109 | + } |
| 110 | +
|
| 111 | + details summary::-webkit-details-marker { |
| 112 | + display: none; |
| 113 | + } |
| 114 | +</style> |
0 commit comments