<article class="animated-carousel-card" data-module="cardCarousel" data-show-more-label="Show More" data-show-less-label="Show Less">
<div class="animated-carousel-card__content">
<p class="animated-carousel-card__subheader">1976 - 1979</p>
<h3 class="animated-carousel-card__header">Milestone Title</h3>
<div class="animated-carousel-card__description rtf">
<p>In 1976 the Model 115 cell deglycerolization system, the Model 30-S apheresis system, and the Model 102 cell washer systems are launched.</p>
<p>1978 Saw the opening of the Braintree, MA facility at 400 Wood Road.</p>
<p>In 1979 Haemonetics successfully completed an over the counter (OTC) initial public offering, production of the one millionth Latham bowl is reached, and the PEX® automated plasma exchange system is introduced.</p>
</div>
<div class="animated-carousel-card__action">
<button type="button" class="btn btn--primary btn--outline btn--small">
Show More
</button>
</div>
</div>
</article>
<article class="animated-carousel-card" data-module="cardCarousel" data-show-more-label="{{showMoreLabel}}"
data-show-less-label="{{showLessLabel}}">
{{#if image}}
<div class="animated-carousel-card__image">
{{#json image}}
{{>picture}}
{{/json}}
</div>
{{/if}}
<div class="animated-carousel-card__content">
{{#if subheader}}<p class="animated-carousel-card__subheader">{{subheader}}</p>{{/if}}
<h3 class="animated-carousel-card__header">{{header}}</h3>
<div class="animated-carousel-card__description rtf">
{{{description}}}
</div>
{{#ifCond showMoreLabel "&&" showLessLabel}}
<div class="animated-carousel-card__action">
{{>@button label=showMoreLabel type="button" className="primary" style="outline" size="small"}}
</div>
{{/ifCond}}
</div>
</article>
{
"subheader": "1976 - 1979",
"header": "Milestone Title",
"description": "<p>In 1976 the Model 115 cell deglycerolization system, the Model 30-S apheresis system, and the Model 102 cell washer systems are launched.</p><p>1978 Saw the opening of the Braintree, MA facility at 400 Wood Road.</p><p>In 1979 Haemonetics successfully completed an over the counter (OTC) initial public offering, production of the one millionth Latham bowl is reached, and the PEX® automated plasma exchange system is introduced.</p>",
"showMoreLabel": "Show More",
"showLessLabel": "Show Less"
}
import { Component } from '@verndale/core';
import { debounce } from '../../helpers';
import { gsap, Expo } from 'gsap';
class Module extends Component {
setupDefaults() {
this.dom = {
btnExpandCollapse: this.el.querySelector(
'.animated-carousel-card__action .btn'
),
description: this.el.querySelector('.animated-carousel-card__description')
};
this.breakpoint = window.matchMedia('(max-width: 1279px)');
this.showMoreLabel = this.el.dataset.showMoreLabel;
this.showLessLabel = this.el.dataset.showLessLabel;
this.checkCollapseText();
}
addListeners() {
window.addEventListener(
'resize',
debounce(this.checkCollapseText.bind(this), 500)
);
this.dom.btnExpandCollapse.addEventListener(
'click',
this.handleShowMoreLess.bind(this)
);
}
checkCollapseText() {
if (
this.breakpoint.matches &&
this.dom.description.offsetHeight < this.dom.description.scrollHeight
) {
this.dom.btnExpandCollapse.style.display = 'block';
} else {
this.dom.description.style.height = null;
this.dom.btnExpandCollapse.style.display = 'none';
}
}
handleShowMoreLess(e) {
e.preventDefault();
if (
this.dom.description.classList.contains(
'animated-carousel-card__description--expanded'
)
) {
this.collapse();
} else {
this.expand();
}
}
expand() {
const { description, btnExpandCollapse } = this.dom;
this.textHeight = description.offsetHeight;
description.classList.add('animated-carousel-card__description--expanded');
gsap.set(description, { height: 'auto' });
gsap.from(description, {
height: this.textHeight,
ease: Expo['easeOut'],
duration: 0.4,
onComplete: () => {
description.style.height = null;
btnExpandCollapse.textContent = this.showLessLabel;
}
});
}
collapse() {
const { description, btnExpandCollapse } = this.dom;
gsap.set(description, { height: description.offsetHeight });
gsap.to(description, {
height: this.textHeight,
ease: Expo['easeOut'],
duration: 0.4,
onComplete: () => {
description.classList.remove(
'animated-carousel-card__description--expanded'
);
description.style.height = null;
btnExpandCollapse.textContent = this.showMoreLabel;
}
});
}
}
export default Module;
@import '../../theme', 'variables';
.animated-carousel-card {
background-color: $background-carousel-card-color;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2);
display: flex;
flex-direction: column;
justify-content: center;
overflow: hidden;
padding: 20px;
@include mq(tablet-landscape) {
align-items: center;
flex-direction: row-reverse;
justify-content: space-between;
padding: 20px 20px 20px 48px;
}
@include mq(desktop) {
padding: 48px 48px 48px 90px;
}
}
.animated-carousel-card__content {
@include mq(tablet-landscape) {
flex-grow: 1;
}
}
.animated-carousel-card__subheader {
align-items: center;
display: flex;
font-weight: 600;
margin: 0 0 19px;
&:before {
background-color: $primary-color;
content: "";
display: block;
height: 3px;
margin-right: 10px;
width: 25px;
}
}
.animated-carousel-card__header {
margin: 0 0 16px;
@include mq(tablet-landscape) {
margin-bottom: 14px;
}
}
.animated-carousel-card__description {
overflow: hidden;
&:not(.animated-carousel-card__description--expanded) {
@include mq($until: tablet-landscape) {
-webkit-box-orient: vertical;
-webkit-line-clamp: 5;
display: -webkit-box;
text-overflow: ellipsis;
}
}
}
.animated-carousel-card__image {
flex-shrink: 0;
margin-bottom: 20px;
width: 100%;
@include mq(tablet-landscape) {
margin-bottom: 0;
margin-left: 60px;
width: 50%;
}
@include mq(desktop) {
margin-left: 129px;
}
picture {
display: block;
height: 0;
padding-bottom: 80%;
position: relative;
}
img {
height: 100%;
left: 0;
object-fit: cover;
position: absolute;
top: 0;
width: 100%;
}
}
.animated-carousel-card__action {
margin-top: 20px;
@include mq(tablet-landscape) {
display: none;
}
.btn {
width: 100%;
}
}
$primary-color: map-get($theme-colors, "primary") !default;
$background-carousel-card-color: #fff !default;
Display an animated carousel Card within the animated card carousel. Each animated carousel card consist of Subheader, Header, Description and Image.
Add the front-end-component library to your project
yarn add @verndale/front-end-components
Import the style to your main style file in your project
@import '../../node_modules/@verndale/front-end-components/lib/cards/animated-carousel-card/styles';
Copy and paste to your project any of the markup in the link variations - you can find the markup in the HTML tab.
The component will already have a default style/theme set, so it will work out of the box. The testimonials cards has a set of variables that may be overriden, or you may choose to just override the actual styles in your project. It is recommended to use the overrides if you can as it will be less code in your project.
Below is the list of variables you can override. You may also find these in the Assets tab under _variables.scss
$primary-color
$background-carousel-card-color
You always need to set your overrides before the import of you component - for example:
$background-carousel-card-color: #fff;
$primary-color: #06847b;
@import '../../node_modules/@verndale/front-end-components/lib/cards/animated-carousel-card/styles';