Global Elements
2
Footer Header Services Strip Services Tabs
Components
36
Card Carousel Cards Grid Content Overlap Content Strip Cta Bar Featured Article Featured Blocks Featured Expert Featured Pods Featured Tabs Form Block Full Screen Carousel Full Width Content Heading Strip Hero Hero Featured Links List Location Tabs Logo Carousel Map Block People Grid Quote Block Reviews Carousel Reviews Tabs Service Tiles Services Strip Services Tabs Staggered Content Sticky Accordion Sticky List Sub Navigation Team Carousel Team Filters Team Strip Tile Carousel Tile Grid

Featured Blocks

Field
Field Type
Field Name
Instructions
Block Data
tab
Heading Type
select
heading_type
Heading Text
text
heading_text
Content
wysiwyg
content
Buttons
repeater
buttons_list
-- Button
link
button
Use Sticky Posts
true_false
use_sticky_posts
Sections
taxonomy
sections
Featured Posts
relationship
featured_posts
Block Meta
tab
ID
text
block_id
Block Classes
text
block_classes
Block Theme
select
block_theme
Background Colors
select
background_colors
Padding Top
select
padding_top
Padding Bottom
select
padding_bottom
Margin Top
select
margin_top
Margin Bottom
select
margin_bottom

				
@import "../../resources/scss/util/colours";
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";

.block-featured-blocks {
	padding-top: rem-calc(80);
	padding-bottom: rem-calc(80);
	overflow: hidden;

	.heading {
		@include fluid-type(28, 34);
	}

	&__buttons {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;

		@include bp($lg) {
			justify-content: flex-end;
			width: auto;
		}
	}

	&.bg-navy {
		.heading {
			color: $white;
		}

		.e-link {
			color: $white;
		}

		.block-card-carousel__buttons {
			.e-link {
				color: $white;
			}
		}
	}

	.single-service & {
		background-color: $veryLightBlue;
		border-bottom: 1px solid $lightBlue;
	}

	&__intro {
		margin-bottom: rem-calc(28);
	}

	&__row-01 {
		margin-bottom: rem-calc(30);
	}

	.swiper {
		overflow: visible;
	}

	.swiper-slide {
		height: auto;
	}
}
class FeaturedBlocks {
	/**
	 * Create and initialise objects of this class
	 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor
	 * @param {object} block
	 */
	constructor() {
		this.blocks = document.querySelectorAll('.block-featured-blocks');
		this.init();
	}

	/**
	 * Example function to run class logic
	 * Can access `this.block`
	 */
	init() {
		this.blocks.forEach((block) => {

			const blockCarousel = block.querySelector(".swiper");
			const navNext = block.querySelector(".e-carousel__next");
			const navPrev = block.querySelector(".e-carousel__prev");

			const swiper = new Swiper(blockCarousel, {
				loop: false,
				slidesPerView: 1.5,
				spaceBetween: 15,
				navigation: {
					nextEl: navNext,
					prevEl: navPrev,
				},
			});

			const featuredBlocks = block.querySelectorAll(".e-card");

			if (featuredBlocks !== null)  {
				gsap.set(".block-featured-blocks .e-card", {y: 50, opacity: 0});

				ScrollTrigger.batch(".block-featured-blocks .e-card", {
					start: "top 100%",
					onEnter: batch => gsap.to(batch, {opacity: 1, y: 0, stagger:  0.15, overwrite: true}),
					onLeave: batch => gsap.set(batch, {opacity: 0, y: -50, overwrite: true}),
					onEnterBack: batch => gsap.to(batch, {opacity: 1, y: 0, stagger: 0.15, overwrite: true}),
					onLeaveBack: batch => gsap.set(batch, {opacity: 0, y: 50, overwrite: true}),
				});

				ScrollTrigger.addEventListener("refreshInit", () => gsap.set(".block-featured-blocks .e-card", {y: 0}));
			}


		});
	}
}

new FeaturedBlocks();

Animation / States

  • As the user scrolls to this component each items will be lazyloaded and fade in one by one
  • For blocks that have images; on hover any background images will slowly expand

External Libraries

  • ScrollTrigger (GSAP)

Notes (Design / Dev / SEO)

  • By default this component will pull through the latest 5 items published within the Knowledge Hub, however on the component the user can specify which articles to feature.