Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions kolibri_explore_plugin/assets/src/components/EkIguanaList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@
{{ name }}
</h5>
</b-container>
<b-container class="no-container-padding">
<EkSlidableGrid
<b-container fluid class="no-container-padding">
<EkSlidableGridNew
v-slot="slotProps"
:nodes="getSlidableGridNodes(channels, contentPicks)"
:hasWhiteBackground="true"
:itemsPerSlide="{ lg: 3, md: 2, sm: 1 }"
>
<template
v-for="node in slotProps.slideNodes"
<div
v-for="(node, index) in slotProps.nodes"
:key="node.id"
class="slide"
:index="index"
>
<EkChannelCard
v-if="node !== undefined && node.kind === 'channel'"
Expand All @@ -32,8 +35,8 @@
:key="node.id"
:node="node"
/>
</template>
</EkSlidableGrid>
</div>
</EkSlidableGridNew>
</b-container>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@
<EkCardGridPlaceholder />
</template>
<template v-else>
<b-container class="mb-2 mt-4 no-container-padding">
<b-container fluid class="mb-2 mt-4 no-container-padding">
<template v-if="hasNodesForSection('featured-channel')">
<b-container>
<h5 class="mt-2 text-muted">
{{ $tr('channelLabel') }}
</h5>
</b-container>
<!-- These classes must match EkCardGrid -->
<b-container class="mb-5 mt-3 no-container-padding section-container">
<EkSlidableGrid
<b-container fluid class="mb-5 mt-3 no-container-padding section-container">
<EkSlidableGridNew
v-slot="slotProps"
:nodes="sectionNodes['featured-channel']"
>
<EkChannelCard
v-for="node in slotProps.slideNodes"
<div
v-for="(node, index) in slotProps.nodes"
:key="node.id"
:channel="node"
@click.native="goToChannel(node.id)"
/>
</EkSlidableGrid>
class="slide"
:index="index"
>
<EkChannelCard
:channel="node"
@click.native="goToChannel(node.id)"
/>
</div>
</EkSlidableGridNew>
</b-container>
</template>
<template v-if="hasNodesForSection('highlight')">
Expand All @@ -37,6 +42,7 @@
</b-container>
<EkCardGrid
:nodes="sectionNodes['highlight']"
variant="slidable-new"
/>
</template>
<template v-if="hasNodesForSection('skill')">
Expand All @@ -47,6 +53,7 @@
</b-container>
<EkCardGrid
:nodes="sectionNodes['skill']"
variant="slidable-new"
/>
</template>
<template v-if="hasNodesForSection('career')">
Expand All @@ -57,6 +64,7 @@
</b-container>
<EkCardGrid
:nodes="sectionNodes['career']"
variant="slidable-new"
/>
</template>
<template v-if="hasNodesForSection('curious')">
Expand All @@ -67,6 +75,7 @@
</b-container>
<EkCardGrid
:nodes="sectionNodes['curious']"
variant="slidable-new"
/>
</template>

Expand Down
3 changes: 2 additions & 1 deletion packages/ek-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"core-js": "^3.6.5",
"lodash": "^4.17.21",
"vue": "^2.6.11",
"vue-material-design-icons": "^4.12.1"
"vue-material-design-icons": "^4.12.1",
"vue-ssr-carousel": "^2.3.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.11",
Expand Down
16 changes: 13 additions & 3 deletions packages/ek-components/src/components/EkCardGrid.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<b-container
class="mb-5 mt-3 section-container"
:class="{ 'no-container-padding': variant === 'slidable' }"
:fluid="displayVariant === 'EkSlidableCardGridNew'"
:class="{ 'no-container-padding': (
displayVariant === 'EkSlidableCardGrid' ||
displayVariant === 'EkSlidableCardGridNew'
) }"
>
<slot></slot>

Expand Down Expand Up @@ -41,15 +45,15 @@ export default {
cardColumns: {
type: Object,
default() {
return { cols: 6, md: 4, lg: 3 };
return { cols: 6, sm: 12, md: 6, lg: 3 };
},
},
variant: {
type: String,
default: 'slidable',
validator(value) {
// The value must match one of these strings
return ['collapsible', 'slidable'].includes(value);
return ['collapsible', 'slidable', 'slidable-new'].includes(value);
},
},
itemsPerPage: {
Expand All @@ -64,9 +68,15 @@ export default {
},
computed: {
displayVariant() {
if (this.variant === 'slidable-new' && this.itemsPerSlide.lg >= this.nodes.length) {
// There is no need to display a more complex component if there is no pagination:
return 'EkGridPage';
}
switch (this.variant) {
case 'collapsible':
return 'EkCollapsibleCardGrid';
case 'slidable-new':
return 'EkSlidableCardGridNew';
case 'slidable':
default:
return 'EkSlidableCardGrid';
Expand Down
56 changes: 56 additions & 0 deletions packages/ek-components/src/components/EkSlidableCardGridNew.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<EkSlidableGridNew
v-slot="slotProps"
class="pb-4"
:nodes="nodes"
:hasMoreNodes="hasMoreNodes"
:itemsPerSlide="itemsPerSlide"
@loadMoreNodes="$emit('loadMoreNodes')"
>
<div
v-for="(node, index) in slotProps.nodes"
:key="node.id"
class="slide"
:index="index"
>
<EkCard
:node="node"
:mediaQuality="mediaQuality"
@nodeUpdated="onNodeUpdated"
/>
</div>
</EkSlidableGridNew>
</template>

<script>
import { ItemsPerSlide, MediaQuality } from '../constants';
import { validateItemsPerSlide } from '../utils';

export default {
name: 'EkSlidableCardGridNew',
props: {
nodes: {
type: Array,
required: true,
},
hasMoreNodes: {
type: Boolean,
default: false,
},
mediaQuality: {
type: String,
default: MediaQuality.REGULAR,
},
itemsPerSlide: {
type: Object,
default: () => ItemsPerSlide,
validator: validateItemsPerSlide,
},
},
methods: {
onNodeUpdated(nodeId) {
this.$emit('nodeUpdated', nodeId);
},
},
};
</script>
74 changes: 74 additions & 0 deletions packages/ek-components/src/components/EkSlidableGridNew.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<template>
<b-container fluid class="no-container-padding" style="overflow: hidden">
<b-container>
<SsrCarousel
:key="nodes.length"
v-model="slide"
:gutter="gridGutterWidth"
:slidesPerPage="itemsPerSlideComputed"
overflowVisible
paginateBySlide
@change="onChange"
>
<slot :nodes="nodes"></slot>
</SsrCarousel>
</b-container>
</b-container>
</template>

<script>
import SsrCarousel from 'vue-ssr-carousel';
import { ItemsPerSlide } from '../constants';
import { validateItemsPerSlide } from '../utils';
import { gridGutterWidth } from '../styles.scss';
import responsiveMixin from './mixins/responsiveMixin';

export default {
name: 'EkSlidableGridNew',
components: { SsrCarousel },
mixins: [responsiveMixin],
props: {
nodes: {
type: Array,
required: true,
},
hasMoreNodes: {
type: Boolean,
default: false,
},
itemsPerSlide: {
type: Object,
default: () => ItemsPerSlide,
validator: validateItemsPerSlide,
},
},
data() {
return {
slide: 0,
gridGutterWidth,
};
},
computed: {
itemsPerSlideComputed() {
if (this.xs) {
return this.itemsPerSlide.sm;
}
if (this.sm || this.md) {
return this.itemsPerSlide.md;
}
return this.itemsPerSlide.lg;
},
},
methods: {
onChange({ index }) {
const isLastSlide = index >= this.nodes.length - this.itemsPerSlideComputed;
if (this.hasMoreNodes && isLastSlide) {
this.$emit('loadMoreNodes');
}
},
},
}
</script>

<style lang="scss" scoped>
</style>
1 change: 1 addition & 0 deletions packages/ek-components/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

@import "~@fontsource/lato/index.css";
@import "~@fontsource/poppins/index.css";
@import "~vue-ssr-carousel/index.css";

// Override containers mixin:
@mixin make-container($gutter: $grid-gutter-width) {
Expand Down
4 changes: 4 additions & 0 deletions packages/ek-components/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import EkPrivacyPolicyText from './components/EkPrivacyPolicyText.vue';
import EkSearchBar from './components/EkSearchBar.vue';
import EkSlidableCardGrid from './components/EkSlidableCardGrid.vue';
import EkSlidableGrid from './components/EkSlidableGrid.vue';
import EkSlidableGridNew from './components/EkSlidableGridNew.vue';
import EkSlidableCardGridNew from './components/EkSlidableCardGridNew.vue';
import EkTopicCard from './components/EkTopicCard.vue';
import EkPackCard from './components/EkPackCard.vue';
import EkClamp from './components/EkClamp.vue';
Expand Down Expand Up @@ -62,6 +64,8 @@ const components = {
EkSearchBar,
EkSlidableCardGrid,
EkSlidableGrid,
EkSlidableGridNew,
EkSlidableCardGridNew,
Comment on lines +67 to +68
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we choose a better name for these components? EkSlidableGrid vs EkSlidableGridNew has zero meaning for someone who was not around when they were created. I tried to think of some suggestions and the best I could come up with was EkInertialSlidableGrid, but I'm not sure how good that is.

EkTopicCard,
EkClamp,
};
Expand Down
1 change: 1 addition & 0 deletions packages/ek-components/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ $background-alpha: -8%;
$card-image-ar: calc(9 / 16);

:export {
gridGutterWidth: $grid-gutter-width;
headerLogoWidth: $header-logo-width;
cardImageAspectRatio: $card-image-ar;
xs: map-get($grid-breakpoints, "xs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<EkCardGrid
v-if="showTopics"
:nodes="mainSections"
variant="slidable-new"
:mediaQuality="mediaQuality"
:cardColumns="cardColumns"
>
Expand Down
1 change: 1 addition & 0 deletions packages/template-ui/src/views/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<EkCardGrid
v-if="nextNodesInTopic.length && showNextContent"
:nodes="nextNodesInTopic"
variant="slidable-new"
:cardColumns="cardColumns"
class="next-grid"
@nodeUpdated="onNextNodesUpdated"
Expand Down
3 changes: 2 additions & 1 deletion packages/template-ui/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<template v-if="contentNodes.nodes.length">
<EkCardGrid
:nodes="contentNodes.nodes"
:variant="hasFlatGrid ? 'collapsible' : 'slidable'"
:variant="hasFlatGrid ? 'collapsible' : 'slidable-new'"
:mediaQuality="mediaQuality"
:cardColumns="cardColumns"
:hasMoreNodes="contentNodes.hasMoreNodes"
Expand All @@ -41,6 +41,7 @@
<EkCardGrid
:id="section.id"
:nodes="sectionNodes[section.id].nodes"
variant="slidable-new"
:hasMoreNodes="sectionNodes[section.id].hasMoreNodes"
:mediaQuality="mediaQuality"
@loadMoreNodes="onLoadMoreSectionNodes(section.id)"
Expand Down
1 change: 1 addition & 0 deletions packages/template-ui/src/views/ListSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
v-for="subsection in sectionNodes.nodes"
:id="subsection.id"
:key="subsection.id"
variant="slidable-new"
:nodes="getSubsectionNodes(subsection.id).nodes"
:mediaQuality="mediaQuality"
:cardColumns="cardColumns"
Expand Down
1 change: 1 addition & 0 deletions packages/template-ui/src/views/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<EkCardGrid
v-if="!resultNodes.length"
:nodes="mainSections"
variant="slidable-new"
:mediaQuality="mediaQuality"
:cardColumns="cardColumns"
>
Expand Down
Loading