Skip to content

Commit

Permalink
post listing block
Browse files Browse the repository at this point in the history
  • Loading branch information
billerickson committed Nov 21, 2019
1 parent a7a3e7a commit 6ed35e7
Show file tree
Hide file tree
Showing 14 changed files with 456 additions and 4 deletions.
120 changes: 120 additions & 0 deletions acf-json/group_5dd48fe1660cb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"key": "group_5dd48fe1660cb",
"title": "Post Listing block",
"fields": [
{
"key": "field_5dd48fee5f73b",
"label": "Title",
"name": "title",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
},
{
"key": "field_5dd490165f73c",
"label": "Order by",
"name": "orderby",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"recent": "Recent",
"popular": "Popular"
},
"default_value": [
"recent"
],
"allow_null": 0,
"multiple": 0,
"ui": 0,
"return_format": "value",
"ajax": 0,
"placeholder": ""
},
{
"key": "field_5dd4905c5f73d",
"label": "Filter by Category",
"name": "category",
"type": "taxonomy",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"taxonomy": "category",
"field_type": "multi_select",
"allow_null": 1,
"add_term": 0,
"save_terms": 0,
"load_terms": 0,
"return_format": "id",
"multiple": 0
},
{
"key": "field_5dd4907f5f73e",
"label": "Layout",
"name": "post_listing_layout",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"layout3": "3 Columns",
"layout4": "4 Columns",
"layout2x2": "2x2 Columns"
},
"default_value": [
"layout3"
],
"allow_null": 0,
"multiple": 0,
"ui": 0,
"return_format": "value",
"ajax": 0,
"placeholder": ""
}
],
"location": [
[
{
"param": "block",
"operator": "==",
"value": "acf\/post-listing"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": "",
"modified": 1574211779
}
Binary file added assets/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/css/editor-style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/main.css.map

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

Binary file added assets/icons/.DS_Store
Binary file not shown.
Binary file added assets/icons/social/.DS_Store
Binary file not shown.
Binary file added assets/icons/utility/.DS_Store
Binary file not shown.
80 changes: 80 additions & 0 deletions assets/scss/partials/_blocks-custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* Post Listing
--------------------------------------------- */

.post-listing-block {

header, footer {
grid-column: 1 / -1;
width: 100%;
@include clearfix;
}

footer {
position: relative;
margin-top: -20px;

a {
color: $highlight;
display: inline-block;
font-size: 18px;
font-weight: 700;
letter-spacing: .5px;
text-decoration: none;
text-transform: uppercase;
position: relative;
z-index: 2;
}
}

@supports( display: $grid ) {

&.layout3 {
@include media(">=tablet") {
display: grid;
grid-template-columns: repeat( 3, 1fr );
grid-column-gap: $grid-gap;
}
}

&.layout4 {
@include media(">=tablet") {
display: grid;
grid-template-columns: repeat( 2, 1fr );
grid-column-gap: $grid-gap;
}
@include media(">=medium") {
grid-template-columns: repeat( 4, 1fr );
}
}

&.layout2x2 {
display: grid;
grid-template-columns: repeat( 2, 1fr );
grid-column-gap: 16px;
@include media(">=tablet") {
grid-column-gap: $grid-gap;
}
}

&.layout1x3 {
@include media(">=tablet") {
display: grid;
grid-template-columns: repeat( 2, 1fr );
grid-column-gap: $grid-gap;
align-items: start;

.feature {
grid-row: span 4;
}

.secondary .post-summary__image {
margin: 0;
}

footer {
margin-top: -16px;
}
}
}
}
}
2 changes: 1 addition & 1 deletion assets/scss/partials/_post-summary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

.entry-category {
font-size: 12px;
font-weight: 600;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 4px;
Expand Down
1 change: 1 addition & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function ea_child_theme_setup() {
include_once( get_stylesheet_directory() . '/inc/category-landing-page.php' );
include_once( get_stylesheet_directory() . '/inc/block-area.php' );
include_once( get_stylesheet_directory() . '/inc/social-links.php' );
include_once( get_stylesheet_directory() . '/inc/post-listing.php' );

// Plugin Support
include_once( get_stylesheet_directory() . '/inc/acf.php' );
Expand Down
35 changes: 35 additions & 0 deletions inc/acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function __construct() {
// Register Blocks
add_action('acf/init', array( $this, 'register_blocks' ) );

// Dynamic options
add_filter( 'acf/load_field', array( $this, 'dynamic_layouts' ) );
}

/**
Expand Down Expand Up @@ -51,6 +53,39 @@ function register_blocks() {
if( ! function_exists('acf_register_block_type') )
return;

acf_register_block_type(array(
'name' => 'post-listing',
'title' => __( 'Post Listing', 'grownandflown2020' ),
'mode' => 'auto',
'render_template' => 'partials/blocks/post-listing.php',
'category' => 'widgets',
'icon' => 'feedback',
'supports' => [ 'anchor' => true, 'align' => false ],
));

}

/**
* Dynamic layouts
*
*/
function dynamic_layouts( $field ) {
if( 'post_listing_layout' !== $field['name'] )
return $field;

$field['choices'] = [];
$field['default'] = false;
$layouts = ea_post_listing_layouts();
foreach( $layouts as $key => $details ) {
$field['choices'][ $key ] = $details['label'];

// Set default to first layout
if( false === $field['default'] )
$field['default'] = $key;
}

return $field;
}

}
new BE_ACF_Customizations();
Loading

0 comments on commit 6ed35e7

Please sign in to comment.