-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLANET-7214 Build a Posts List block using Query Loop (#2137)
* PLANET-7214 Build a Posts List block using Query Loop - Added Posts List block using the QLB - Restyled block for both editor and frontend * Changed script Enqueue for blocks - We can just enqueue from the Loader file and remove from MastersBlock * Changed script Enqueue for blocks - We can just enqueue from the Loader file and remove from MastersBlock
- Loading branch information
1 parent
046d2ad
commit 07e7ac5
Showing
7 changed files
with
269 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const POSTS_LIST_BLOCK = 'planet4-blocks/posts-list-block'; | ||
|
||
export const registerPostsListBlock = () => { | ||
const {registerBlockVariation} = wp.blocks; | ||
const {__} = wp.i18n; | ||
|
||
return registerBlockVariation('core/query', { | ||
name: POSTS_LIST_BLOCK, | ||
title: 'Posts List', | ||
icon: 'list-view', | ||
description: __('Posts List is the place in Planet 4 that the latest articles, press releases and publications can be found.', 'planet4-blocks-backend'), | ||
category: 'planet4-blocks-beta', | ||
isActive: ({namespace, query}) => { | ||
return ( | ||
namespace === POSTS_LIST_BLOCK && | ||
query.postType === 'post' | ||
); | ||
}, | ||
attributes: { | ||
namespace: POSTS_LIST_BLOCK, | ||
className: 'posts-list-query', | ||
query: { | ||
perPage: 3, | ||
pages: 0, | ||
offset: 0, | ||
postType: 'post', | ||
order: 'desc', | ||
orderBy: 'date', | ||
author: '', | ||
search: '', | ||
exclude: [], | ||
sticky: '', | ||
inherit: false, | ||
}, | ||
}, | ||
scope: ['inserter'], | ||
allowedControls: ['taxQuery'], | ||
innerBlocks: [ | ||
['core/heading', {content: __('Related Posts', 'planet4-blocks-backend')}], | ||
['core/paragraph', { | ||
placeholder: __('Enter description', 'planet4-blocks-backend'), | ||
style: { | ||
spacing: { | ||
margin: { | ||
top: '24px', | ||
bottom: '36px', | ||
}, | ||
}, | ||
}, | ||
}], | ||
['core/post-template', {}, [ | ||
['core/columns', {}, [ | ||
['core/post-featured-image', {isLink: true}], | ||
['core/group', {}, [ | ||
['core/post-terms', { | ||
term: 'category', | ||
separator: ' | ', | ||
}], | ||
['core/post-title', {isLink: true}], | ||
['core/post-excerpt'], | ||
['core/group', {className: 'posts-list-meta'}, [ | ||
['core/post-author-name', {isLink: true}], | ||
['core/post-date'], | ||
]], | ||
]], | ||
]], | ||
]], | ||
], | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
import {registerPostsListBlock} from './PostsList'; | ||
import {registerActionsList} from './ActionsList'; | ||
|
||
// Beta blocks | ||
registerActionsList(); | ||
registerPostsListBlock(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
.posts-list-query { | ||
.wp-block-post-template.is-layout-flow li { | ||
width: 100% !important; | ||
} | ||
|
||
.wp-block-columns.is-layout-flex { | ||
gap: $sp-2x; | ||
} | ||
|
||
.wp-block-post-featured-image { | ||
flex-basis: 30%; | ||
|
||
img { | ||
width: 100% !important; | ||
object-fit: cover; | ||
|
||
@include medium-and-up { | ||
height: 180px; | ||
} | ||
|
||
@include large-and-up { | ||
height: 210px; | ||
} | ||
} | ||
} | ||
|
||
.wp-block-group.is-layout-flow { | ||
flex-basis: 70%; | ||
} | ||
|
||
.wp-block-post-title { | ||
font-weight: var(--font-weight-bold); | ||
color: var(--grey-900); | ||
font-family: var(--font-family-tertiary); | ||
font-size: var(--font-size-l--font-family-primary); | ||
margin-top: 5px; | ||
|
||
a { | ||
-webkit-line-clamp: 2; | ||
} | ||
} | ||
|
||
.wp-block-post-title a, | ||
.wp-block-post-excerpt__excerpt { | ||
display: -webkit-box; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
} | ||
|
||
.wp-block-post-excerpt { | ||
margin-top: -15px; | ||
|
||
&__excerpt { | ||
width: 100%; | ||
margin-bottom: $sp-1; | ||
font-size: var(--font-size-m--font-family-secondary); | ||
|
||
@include medium-and-up { | ||
-webkit-line-clamp: 2; | ||
width: 100%; | ||
} | ||
|
||
@include large-and-up { | ||
-webkit-line-clamp: 3; | ||
} | ||
} | ||
} | ||
|
||
.is-layout-flow > .is-layout-flow { | ||
display: flex; | ||
gap: $sp-x; | ||
font-size: calc(var(--font-size-xxs--font-family-primary) - 2px); | ||
color: var(--grey-600); | ||
font-family: var(--font-family-paragraph-secondary); | ||
} | ||
|
||
.wp-block-post-author-name { | ||
font-size: calc(var(--font-size-xxs--font-family-primary) - 2px); | ||
font-weight: var(--font-weight-semibold); | ||
display: flex; | ||
|
||
a { | ||
color: var(--grey-600); | ||
} | ||
|
||
&::after { | ||
content: "."; | ||
font-size: calc(var(--font-size-m--font-family-primary) + 5px); | ||
margin-top: -6px; | ||
margin-left: $sp-x; | ||
} | ||
} | ||
|
||
.wp-block-post-terms { | ||
margin-top: -5px; | ||
|
||
&__separator, | ||
a, | ||
a:visited { | ||
color: var(--gp-green-800); | ||
font-weight: var(--font-weight-semibold); | ||
font-family: var(--font-family-tertiary); | ||
font-size: var(--font-size-m--font-family-tertiary); | ||
} | ||
} | ||
} | ||
|
||
@media (max-width: 1200px) { | ||
.posts-list-query { | ||
.wp-block-post-excerpt, | ||
.wp-block-post-terms { | ||
margin-top: 0; | ||
} | ||
} | ||
} | ||
|
||
@media (max-width: 781px) { | ||
.posts-list-query { | ||
.wp-block-post-featured-image { | ||
flex-basis: 100%; | ||
|
||
img { | ||
height: 100%; | ||
} | ||
} | ||
|
||
.wp-block-group.is-layout-flow { | ||
flex-basis: 100%; | ||
} | ||
|
||
.wp-block-post-excerpt { | ||
&__excerpt { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@media (max-width: 767px) { | ||
.posts-list-query { | ||
.wp-block-heading { | ||
font-size: var(--font-size-2xl--font-family-primary); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ | |
|
||
// Blocks | ||
@import "blocks/ActionsList"; | ||
@import "blocks/PostsList"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters