Hero Carousel
<div class="hero-carousel js-hero-carousel">
<div class="hero-carousel__slides js-slides">
<!-- Slide 1 -->
<div class="hero-carousel__slide">
<div class="hero-carousel__item" style="background-image: url(https://via.placeholder.com/1152x648/013f8c/1475ff)">
<a href="#hero-url" class="hero-carousel__link">Lorem ipsum dolor sit amet consectetur</a>
<div class="hero-carousel__content-wrapper">
<div class="hero-carousel__content">
<div class="hero-carousel__title-wrap">
<h2 class="hero-carousel__title">Lorem ipsum dolor sit amet consectetur</h2>
</div>
<div class="hero-carousel__actions">
<a href="#button-1" class="btn btn-primary">Button</a>
<a href="#button-2" class="btn btn-default">Button</a>
<a href="#button-3" class="btn btn-link">Button</a>
</div>
</div>
</div>
</div>
</div>
<!-- /Slide 1 -->
<!-- Slide 2 -->
<div class="hero-carousel__slide">
<div class="hero-carousel__item" style="background-image: url(https://via.placeholder.com/1152x648/960064/f870ff)">
<div class="hero-carousel__content-wrapper">
<div class="hero-carousel__content">
<div class="hero-carousel__title-wrap">
<h2 class="hero-carousel__title">This is a slide without a link or buttons</h2>
</div>
</div>
</div>
</div>
</div>
<!-- /Slide 2 -->
<!-- Slide 3 -->
<div class="hero-carousel__slide">
<div class="hero-carousel__item" style="background-image: url(https://via.placeholder.com/1152x648/006550/00d256)">
<a href="#hero-url-2" class="hero-carousel__link">Ratione sunt repellat nesciunt porro reiciendis</a>
<div class="hero-carousel__content-wrapper">
<div class="hero-carousel__content">
<div class="hero-carousel__title-wrap">
<h2 class="hero-carousel__title">Ratione sunt repellat nesciunt porro reiciendis</h2>
</div>
<div class="hero-carousel__actions">
<a href="#button-1" class="btn btn-primary">Button</a>
<a href="#button-2" class="btn btn-default">Button</a>
<a href="#button-3" class="btn btn-link">Button</a>
</div>
</div>
</div>
</div>
</div>
<!-- /Slide 3 -->
</div>
<div class="hero-carousel__controls">
<button type="button" class="carousel-arrow carousel-prev js-carousel-prev">Previous</button>
<div class="carousel-dots-wrapper js-carousel-dots"></div>
<button type="button" class="carousel-arrow carousel-next js-carousel-next">Next</button>
</div>
</div>
.hero-carousel {
color: $color-base-white;
position: relative;
margin-bottom: 2.4rem;
.carousel-dots-wrapper {
margin: 0 0.8rem;
}
.carousel-dots {
padding: 0;
margin: 0;
list-style: none;
li {
position: relative;
display: inline-block;
margin: 0;
padding: 0;
cursor: pointer;
button {
font-size: 0;
line-height: 0;
display: block;
padding: 0.8rem;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
&:hover,
&:focus {
outline: none;
}
&::before {
font-family: "FontAwesome";
font-size: 1.6rem;
line-height: 1;
content: "\f10c";
text-align: center;
opacity: 0.5;
color: $color-base-white;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
&:hover::before,
&:focus::before {
opacity: 1;
}
}
}
li.slick-active button::before {
opacity: 1;
color: $color-base-white;
content: "\f111";
}
}
.carousel-arrow {
z-index: 1;
font-size: 0;
line-height: 0;
display: block;
padding: 0.8rem;
cursor: pointer;
color: transparent;
border: none;
outline: none;
background: transparent;
&::before {
font-family: "FontAwesome";
font-size: 1.6rem;
line-height: 1;
opacity: 0.75;
color: $color-base-white;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
&:hover,
&:focus {
color: transparent;
outline: none;
background: transparent;
&::before {
opacity: 1;
}
}
}
.carousel-prev::before {
content: "\f177";
}
.carousel-next::before {
content: "\f178";
}
}
.hero-carousel__controls {
position: absolute;
bottom: 0;
width: 100%;
height: 3.2rem;
display: inline-flex;
justify-content: center;
@media (min-width: $breakpoint-tablet) {
bottom: 2.4rem;
}
}
.hero-carousel__item {
height: 0;
padding-top: 56.25%; // 16:9
overflow: hidden;
display: flex;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
position: relative;
a {
position: relative;
z-index: 10;
}
}
a.hero-carousel__link {
top: 0;
right: 0;
bottom: 0;
left: 0;
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
position: absolute;
z-index: 1;
}
.hero-carousel__content-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.hero-carousel__content {
@media (min-width: $breakpoint-desktop) {
padding-left: 2.4rem;
width: calc(50% - 6.2rem); // Don't touch the play icon
}
}
.hero-carousel__category {
@include typeCaption(true);
margin-bottom: 0.4rem;
}
.hero-carousel__title-wrap {
display: flex;
justify-content: center;
margin-bottom: 1.2rem;
}
.hero-carousel__title {
@include typeHeadline(true);
text-align: center;
@media (min-width: $breakpoint-tablet) {
@include typeDisplay(true);
}
@media (min-width: $breakpoint-desktop) {
@include typeDisplayMedium(true);
text-align: left;
}
}
.hero-carousel__actions {
text-align: center;
@media (min-width: $breakpoint-desktop) {
text-align: left;
}
}
$(document).ready(function () {
$(".js-hero-carousel").each(function () {
const $component = $(this);
$component.find(".js-slides").slick({
autoplay: false,
dots: true,
dotsClass: "carousel-dots",
appendDots: $component.find(".js-carousel-dots"),
prevArrow: $component.find(".js-carousel-prev"),
nextArrow: $component.find(".js-carousel-next"),
});
});
});