Skip to content

Commit 9c77c95

Browse files
committed
Choosing content card component dynamically based on window size
Naming all componenets, getting rid of deprecated `$trNamespace` running into issues with windowSize - seems like it's not updating, but only when carousel is included.
1 parent 98a1919 commit 9c77c95

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
const gutterWidth = 20;
8383
8484
export default {
85-
mixins: [responsiveElement],
8685
name: 'contentCardCarousel',
86+
mixins: [responsiveElement],
8787
$trs: { viewAllButtonLabel: 'View all' },
8888
props: {
8989
contents: {

kolibri/plugins/learn/assets/src/views/learn-page/index.vue

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,37 @@
44
<page-header :title="$tr('pageHeader')">
55
<mat-svg slot="icon" category="action" name="home"/>
66
</page-header>
7-
<content-card-carousel
7+
<component
88
v-if="trimmedResume.length"
9+
:is="recommendationDisplay"
910
:gen-link="genLink"
1011
:contents="trimmedResume"
1112
:header="$tr('resumeSectionHeader')"
13+
:filter="false"
1214
:subheader="$tr('resumeSectionSubHeader', {numOfItems: trimmedResume.length})"/>
13-
<content-card-carousel
15+
<component
1416
v-if="trimmedNextSteps.length"
17+
:is="recommendationDisplay"
1518
:gen-link="genLink"
1619
:contents="trimmedNextSteps"
1720
:header="$tr('suggestedNextStepsSectionHeader')"
21+
:filter="false"
1822
:subheader="$tr('suggestedNextStepsSectionSubHeader', {numOfItems: trimmedNextSteps.length})"/>
19-
<content-card-carousel
23+
<component
2024
v-if="trimmedPopular.length"
25+
:is="recommendationDisplay"
2126
:gen-link="genLink"
2227
:contents="trimmedPopular"
2328
:header="$tr('popularSectionHeader')"
29+
:filter="false"
2430
:subheader="$tr('popularSectionSubHeader', {numOfItems: trimmedPopular.length})"/>
25-
<content-card-carousel
31+
<component
2632
v-if="trimmedOverview.length"
33+
:is="recommendationDisplay"
2734
:showViewAll="true"
2835
:gen-link="genLink"
2936
:header="$tr('overviewSectionHeader')"
37+
:filter="false"
3038
:contents="trimmedOverview" />
3139
</div>
3240

@@ -39,12 +47,13 @@
3947
import { getCurrentChannelObject } from 'kolibri.coreVue.vuex.getters';
4048
import pageHeader from '../page-header';
4149
import contentCardCarousel from '../content-card-carousel';
50+
import contentCardGrid from '../content-card-grid';
4251
import responsiveWindow from 'kolibri.coreVue.mixins.responsiveWindow';
4352
4453
const mobileCardNumber = 3;
4554
4655
export default {
47-
$trNameSpace: 'learnPageIndex',
56+
name: 'recommendedPage',
4857
$trs: {
4958
pageHeader: 'Recommended',
5059
popularSectionHeader: 'Most popular',
@@ -59,11 +68,18 @@
5968
components: {
6069
pageHeader,
6170
contentCardCarousel,
71+
contentCardGrid,
6272
},
6373
computed: {
6474
isMobile() {
6575
return this.windowSize.breakpoint <= 2;
6676
},
77+
recommendationDisplay() {
78+
if (this.isMobile) {
79+
return contentCardGrid;
80+
}
81+
return contentCardCarousel;
82+
},
6783
trimmedResume() {
6884
if (this.isMobile) {
6985
return this.recommendations.resume.slice(0, mobileCardNumber);

0 commit comments

Comments
 (0)