-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e241320
commit 318bde6
Showing
7 changed files
with
161 additions
and
245 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
252 changes: 7 additions & 245 deletions
252
source/wp-content/themes/wporg-main-2022/patterns/remembers.php
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
source/wp-content/themes/wporg-main-2022/src/remembers-list/block.json
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,35 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "wporg/remembers-list", | ||
"version": "0.1.0", | ||
"title": "Remembers Contributor List", | ||
"category": "design", | ||
"icon": "heading", | ||
"description": "Remembers Contributor List", | ||
"textdomain": "wporg", | ||
"attributes": { | ||
"columns": { | ||
"type": "number", | ||
"default": 3 | ||
} | ||
}, | ||
"supports": { | ||
"align": true, | ||
"color": { | ||
"background": true, | ||
"text": true | ||
}, | ||
"spacing": { | ||
"margin": [ "top", "bottom" ], | ||
"padding": true, | ||
"blockGap": false | ||
}, | ||
"typography": { | ||
"fontSize": true, | ||
"lineHeight": true | ||
} | ||
}, | ||
"editorScript": "file:./index.js", | ||
"style": "file:./style-index.css" | ||
} |
17 changes: 17 additions & 0 deletions
17
source/wp-content/themes/wporg-main-2022/src/remembers-list/edit.js
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,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
||
import { useBlockProps } from '@wordpress/block-editor'; | ||
import { Disabled } from '@wordpress/components'; | ||
import ServerSideRender from '@wordpress/server-side-render'; | ||
|
||
export default function Edit( { attributes, name } ) { | ||
return ( | ||
<div { ...useBlockProps() }> | ||
<Disabled> | ||
<ServerSideRender block={ name } attributes={ attributes } /> | ||
</Disabled> | ||
</div> | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
source/wp-content/themes/wporg-main-2022/src/remembers-list/index.js
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,16 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Edit from './edit'; | ||
import metadata from './block.json'; | ||
import './style.scss'; | ||
|
||
registerBlockType( metadata.name, { | ||
edit: Edit, | ||
save: () => null, | ||
} ); |
76 changes: 76 additions & 0 deletions
76
source/wp-content/themes/wporg-main-2022/src/remembers-list/index.php
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,76 @@ | ||
<?php | ||
/** | ||
* Block Name: Remembers Contributor List | ||
* Description: Displays a list of memorialized contributors.. | ||
* | ||
* @package wporg | ||
*/ | ||
|
||
namespace WordPressdotorg\Theme\Main_2022\Remembers_List_Block; | ||
|
||
add_action( 'init', __NAMESPACE__ . '\init' ); | ||
|
||
/** | ||
* Registers the block using the metadata loaded from the `block.json` file. | ||
* Behind the scenes, it registers also all assets so they can be enqueued | ||
* through the block editor in the corresponding context. | ||
* | ||
* @see https://developer.wordpress.org/reference/functions/register_block_type/ | ||
*/ | ||
function init() { | ||
register_block_type( | ||
dirname( dirname( __DIR__ ) ) . '/build/remembers-list', | ||
array( | ||
'render_callback' => __NAMESPACE__ . '\render', | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Render the block content. | ||
* | ||
* @param array $attributes Block attributes. | ||
* @param string $content Block default content. | ||
* @param WP_Block $block Block instance. | ||
* | ||
* @return string Returns the block markup. | ||
*/ | ||
function render( $attributes, $content, $block ) { | ||
|
||
// Replace with query | ||
$profiles = [ 'Kim Parsell', 'Alex King', 'Jesse Petersen', 'Efrain Rivera', 'Todrick Moore', 'Alex Mills', 'Joseph Karr O’Connor', 'David de Boer' ]; | ||
|
||
$columns = $attributes['columns']; | ||
$group_count = ceil( count( $profiles ) / $columns ); | ||
|
||
$groups = []; | ||
for ( $i = 0; $i < $group_count; $i++ ) { | ||
$groups[] = array_slice( $profiles, $i * $columns, $columns ); | ||
} | ||
|
||
$block_content = ''; | ||
foreach ( $groups as $group ) { | ||
$block_content .= '<!-- wp:columns --><div class="wp-block-columns">'; | ||
|
||
foreach ( $group as $name ) { | ||
$block_content .= '<!-- wp:column --><div class="wp-block-column">'; | ||
$block_content .= '<!-- wp:heading {"textAlign":"center","style":{"spacing":{"margin":{"top":"var:preset|spacing|30","right":"var:preset|spacing|default","bottom":"var:preset|spacing|30","left":"var:preset|spacing|default"}}},"fontSize":"extra-large"} -->'; | ||
$block_content .= '<h2 class="wp-block-heading has-text-align-center has-extra-large-font-size" style="margin-top:var(--wp--preset--spacing--30);margin-right:var(--wp--preset--spacing--default);margin-bottom:var(--wp--preset--spacing--30);margin-left:var(--wp--preset--spacing--default)">'; | ||
$block_content .= '<em>'; | ||
$block_content .= '<a href="https://google.com">' . esc_html( $name ) . '</a>'; | ||
$block_content .= '</em>'; | ||
$block_content .= '</h2>'; | ||
$block_content .= '<!-- /wp:heading -->'; | ||
$block_content .= '</div><!-- /wp:column -->'; | ||
} | ||
|
||
$block_content .= '</div><!-- /wp:columns -->'; | ||
} | ||
|
||
$wrapper_attributes = get_block_wrapper_attributes(); | ||
return sprintf( | ||
'<h1 %1$s>%2$s</h1>', | ||
$wrapper_attributes, | ||
do_blocks( $block_content ) | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
source/wp-content/themes/wporg-main-2022/src/remembers-list/style.scss
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,9 @@ | ||
.wp-block-wporg-remembers-list a { | ||
display: inline-block; | ||
color: inherit; | ||
text-decoration: none; | ||
|
||
&:hover { | ||
text-decoration: underline; | ||
} | ||
} |