Skip to content

Commit 5a99f63

Browse files
committed
Maintaining thumbnail ratio only at large card scales
1 parent 9004be5 commit 5a99f63

File tree

1 file changed

+12
-16
lines changed
  • kolibri/plugins/learn/assets/src/views/content-card

1 file changed

+12
-16
lines changed

kolibri/plugins/learn/assets/src/views/content-card/index.vue

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22

3-
<router-link :to="link" class="card" :style="cardHeight">
3+
<router-link :to="link" class="card">
44

5-
<div class="card-thumbnail" :style="backgroundImg">
5+
<div class="card-thumbnail" :style="cardThumbnail">
66
<content-icon v-if="!thumbnail" :kind="kind" :style="iconSize" class="card-thumbnail-backup"/>
77
<div v-show="progress > 0" class="card-progress-icon-wrapper">
88
<progress-icon :progress="progress"/>
@@ -85,28 +85,26 @@
8585
mastered() {
8686
return this.progress === 1;
8787
},
88-
cardHeight() {
89-
// set here so that parent component can set width and have height dynamically calculated
90-
return {
91-
height: `${this.elSize.width}px`,
92-
};
88+
thumbnailHeight() {
89+
return this.elSize.width * (9 / 16);
9390
},
9491
iconSize() {
95-
const cardHeight = this.elSize.width; // can use height or width because it's a square
9692
// maintain the thumbnail 16:9 ratio
97-
const thumbnailHeight = this.elSize.width * (9 / 16);
9893
return {
99-
'font-size': `${thumbnailHeight / 2}px`,
94+
'font-size': `${this.thumbnailHeight / 2}px`,
10095
};
10196
},
10297
inProgress() {
10398
return this.progress > 0 && this.progress < 1;
10499
},
105-
backgroundImg() {
100+
cardThumbnail() {
101+
const thumbnailStyles = {
102+
height: `${this.thumbnailHeight}px`,
103+
};
106104
if (this.thumbnail) {
107-
return { backgroundImage: `url('${this.thumbnail}')` };
105+
thumbnailStyles.backgroundImage = `url('${this.thumbnail}')`;
108106
}
109-
return {};
107+
return thumbnailStyles;
110108
},
111109
backgroundClass() {
112110
if (this.kind === 'exercise') {
@@ -138,8 +136,7 @@
138136
139137
$card-width = 210px
140138
$card-thumbnail-ratio = (9 / 16)
141-
$card-thumbnail-height = 100% * $card-thumbnail-ratio
142-
$card-text-height = $card-width - $card-thumbnail-height
139+
$card-text-height = $card-width - ($card-width * $card-thumbnail-ratio)
143140
$card-text-padding = ($card-width / (320 / 24))
144141
$card-elevation-resting = 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12)
145142
$card-elevation-raised = 0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12), 0 5px 5px -3px rgba(0, 0, 0, 0.2)
@@ -161,7 +158,6 @@
161158
.card-thumbnail
162159
position: relative
163160
width: 100%
164-
height: $card-thumbnail-height
165161
background-size: cover
166162
background-position: center
167163
background-color: $core-grey

0 commit comments

Comments
 (0)