Skip to content

Commit 2a280d7

Browse files
authored
Merge pull request #5142 from ozer550/fix-double-wrapped-thumbnail-icon
Fix double wrapped thumbnail icon
2 parents e053d82 + 3f0ad6a commit 2a280d7

2 files changed

Lines changed: 49 additions & 114 deletions

File tree

contentcuration/contentcuration/frontend/shared/views/channel/ChannelThumbnail.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
>
1717
<VCard
1818
ref="thumbnail"
19-
class="thumbnail"
19+
class="thumbnail-wrapper"
2020
data-test="loading"
2121
>
2222
<VLayout
@@ -355,7 +355,7 @@
355355
border: 2px solid var(--v-grey-darken2);
356356
}
357357
358-
.thumbnail {
358+
.thumbnail-wrapper {
359359
padding: 28% 0;
360360
/* stylelint-disable-next-line custom-property-pattern */
361361
border-color: var(--v-greyBorder-base) !important;

contentcuration/contentcuration/frontend/shared/views/files/Thumbnail.vue

Lines changed: 47 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
[kind]: compact,
77
'icon-only': compact,
88
nothumbnail: !showThumbnail && !compact,
9+
'with-caption': showCaption,
910
}"
1011
:style="{ 'max-width': maxWidth }"
1112
>
1213
<VLayout
13-
v-if="kind && !printing && showKind && !compact"
14+
v-if="showCaption"
1415
tag="figcaption"
1516
row
1617
align-center
@@ -21,12 +22,10 @@
2122
shrink
2223
class="px-1"
2324
>
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"
3029
/>
3130
</VFlex>
3231
<VFlex shrink>
@@ -46,51 +45,42 @@
4645
v-else-if="printing"
4746
class="printable-icon"
4847
>
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+
/>
5552
</div>
5653

57-
<!-- Bury icon within SVG so it's more responsive, since font-size scaling is more difficult -->
58-
<svg
54+
<div
5955
v-else-if="compact"
60-
viewBox="0 0 24 24"
61-
:aria-label="kindTitle"
62-
class="thumbnail-image"
56+
class="kicon-wrapper"
6357
>
6458
<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"
6962
/>
70-
</svg>
71-
<svg
63+
</div>
64+
<div
7265
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"
7767
>
7868
<KIcon
7969
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' }"
8373
/>
84-
</svg>
74+
</div>
8575
</figure>
8676

8777
</template>
8878

8979

9080
<script>
9181
82+
import { getContentKindIcon } from 'shared/utils/icons';
9283
import { constantsTranslationMixin, printingMixin } from 'shared/mixins';
93-
import { getContentKindIcon } from 'shared/vuetify/icons';
9484
9585
export default {
9686
name: 'Thumbnail',
@@ -136,22 +126,15 @@
136126
},
137127
},
138128
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-
},
149129
objectFit() {
150130
return this.kind ? 'cover' : 'contain';
151131
},
152132
icon() {
153133
return getContentKindIcon(this.kind, this.isEmpty);
154134
},
135+
showCaption() {
136+
return this.kind && !this.printing && this.showKind && !this.compact;
137+
},
155138
thumbnailSrc() {
156139
return this.encoding && this.encoding.base64 ? this.encoding.base64 : this.src;
157140
},
@@ -176,16 +159,8 @@
176159
<style lang="scss" scoped>
177160
178161
$caption-height: 25px;
179-
$svg-scale: 1.25;
180162
$aspect-ratio: 9 / 16;
181-
182163
$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;
189164
190165
.thumbnail {
191166
position: relative;
@@ -218,15 +193,11 @@
218193
line-height: 11px;
219194
}
220195
221-
.thumbnail-image,
222-
.nothumbnail-image {
196+
.thumbnail-image {
223197
position: absolute;
224-
display: block;
225-
}
226-
227-
img.thumbnail-image {
228198
bottom: 0;
229199
left: 0;
200+
display: block;
230201
width: 100%;
231202
height: 100%;
232203
overflow: hidden; // Don't show alt text outside of img boundaries
@@ -236,61 +207,6 @@
236207
}
237208
}
238209
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-
294210
.printable-icon {
295211
width: 100%;
296212
height: 0;
@@ -302,4 +218,23 @@
302218
}
303219
}
304220
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+
305240
</style>

0 commit comments

Comments
 (0)