|
1 | 1 | <script lang="ts">
|
| 2 | + import { Image } from "@gradio/image/shared"; |
| 3 | + import type { FileData } from "@gradio/client"; |
| 4 | +
|
2 | 5 | export let layout = "bubble";
|
| 6 | + export let avatar_images: [FileData | null, FileData | null] = [null, null]; |
3 | 7 | </script>
|
4 | 8 |
|
5 |
| -<div |
6 |
| - class="message pending" |
7 |
| - role="status" |
8 |
| - aria-label="Loading response" |
9 |
| - aria-live="polite" |
10 |
| - style:border-radius={layout === "bubble" ? "var(--radius-xxl)" : "none"} |
11 |
| -> |
12 |
| - <span class="sr-only">Loading content</span> |
13 |
| - <div class="dot-flashing" /> |
14 |
| - |
15 |
| - <div class="dot-flashing" /> |
16 |
| - |
17 |
| - <div class="dot-flashing" /> |
| 9 | +<div class="container"> |
| 10 | + {#if avatar_images[1] !== null} |
| 11 | + <div class="avatar-container"> |
| 12 | + <Image class="avatar-image" src={avatar_images[1].url} alt="bot avatar" /> |
| 13 | + </div> |
| 14 | + {/if} |
| 15 | + |
| 16 | + <div |
| 17 | + class="message bot pending {layout}" |
| 18 | + class:with_avatar={avatar_images[1] !== null} |
| 19 | + class:with_opposite_avatar={avatar_images[0] !== null} |
| 20 | + role="status" |
| 21 | + aria-label="Loading response" |
| 22 | + aria-live="polite" |
| 23 | + > |
| 24 | + <div class="message-content"> |
| 25 | + <span class="sr-only">Loading content</span> |
| 26 | + <div class="dots"> |
| 27 | + <div class="dot" /> |
| 28 | + <div class="dot" /> |
| 29 | + <div class="dot" /> |
| 30 | + </div> |
| 31 | + </div> |
| 32 | + </div> |
18 | 33 | </div>
|
19 | 34 |
|
20 | 35 | <style>
|
21 |
| - .pending { |
22 |
| - background: var(--color-accent-soft); |
| 36 | + .container { |
23 | 37 | display: flex;
|
24 |
| - flex-direction: row; |
25 |
| - justify-content: center; |
26 |
| - align-items: center; |
27 |
| - align-self: center; |
28 |
| - gap: 2px; |
| 38 | + margin: calc(var(--spacing-xl) * 2); |
| 39 | + } |
| 40 | +
|
| 41 | + .bubble.pending { |
| 42 | + border-width: 1px; |
| 43 | + border-radius: var(--radius-lg); |
| 44 | + border-bottom-left-radius: 0; |
| 45 | + border-color: var(--border-color-primary); |
| 46 | + background-color: var(--background-fill-secondary); |
| 47 | + box-shadow: var(--shadow-drop); |
| 48 | + align-self: flex-start; |
| 49 | + width: fit-content; |
| 50 | + margin-bottom: var(--spacing-xl); |
| 51 | + } |
| 52 | +
|
| 53 | + .bubble.with_opposite_avatar { |
| 54 | + margin-right: calc(var(--spacing-xxl) + 35px + var(--spacing-xxl)); |
| 55 | + } |
| 56 | +
|
| 57 | + .panel.pending { |
| 58 | + margin: 0; |
| 59 | + padding: calc(var(--spacing-lg) * 2) calc(var(--spacing-lg) * 2); |
29 | 60 | width: 100%;
|
30 |
| - height: var(--size-16); |
| 61 | + border: none; |
| 62 | + background: none; |
| 63 | + box-shadow: none; |
| 64 | + border-radius: 0; |
31 | 65 | }
|
32 |
| - .dot-flashing { |
33 |
| - animation: flash 1s infinite ease-in-out; |
34 |
| - border-radius: 5px; |
| 66 | +
|
| 67 | + .panel.with_avatar { |
| 68 | + padding-left: calc(var(--spacing-xl) * 2) !important; |
| 69 | + padding-right: calc(var(--spacing-xl) * 2) !important; |
| 70 | + } |
| 71 | +
|
| 72 | + .avatar-container { |
| 73 | + align-self: flex-start; |
| 74 | + position: relative; |
| 75 | + display: flex; |
| 76 | + justify-content: flex-start; |
| 77 | + align-items: flex-start; |
| 78 | + width: 35px; |
| 79 | + height: 35px; |
| 80 | + flex-shrink: 0; |
| 81 | + bottom: 0; |
| 82 | + border-radius: 50%; |
| 83 | + border: 1px solid var(--border-color-primary); |
| 84 | + margin-right: var(--spacing-xxl); |
| 85 | + } |
| 86 | +
|
| 87 | + .message-content { |
| 88 | + padding: var(--spacing-sm) var(--spacing-xl); |
| 89 | + min-height: var(--size-8); |
| 90 | + display: flex; |
| 91 | + align-items: center; |
| 92 | + } |
| 93 | +
|
| 94 | + .dots { |
| 95 | + display: flex; |
| 96 | + gap: var(--spacing-xs); |
| 97 | + align-items: center; |
| 98 | + } |
| 99 | +
|
| 100 | + .dot { |
| 101 | + width: var(--size-1-5); |
| 102 | + height: var(--size-1-5); |
| 103 | + margin-right: var(--spacing-xs); |
| 104 | + border-radius: 50%; |
35 | 105 | background-color: var(--body-text-color);
|
36 |
| - width: 7px; |
37 |
| - height: 7px; |
38 |
| - color: var(--body-text-color); |
| 106 | + opacity: 0.5; |
| 107 | + animation: pulse 1.5s infinite; |
| 108 | + } |
| 109 | +
|
| 110 | + .dot:nth-child(2) { |
| 111 | + animation-delay: 0.2s; |
39 | 112 | }
|
40 |
| - @keyframes flash { |
| 113 | +
|
| 114 | + .dot:nth-child(3) { |
| 115 | + animation-delay: 0.4s; |
| 116 | + } |
| 117 | +
|
| 118 | + @keyframes pulse { |
41 | 119 | 0%,
|
42 | 120 | 100% {
|
43 |
| - opacity: 0; |
| 121 | + opacity: 0.4; |
| 122 | + transform: scale(1); |
44 | 123 | }
|
45 | 124 | 50% {
|
46 | 125 | opacity: 1;
|
| 126 | + transform: scale(1.1); |
47 | 127 | }
|
48 | 128 | }
|
49 |
| -
|
50 |
| - .dot-flashing:nth-child(1) { |
51 |
| - animation-delay: 0s; |
52 |
| - } |
53 |
| -
|
54 |
| - .dot-flashing:nth-child(2) { |
55 |
| - animation-delay: 0.33s; |
56 |
| - } |
57 |
| - .dot-flashing:nth-child(3) { |
58 |
| - animation-delay: 0.66s; |
59 |
| - } |
60 | 129 | </style>
|
0 commit comments