|
1 | 1 | <template> |
2 | 2 |
|
3 | | - <router-link :to="link" class="card" :style="cardHeight"> |
| 3 | + <router-link :to="link" class="card"> |
4 | 4 |
|
5 | | - <div class="card-thumbnail" :style="backgroundImg"> |
| 5 | + <div class="card-thumbnail" :style="cardThumbnail"> |
6 | 6 | <content-icon v-if="!thumbnail" :kind="kind" :style="iconSize" class="card-thumbnail-backup"/> |
7 | 7 | <div v-show="progress > 0" class="card-progress-icon-wrapper"> |
8 | 8 | <progress-icon :progress="progress"/> |
|
85 | 85 | mastered() { |
86 | 86 | return this.progress === 1; |
87 | 87 | }, |
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); |
93 | 90 | }, |
94 | 91 | iconSize() { |
95 | | - const cardHeight = this.elSize.width; // can use height or width because it's a square |
96 | 92 | // maintain the thumbnail 16:9 ratio |
97 | | - const thumbnailHeight = this.elSize.width * (9 / 16); |
98 | 93 | return { |
99 | | - 'font-size': `${thumbnailHeight / 2}px`, |
| 94 | + 'font-size': `${this.thumbnailHeight / 2}px`, |
100 | 95 | }; |
101 | 96 | }, |
102 | 97 | inProgress() { |
103 | 98 | return this.progress > 0 && this.progress < 1; |
104 | 99 | }, |
105 | | - backgroundImg() { |
| 100 | + cardThumbnail() { |
| 101 | + const thumbnailStyles = { |
| 102 | + height: `${this.thumbnailHeight}px`, |
| 103 | + }; |
106 | 104 | if (this.thumbnail) { |
107 | | - return { backgroundImage: `url('${this.thumbnail}')` }; |
| 105 | + thumbnailStyles.backgroundImage = `url('${this.thumbnail}')`; |
108 | 106 | } |
109 | | - return {}; |
| 107 | + return thumbnailStyles; |
110 | 108 | }, |
111 | 109 | backgroundClass() { |
112 | 110 | if (this.kind === 'exercise') { |
|
138 | 136 |
|
139 | 137 | $card-width = 210px |
140 | 138 | $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) |
143 | 140 | $card-text-padding = ($card-width / (320 / 24)) |
144 | 141 | $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) |
145 | 142 | $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 | 158 | .card-thumbnail |
162 | 159 | position: relative |
163 | 160 | width: 100% |
164 | | - height: $card-thumbnail-height |
165 | 161 | background-size: cover |
166 | 162 | background-position: center |
167 | 163 | background-color: $core-grey |
|
0 commit comments