|
6 | 6 | [kind]: compact, |
7 | 7 | 'icon-only': compact, |
8 | 8 | nothumbnail: !showThumbnail && !compact, |
| 9 | + 'with-caption': showCaption, |
9 | 10 | }" |
10 | 11 | :style="{ 'max-width': maxWidth }" |
11 | 12 | > |
12 | 13 | <VLayout |
13 | | - v-if="kind && !printing && showKind && !compact" |
| 14 | + v-if="showCaption" |
14 | 15 | tag="figcaption" |
15 | 16 | row |
16 | 17 | align-center |
|
21 | 22 | shrink |
22 | 23 | class="px-1" |
23 | 24 | > |
24 | | - <VIconWrapper |
25 | | - v-if="!compact" |
26 | | - dark |
27 | | - small |
28 | | - :aria-label="kindTitle" |
29 | | - v-text="icon" |
| 25 | + <KIcon |
| 26 | + :icon="icon" |
| 27 | + class="icon-thumbnail" |
| 28 | + :color="$themeTokens.textInverted" |
30 | 29 | /> |
31 | 30 | </VFlex> |
32 | 31 | <VFlex shrink> |
|
46 | 45 | v-else-if="printing" |
47 | 46 | class="printable-icon" |
48 | 47 | > |
49 | | - <VIconWrapper |
50 | | - :color="$vuetify.theme[kind]" |
51 | | - capture-as-image |
52 | | - > |
53 | | - {{ icon }} |
54 | | - </VIconWrapper> |
| 48 | + <KIcon |
| 49 | + class="icon-thumbnail" |
| 50 | + :icon="icon" |
| 51 | + /> |
55 | 52 | </div> |
56 | 53 |
|
57 | | - <!-- Bury icon within SVG so it's more responsive, since font-size scaling is more difficult --> |
58 | | - <svg |
| 54 | + <div |
59 | 55 | v-else-if="compact" |
60 | | - viewBox="0 0 24 24" |
61 | | - :aria-label="kindTitle" |
62 | | - class="thumbnail-image" |
| 56 | + class="kicon-wrapper" |
63 | 57 | > |
64 | 58 | <KIcon |
65 | | - icon="infoOutline" |
66 | | - :x="+10" |
67 | | - :y="y + 20" |
68 | | - :style="{ fill: '#ffffff' }" |
| 59 | + :icon="icon" |
| 60 | + class="icon-thumbnail" |
| 61 | + :color="$themeTokens.textInverted" |
69 | 62 | /> |
70 | | - </svg> |
71 | | - <svg |
| 63 | + </div> |
| 64 | + <div |
72 | 65 | v-else |
73 | | - viewBox="0 0 40 40" |
74 | | - :aria-label="kindTitle" |
75 | | - class="nothumbnail-image" |
76 | | - :class="$isRTL ? 'rtl-image' : 'ltr-image'" |
| 66 | + class="kicon-wrapper" |
77 | 67 | > |
78 | 68 | <KIcon |
79 | 69 | icon="image" |
80 | | - :x="-3" |
81 | | - :y="y - 14" |
82 | | - :style="{ fill: '#999999' }" |
| 70 | + class="icon-thumbnail" |
| 71 | + :color="$themePalette.grey.v_400" |
| 72 | + :style="{ width: '40%', height: '50px' }" |
83 | 73 | /> |
84 | | - </svg> |
| 74 | + </div> |
85 | 75 | </figure> |
86 | 76 |
|
87 | 77 | </template> |
88 | 78 |
|
89 | 79 |
|
90 | 80 | <script> |
91 | 81 |
|
| 82 | + import { getContentKindIcon } from 'shared/utils/icons'; |
92 | 83 | import { constantsTranslationMixin, printingMixin } from 'shared/mixins'; |
93 | | - import { getContentKindIcon } from 'shared/vuetify/icons'; |
94 | 84 |
|
95 | 85 | export default { |
96 | 86 | name: 'Thumbnail', |
|
136 | 126 | }, |
137 | 127 | }, |
138 | 128 | computed: { |
139 | | - y() { |
140 | | - switch (this.kind) { |
141 | | - case 'exercise': |
142 | | - return 28; |
143 | | - case 'topic': |
144 | | - case 'audio': |
145 | | - default: |
146 | | - return 26; |
147 | | - } |
148 | | - }, |
149 | 129 | objectFit() { |
150 | 130 | return this.kind ? 'cover' : 'contain'; |
151 | 131 | }, |
152 | 132 | icon() { |
153 | 133 | return getContentKindIcon(this.kind, this.isEmpty); |
154 | 134 | }, |
| 135 | + showCaption() { |
| 136 | + return this.kind && !this.printing && this.showKind && !this.compact; |
| 137 | + }, |
155 | 138 | thumbnailSrc() { |
156 | 139 | return this.encoding && this.encoding.base64 ? this.encoding.base64 : this.src; |
157 | 140 | }, |
|
176 | 159 | <style lang="scss" scoped> |
177 | 160 |
|
178 | 161 | $caption-height: 25px; |
179 | | - $svg-scale: 1.25; |
180 | 162 | $aspect-ratio: 9 / 16; |
181 | | -
|
182 | 163 | $aspect-percentage: $aspect-ratio * 100%; |
183 | | - $half-aspect-percentage: $aspect-percentage / 2; |
184 | | -
|
185 | | - $svg-width: $aspect-percentage / $svg-scale; |
186 | | - $svg-top: $half-aspect-percentage - ($svg-width / 2); |
187 | | - $svg-width-quarter: $svg-width / 4; |
188 | | - $svg-left-position: 50% - $svg-width-quarter; |
189 | 164 |
|
190 | 165 | .thumbnail { |
191 | 166 | position: relative; |
|
218 | 193 | line-height: 11px; |
219 | 194 | } |
220 | 195 |
|
221 | | - .thumbnail-image, |
222 | | - .nothumbnail-image { |
| 196 | + .thumbnail-image { |
223 | 197 | position: absolute; |
224 | | - display: block; |
225 | | - } |
226 | | -
|
227 | | - img.thumbnail-image { |
228 | 198 | bottom: 0; |
229 | 199 | left: 0; |
| 200 | + display: block; |
230 | 201 | width: 100%; |
231 | 202 | height: 100%; |
232 | 203 | overflow: hidden; // Don't show alt text outside of img boundaries |
|
236 | 207 | } |
237 | 208 | } |
238 | 209 |
|
239 | | - svg.thumbnail-image { |
240 | | - top: 0; |
241 | | - left: $svg-left-position; |
242 | | - width: $svg-width-quarter; |
243 | | - margin: 0 auto; |
244 | | - overflow: visible; |
245 | | -
|
246 | | - .icon-only & { |
247 | | - top: 18%; |
248 | | - left: 21%; |
249 | | - display: block; |
250 | | - width: 55%; |
251 | | -
|
252 | | - [dir='rtl'] & { |
253 | | - left: -10px; |
254 | | - } |
255 | | - } |
256 | | -
|
257 | | - text { |
258 | | - font-size: 1.8em; |
259 | | - line-height: 1.8em; |
260 | | - } |
261 | | - } |
262 | | -
|
263 | | - svg.nothumbnail-image { |
264 | | - top: 0; |
265 | | - width: $svg-width; |
266 | | - margin: 0 auto; |
267 | | - overflow: visible; |
268 | | -
|
269 | | - &.ltr-image { |
270 | | - left: 36%; |
271 | | - } |
272 | | -
|
273 | | - &.rtl-image { |
274 | | - right: 66%; |
275 | | - } |
276 | | -
|
277 | | - .caption + & { |
278 | | - top: calc(#{$caption-height / 2} + #{$svg-top}); |
279 | | - } |
280 | | -
|
281 | | - .icon-only & { |
282 | | - top: 18%; |
283 | | - left: 21%; |
284 | | - display: block; |
285 | | - width: 55%; |
286 | | - } |
287 | | -
|
288 | | - text { |
289 | | - font-size: 1em; |
290 | | - line-height: 1em; |
291 | | - } |
292 | | - } |
293 | | -
|
294 | 210 | .printable-icon { |
295 | 211 | width: 100%; |
296 | 212 | height: 0; |
|
302 | 218 | } |
303 | 219 | } |
304 | 220 |
|
| 221 | + .kicon-wrapper { |
| 222 | + position: absolute; |
| 223 | + display: flex; |
| 224 | + align-items: center; |
| 225 | + justify-content: center; |
| 226 | + width: 100%; |
| 227 | + height: 100%; |
| 228 | +
|
| 229 | + .icon-thumbnail { |
| 230 | + top: 0; |
| 231 | + } |
| 232 | + } |
| 233 | +
|
| 234 | + .thumbnail.with-caption { |
| 235 | + .kicon-wrapper { |
| 236 | + height: calc(100% - #{$caption-height}); |
| 237 | + } |
| 238 | + } |
| 239 | +
|
305 | 240 | </style> |
0 commit comments