Components
54
Accordion Items Basic Hero Basic Map Benefits Card Grid Career Testimonials Case Study Carousel Case Study Content Two Column Contact Form Content Centred Content Image Content Three Columns Content Two Column Content Video Cookie Table Cta Blocks Example Faqs Featured Card Featured Latest Cards Footer Banner Glossary Items Hero Insights Hero Rounded Hero With Featured Insight Home Hero Icon Carousel Image Link Carousel Image Link Carousel 2×2 Image Link Grid Insight Content Job Listing Large Image Large Testimonial Leadership Grid Link Grid Locations Locations Archive Logo Scroller Page Heading People Carousel Related Services Resources Carousel Section Anchors Separator Service Hero Services List Services Tabs Tech Partners Testimonial Carousel Testimonial Single Use Case Component Values Scroller Video

Card Grid

Field
Field Type
Field Name
Instructions
Block Data
tab
Overline
text
overline
Heading Type
select
heading_type
Heading Text
textarea
heading_text
Button Type
select
button_type
Button Color
select
button_color
Button Link
link
button_link
Show filters?
true_false
show_filters
Only works when 'Number of posts to display' is set to default
Number of posts to display
button_group
number_of_posts_to_display
Show pagination?
true_false
show_pagination
Cards
relationship
cards
Choose cards to display. If none are chosen, all posts will show.
Block Meta
tab
ID
text
block_id
Block Classes
text
block_classes
Padding Top
select
padding_top
Padding Bottom
select
padding_bottom
Margin Top
select
margin_top
Margin Bottom
select
margin_bottom

				
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";
@import "../../resources/scss/vendor/bootstrap/vendor/rfs";

@import "../../resources/scss/partials/post-card";
@import "../../resources/scss/partials/pagination";

.block-card-grid {
	&:not([class*=pad-top]) {
		@include padding-top( rem-calc( 96 ) );
	}

	&:not([class*=pad-bottom]) {
		@include padding-bottom( rem-calc( 96 ) );
	}

	&__content-row {
		@include margin-bottom( rem-calc(44) );
	}

	&__button-col {
		display: flex;
		flex-direction: row;
		align-items: flex-end;
		justify-content: flex-end;
	}

	.heading {
		font-weight: 400;
		margin-bottom: 0;
	}

	&__filters-row {
		@include margin-bottom( rem-calc(48) );
	}

	&__filters-col {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		gap: rfs-fluid-value( rem-calc(48) );

		select {
			width: rem-calc(200);
			min-height: auto;
			border: none;
			flex-grow: 0;
			text-overflow: ellipsis;
			overflow:hidden;
			white-space:nowrap;
			padding: 0;
			margin-bottom: 0;
		}
	}

	&__card-row {
		gap: rfs-fluid-value( rem-calc(48) ) 0;
	}
}
class CardGrid {
	/**
	 * @param {object} block
	 */
	constructor( block ) {
		this.block = block;
		this.blockId = this.block.getAttribute( 'id' );

		this.filters = block.querySelectorAll( '.block-card-grid__filters-col select' );
		this.filters.forEach( filter => {
			filter.addEventListener( 'change', () => {
				this.updateURL();
			});
		});
	}

	updateURL() {
		this.block.classList.add( 'loading' );

		const urlWithParams = new URL( `${window.location.origin}${window.location.pathname}` );

		this.filters.forEach( filter => {
			if ( filter.options[filter.selectedIndex].value !== '' ) {
				urlWithParams.searchParams.append( filter.getAttribute( 'name' ), filter.options[filter.selectedIndex].value );
			}
		});

		let href = urlWithParams.href;
		if ( this.blockId ) {
			href = `${urlWithParams.href}#${this.blockId}`;
		}

		if ( window.location.href !== href ) {
			window.location = href;
		}
	}
}

document.querySelectorAll('.block-card-grid').forEach((block) => {
	new CardGrid( block );
});
Page Title
Page Type
Page URL
There are is no readme file with this component.