Components
41
Accordion Block Benifits Grid Block 404 Card Stack Careers Grid Case Study Carousel Case Study Hero Content Columns Content Image Content Image Accordion Content Video Cta Block Example Featured Blog Hero Featured Resource Hero Form Cta Form Hero Full Width Image Homepage Hero Hover List Image Hero Image Mask Image Testimonial Carousel Industry Insights Latest News List Columns Logo Scroller Map Block Post Feed Resource Grid Split Hero Split Text Statement Statistics Row Team Filter Team Grid Testimonial Carousel Testimonial Carousel Text Highlight Tools Grid Two Column List

Latest News

View example
Field
Field Type
Field Name
Instructions
Content
wysiwyg
content
Accordion items
repeater
accordion_items
-- Title
text
title
-- Content
wysiwyg
content
-- Cards
clone
cards
---- Display type
button_group
cards_display_type
---- Cards
relationship
cards_cards
---- Post type
button_group
cards_post_type
---- Category
taxonomy
cards_category
Right Content
wysiwyg
right_content
Background image
image
image
Note: Should only be used for abstract/gradient background images
Theme
button_group
theme
Note: Controls text colour when using a background image
Split Sections
true_false
split_sections
Enable this option to divide the component into two separate blocks
Secondary Block Background Colour
select
secondary_block_background_colour
Rounded corners
button_group
has_rounded_corners_rounded_corners
Border type
button_group
border_type_border_type
Blob gradients
button_group
background_gradients_blob_gradients
Note: Where to position red & blue gradient blobs

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

.block-latest-news {
	padding: rem-calc(10 0);

	&.theme-dark {
		.content-col {
			--text-color: var(--white);

			.content-container {
				--text-color: var(--white);
			}
		}

		.accordion-item .accordion-trigger:before,
		.accordion-item .accordion-trigger:after {
			background-color: var(--white);
		}

		.accordion-item {
			border-bottom: 1px solid rgba(255,255,255, 0.2);
		}
	}

	&__faux-background {
		position: absolute;
		top: 0;
		bottom: -50%;
		left: 0;
		right: 0;
		z-index: 1;

		@include bp($lg) {
			top: -50%;
		}
	}

	.content-col {
		position: relative;
		z-index: 5;

		&-inner {
			max-width: rem-calc(530);
			margin: 0 auto;
			padding-top: 4rem;
			padding-bottom: 2rem;

			@include bp($md) {
				padding-bottom: 4rem;
			}

			@include bp($lg) {
				@include padding-top(rem-calc(200));
				@include padding-bottom(rem-calc(200));
			}
		}
	}

	> picture {
		display: flex;
		flex-direction: column;
	}

	&.rounded-corners {
		overflow: hidden;

		> picture {
			border-radius: rem-calc(24);
		}
	}

	.cards-col {
		position: relative;

		&:has(.block-latest-news__faux-background) {
			padding-top: 2rem;

			@include bp($md) {
				padding-top: 4rem;
				padding-bottom: 4rem;
			}

			@include bp($lg) {
				padding-left: 2rem;
			}
		}

		@include bp($md - 1px, true) {
			padding-right: 0;
			padding-left: 0;
		}

		@include bp($md) {
			padding-right: 0;
		}
	}

	&.has-tertiary-background-color {
		.swiper {
			@include bp($md - 1px, true) {
				overflow: visible;
			}

			.swiper-wrapper {
				.swiper-slide {
					.cards-container {
						.post-card {
							&:hover {
								--post-card-bg: var(--grey-primary);
							}
						}
					}
				}
			}
		}
	}

	.swiper-wrapper{
		height: auto !important;
	}

	.cards-container{
		> a{
			min-height: 55vh;
		}
	}

	.swiper {
		.swiper-wrapper {
			.swiper-slide {
				box-sizing: border-box;

				.cards-container {
					display: flex;
					flex-direction: row;
					flex-wrap: nowrap;
					justify-content: flex-start;
					gap: rem-calc(10);
					overflow-x: auto;

					@include bp($md - 1px, true) {
						padding: rem-calc(0 12);
					}

					@include bp($md) {
						flex-wrap: wrap;
					}

					.post-card {
						width: 75vw;

						height: auto;
						flex-shrink: 0;

						@include bp($md) {
							width: calc(50% - #{rem-calc(10)});
						}

						@include bp($lg){
							max-width: rem-calc(362);
						}

						&--standard {
							.post-card__tags {
								top: 1.25rem;
								left: 1.25rem;
							}
						}
					}
				}
			}
		}
	}

    &.theme-light .cards-col .content-container {
        --text-color: var(--primary);
    }
    
    .cards-col .content-container {
        padding: 4rem 0 2rem;
        position: relative;
        z-index: 5;
    }
    
    &.theme-dark .cards-col .content-container {
        --text-color: var(--white);
    }
}
class LatestNews {
	/**
	 * Create and initialise objects of this class
	 * @param {object} block
	 */
	constructor(block) {
		this.block = block;
		setTimeout(() => {
			this.init();
		}, 100);
	}

	init() {
		this.swiper = new Swiper(this.block.querySelector('.swiper'), {
			slidesPerView: 1,
			allowTouchMove: false,
			autoHeight: true,
		});

		this.accordionItems = this.block.querySelectorAll('.accordion-trigger-input');
		this.accordionItems.forEach(item => {
			item.addEventListener('change', (e) => {
				const index = e.target.dataset.index;
				this.swiper.slideTo(index);

				// uncheck all other accordion items
				this.accordionItems.forEach(item => {
					if (item !== e.target) {
						item.checked = false;
					}
				});
			});
		});
	}
}

document.addEventListener('DOMContentLoaded', () => {
	document.querySelectorAll('.block-latest-news').forEach( block => new LatestNews(block) );
});
{
    "$schema": "https://schemas.wp.org/trunk/block.json",
    "apiVersion": 2,
    "name": "strategiq/latest-news",
    "title": "Latest news",
    "description": "Latest news block",
    "category": "strategiq",
    "icon": "strategiq",
    "acf": {
        "mode": "preview",
        "renderTemplate": "block-latest-news.php"
    },
    "supports": {
        "anchor": true,
        "align": false,
        "color": {
            "background": true,
            "text": false,
            "gradients": false
        },
        "spacing": {
            "padding": [
                "top",
                "bottom"
            ],
            "margin": [
                "top",
                "bottom"
            ]
        }
    },
    "example": {
        "attributes": {
            "mode": "preview",
            "data": {
                "heading_type": "h2",
                "heading_text": "Example - Example",
                "content": "This is some example content to represent what the content will look like"
            }
        }
    },
    "style": "file:../../assets/css/latest-news/block-latest-news.css"
}
There are is no readme file with this component.