Skip to content

Commit

Permalink
Merge pull request #319 from conversionxl/raphael/fix/dashboard/featu…
Browse files Browse the repository at this point in the history
…re-card
  • Loading branch information
pawelkmpt authored Sep 11, 2023
2 parents cfbe20b + ee10c48 commit 102de7d
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
9 changes: 9 additions & 0 deletions packages/cxl-lumo-styles/scss/themes/vaadin-tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ $vaadin-tab-horizontal-padding: 0.75rem;
scrollbar-width: none;
-ms-overflow-style: none;

scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
scroll-behavior: smooth;

::slotted(*) {
scroll-snap-align: start;
scroll-snap-stop: always;
}

&::-webkit-scrollbar {
display: none;
}
Expand Down
12 changes: 12 additions & 0 deletions packages/cxl-ui/src/components/cxl-tabs-slider.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import '@conversionxl/cxl-lumo-styles';
import { Tabs } from '@vaadin/tabs';
import { customElement } from 'lit/decorators.js';
Expand All @@ -9,6 +10,17 @@ export class CXLTabsSliderElement extends Tabs {
super._updateOverflow();
}

_onResize() {
super._onResize();
// Only for `featured-course-slider`: induce scrolling to snap to next
// one in case resizing lands between two cards
if (this.getAttribute('theme').split(' ').includes('cxl-featured-course-slider')) {
requestAnimationFrame(() => {
this._scroll(1);
});
}
}

/**
* We want [theme~="centered"] so element would does not hug viewport edge, and gap the other edge.
*
Expand Down
26 changes: 11 additions & 15 deletions packages/storybook/cxl-ui/cxl-dashboard-layout.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '@conversionxl/cxl-ui/src/components/cxl-marketing-nav.js';
import { CXLMarketingNav } from './cxl-marketing-nav.stories';
import { CXLDashboardHeader } from './cxl-dashboard-header/template.stories';
import { CXLFeatureadCourseCard } from './cxl-featured-course-card/default.stories';
import { DashboardSlider } from './cxl-featured-course-card/dashboard-slider.stories';
import { CXLStats } from './cxl-stats/default.stories';
import { CXLVaadinAccordionThemeCategory } from './cxl-vaadin-accordion.stories';
import { CXLFooterNav } from './footer-nav.stories';
Expand Down Expand Up @@ -49,20 +50,15 @@ export const CXLDashboard = () => {
};

return html`
<cxl-app-layout
id="container"
layout="1c-w"
theme="cxl-dashboard"
>
${CXLMarketingNav()}
<div style="${boxShadow ? `box-shadow: ${boxShadow}` : ''}">
${CXLDashboardHeader(CXLDashboardHeader.args)}
${CXLFeatureadCourseCard(CXLFeatureadCourseCard.args)}
${CXLStats(statsCount)}
${CXLVaadinAccordionThemeCategory()}
</div>
${CXLFooterNav()}
</cxl-app-layout>
`};
<cxl-app-layout id="container" layout="1c-w" theme="cxl-dashboard">
${CXLMarketingNav()}
<div style="${boxShadow ? `box-shadow: ${boxShadow}` : ''}">
${CXLDashboardHeader(CXLDashboardHeader.args)} ${DashboardSlider()} ${CXLStats(statsCount)}
${CXLVaadinAccordionThemeCategory()}
</div>
${CXLFooterNav()}
</cxl-app-layout>
`;
};

CXLDashboard.storyName = 'cxl-dashboard';
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,32 @@ export default {
title: 'CXL UI/cxl-featured-course-card',
};

const args2 = {
...CXLFeatureadCourseCard.args,
id: 'cxl-featured-course-2',
name: 'Advanced Facebook Ads',
time: '2h 04min',
instructor: 'Curt Maly',
avatar:
'https://cxl.com/institute/wp-content/uploads/2020/01/curt-maly-bw-transparent-bg-v2-min.png',
};

const args3 = {
...CXLFeatureadCourseCard.args,
id: 'cxl-featured-course-3',
name: 'Google Ads Experiments',
time: '1h 30min',
instructor: 'Susan Wenograd',
avatar: 'https://cxl.com/institute/wp-content/uploads/2022/05/susan-wenograd-headshot-bw-bg.png',
};

const Template = () => html`
<cxl-tabs-slider theme="minimal cxl-featured-course-slider">
<vaadin-tab theme="cxl-featured-course-slider"
>${CXLFeatureadCourseCard(CXLFeatureadCourseCard.args)}</vaadin-tab
>
<vaadin-tab theme="cxl-featured-course-slider"
>${CXLFeatureadCourseCard(CXLFeatureadCourseCard.args)}</vaadin-tab
>
<vaadin-tab theme="cxl-featured-course-slider"
>${CXLFeatureadCourseCard(CXLFeatureadCourseCard.args)}</vaadin-tab
>
<vaadin-tab theme="cxl-featured-course-slider">${CXLFeatureadCourseCard(args2)}</vaadin-tab>
<vaadin-tab theme="cxl-featured-course-slider">${CXLFeatureadCourseCard(args3)}</vaadin-tab>
</cxl-tabs-slider>
`;

Expand Down

0 comments on commit 102de7d

Please sign in to comment.