Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quadrat: block styles for query block #4171

Merged
merged 7 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 145 additions & 41 deletions quadrat/assets/theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions quadrat/inc/block-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ function quadrat_register_block_patterns() {

if ( function_exists( 'register_block_pattern' ) ) {
$block_patterns = array(
'headline-button',
'media-text-button',
'latest-episodes',
'episode',
'cover-with-heading',
'episode',
'headline-button',
'headlines-and-buttons',
'query-diamond',
'latest-episodes',
'listen-to-the-podcast',
'media-text-button',
Comment on lines -21 to +28
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scruffian I hope you are proud of me

);

if ( class_exists( 'WP_Block_Type_Registry' ) && \WP_Block_Type_Registry::get_instance()->is_registered( 'jetpack/subscriptions' ) ) {
Expand Down
9 changes: 9 additions & 0 deletions quadrat/inc/block-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ function quadrat_register_block_styles() {
'style_handle' => 'quadrat-cover-diamond',
)
);

register_block_style(
'core/query',
array(
'name' => 'quadrat-diamond-posts',
'label' => __( 'Diamond Posts', 'quadrat' ),
'style_handle' => 'quadrat-diamond-posts',
)
);
}
}
endif;
Expand Down
41 changes: 41 additions & 0 deletions quadrat/inc/patterns/query-diamond.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Blog posts with hover effect.
*
* @package Quadrat
*/

return array(
'title' => __( 'List of blog posts', 'quadrat' ),
'categories' => array( 'quadrat' ),
'blockTypes' => array( 'core/query' ),
'content' => '<!-- wp:query {"query":{"perPage":4,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"displayLayout":{"type":"list","columns":3},"align":"wide","className":"is-style-quadrat-diamond-posts"} -->
<div class="wp-block-query alignwide is-style-quadrat-diamond-posts"><!-- wp:post-template -->
<!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column {"verticalAlignment":"center"} -->
<div class="wp-block-column is-vertically-aligned-center"><!-- wp:group {"className":"post-meta"} -->
<div class="wp-block-group post-meta"><!-- wp:post-date {"fontSize":"tiny"} /-->

<!-- wp:post-terms {"term":"category","fontSize":"tiny"} /--></div>
<!-- /wp:group -->

<!-- wp:post-title {"textAlign":"left","isLink":true,"fontSize":"extra-large"} /-->

<!-- wp:post-excerpt {"moreText":"Read more","fontSize":"normal"} /--></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:post-featured-image /--></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->
<!-- /wp:post-template -->

<!-- wp:query-pagination -->
<div class="wp-block-query-pagination"><!-- wp:query-pagination-previous {"label":"Previous Page"} /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next {"label":"Next Page"} /--></div>
<!-- /wp:query-pagination --></div>
<!-- /wp:query -->',
);
File renamed without changes.
75 changes: 75 additions & 0 deletions quadrat/sass/block-styles/_query.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.is-style-quadrat-diamond-posts {
.post-meta {
justify-content: flex-start;
}
.wp-block-query-pagination,
.post-meta {
a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
.wp-block-column {
flex-basis: auto;
@media (min-width: #{ $break-small }) {
&:last-child {
max-width: 300px;
flex-shrink: 0;
}
&:first-child {
padding-right: 2em;
}
}
}
.wp-block-post-featured-image {
width: 300px;
@media (max-width: #{ ($break-small - 1) }) {
width: 100%;
}
Comment on lines +28 to +30
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this aligns it to the Columns block media query that collapses the two columns into one. I tried to find a solution without a media query but I couldn't :(

img {
object-fit: cover;
width: 100%;
height: 300px;
}
}
.wp-block-post-template {
li {
display: flex;
align-items: center;
min-height: 400px;
position: relative;
& > * {
flex-basis: 100%;
}
&:before {
content: "";
background: var(--wp--preset--color--secondary);
width: 375px;
height: 375px;
position: absolute;
top: 0;
left: 0;
z-index: -1;
opacity:0;
transition: all 0.4s ease-in;
}
&:hover:before {
opacity:1;
}
&:nth-child(2n+1):before {
transform: rotate(16deg) translate(-130px, -20px);
}
&:nth-child(2n+1):hover:before {
transform: rotate(-8deg) translate(-110px, 0);
}
&:nth-child(2n+2):before {
transform: rotate(24deg) translate(-130px, 20px);
}
&:nth-child(2n+2):hover:before {
transform: rotate(16deg) translate(-110px, 40px);
}
Comment on lines +56 to +72
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjellr we went with a very simple animation that we think looks decent, but feel free to tweak the numbers in any way shape or form

}
}
}
8 changes: 7 additions & 1 deletion quadrat/sass/blocks/_query.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.wp-block-query-loop {
.wp-block-query-loop,
.wp-block-query {
.wp-block-post-title {
font-size: var(--wp--custom--heading--h3--font-size);
}

// Important is necessary to override any other font size rules applied to the exerpt.
.wp-block-post-excerpt__more-text {
font-size: var(--wp--preset--font-size--tiny) !important;
}
}
Loading