<div class="news-centre-block-container">
<div class="news-centre-block">
<div class="news-centre-block__header">
<h3>a title</h3>
<div class="page-link">
<a href="">
View all <svg data-name="Calque 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M14.54 7.63l-1.5 1.13.67 2.21H5.18v2h8.53l-.67 2.2 1.5 1.13 5.32-3.5v-1.67l-5.32-3.5z"/>
</svg>
</a>
</div>
</div>
<div class="news-centre-block__content article-slider">
<div class="news-centre-block--article-list slide">
<div class="article-teaser">
<div class="article-teaser__image">
<a href="#">
<img src="https://via.placeholder.com/500x500"/>
</a>
</div>
<div class="article-teaser__content">
<a href="#">
<p class="article-teaser__title">
Article headline with long title name over two or three lines
</p>
<span class="article-teaser__category">
post
</span>
</a>
</div>
</div>
</div>
<div class="news-centre-block--article-list slide">
<div class="article-teaser">
<div class="article-teaser__image">
<a href="#">
<img src="https://via.placeholder.com/500x500"/>
</a>
</div>
<div class="article-teaser__content">
<a href="#">
<p class="article-teaser__title">
Article headline with long title name over two or three lines
</p>
</a>
</div>
</div>
</div>
<div class="news-centre-block--article-list slide">
<div class="article-teaser">
<div class="article-teaser__image">
<a href="#">
<img src="https://via.placeholder.com/500x500"/>
</a>
</div>
<div class="article-teaser__content">
<a href="#">
<p class="article-teaser__title">
Article headline with long title name over two or three lines
</p>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
/* @news-centre-block */
.news-centre-block {
// @include poly-margin--large;
@include poly-padding;
@include container;
@media (min-width: $large-screen) {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 50px auto;
@include poly-grid-gap;
}
&__header {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 100%;
align-items: center;
grid-column: 1/4;
grid-row: 1/1;
h3 {
font-size: $medium-font;
}
div {
justify-self: right;
a {
font-weight: 900;
}
}
}
&__content {
.article-teaser__title {
font-size: 14px;
display: block;
}
.article-teaser__category {
text-transform: uppercase;
font-size: $x-small-font;
font-family: 'Biryani', sans-serif;
font-weight: 200;
color: $red-ribbon;
letter-spacing: 3px;
}
&::after {
content: 'flickity';
display: none;
@media (min-width: $large-screen) {
content: '';
}
}
&.flickity-enabled {
.slide {
@media (max-width: $large-screen) {
width: 70%;
margin-right: 10px;
padding-bottom: 35px;
&.is-previous {
z-index: -1;
}
&.is-next {
z-index: 1;
}
.article-teaser {
box-shadow: $box-shadow-big;
&__image {
height: 210px;
overflow: hidden;
img {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
}
.article-teaser {
&__image {
@media (max-width: $medium-screen) {
height: 160px;
}
@media (max-width: $small-screen) {
height: 110px;
}
}
&__content {
@include poly-padding-bottom;
}
}
}
}
@media (min-width: $large-screen) {
grid-column: 1/4;
grid-row: 2/2;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 80px 80px 80px;
@include poly-grid-gap;
> div {
&:first-child {
grid-column: 1/2;
}
&:nth-child(2) {
grid-column: 2/3;
}
&:first-child,
&:nth-child(2) {
grid-row: 1/ span 3;
padding-right: 10px;
.article-teaser__content {
padding-left: 0;
}
.article-teaser__image {
height: 170px;
overflow: hidden;
img {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
&:nth-child(3),
&:nth-child(4),
&:nth-child(5) {
grid-column: 3/3;
.article-teaser {
display: flex;
flex-flow: row nowrap;
height: 85%;
&__image {
width: 100px;
}
&__title {
max-width: 200px;
flex: 1;
}
&__category {
display: none;
}
}
a {
overflow: hidden;
img {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
}
&:nth-child(3) {
grid-row: 1/1;
}
&:nth-child(4) {
grid-row: 2/2;
}
&:nth-child(5) {
grid-row: 3/3;
}
}
}
}
}
import shave from 'shave'
import $ from 'jQuery'
import Flickity from 'flickity'
function toggleCarousel() {
if ($('.article-slider').length && $(window).outerWidth() < "1024" ) {
var sections = document.querySelectorAll('.article-slider')
for ( var i=0, len = sections.length; i < len; i++ ) {
var currentSection = sections[i];
new Flickity( currentSection, {
contain: true,
watchCSS: true,
pageDots: false,
prevNextButtons: false,
wrapAround: true
})
}
}
}
function shaveYourself () {
const largePara = 60
const smallPara = 40
if ( $(window).outerWidth() < "1024" ) {
shave('.article-teaser__title', largePara)
} else {
shave('.news-centre-block--article-list:nth-child(-n+2) .article-teaser__title', largePara)
shave('.news-centre-block--article-list:nth-child(n+3) .article-teaser__title', smallPara)
}
}
$(document).ready(function () {
shaveYourself()
toggleCarousel()
})
$(window).resize(function() {
shaveYourself()
toggleCarousel()
});
<?php
$newsCentre = array (
'key' => 'news_centre',
'label' => 'News Centre',
'name' => 'news-centre-block',
'type' => 'repeater',
'instructions' => __('This block has no controls.', 'ipsen-master'),
'sub_fields' => array (
array(
'key' => 'news_centre_title',
'label' => 'News section title',
'name' => 'title',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
array (
'key' => 'mini_carousel_section_label',
'label' => 'Section Label',
'name' => 'blocklabel',
'type' => 'text',
'instructions' => __('This label appears in in-page navigation and within the content of some blocks, overriding the title.', 'ipsen-master'),
),
array (
'key' => 'news_centre_category',
'name' => 'posts',
'type' => 'message',
'message' => __('This block has no controls.', 'ipsen-master'),
),
),
'row_min' => 0,
'row_limit' => '',
'layout' => 'row',
);
array_push($_SESSION["blocks"], $newsCentre);