-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial integration with vanilla-extract
- Loading branch information
1 parent
b642d40
commit 81c6556
Showing
14 changed files
with
1,621 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
43 changes: 43 additions & 0 deletions
43
projects/10up-theme/includes/blocks/example-vanilla-extract/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,43 @@ | ||
{ | ||
"title": "Example Block (With Vanilla Extract)", | ||
"description": "An Example Block (With Vanilla Extract)", | ||
"textdomain": "tenup-scaffold", | ||
"name": "tenup/example-vanilla-extract", | ||
"icon": "feedback", | ||
"category": "tenup-scaffold-blocks", | ||
"attributes": { | ||
"title": { | ||
"type": "string" | ||
} | ||
}, | ||
"example": { | ||
"attributes": { | ||
"title": "Example Block (With Vanilla Extract)" | ||
} | ||
}, | ||
"supports": { | ||
"align": false, | ||
"alignWide": false, | ||
"anchor": false, | ||
"color": { | ||
"gradients": false, | ||
"background": false, | ||
"text": false | ||
}, | ||
"customClassName": false, | ||
"defaultStylePicker": false, | ||
"typography": { | ||
"fontSize": false, | ||
"lineHeight": true | ||
}, | ||
"html": false, | ||
"inserter": true, | ||
"multiple": true, | ||
"reusable": false, | ||
"spacing": { | ||
"padding": false | ||
} | ||
}, | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css" | ||
} |
38 changes: 38 additions & 0 deletions
38
projects/10up-theme/includes/blocks/example-vanilla-extract/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,38 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { RichText, useBlockProps } from '@wordpress/block-editor'; | ||
|
||
// the version specified in package.json does not ship a transpiled version, | ||
// so the intent here is to test toolkit `--include` feature to manually tell toolkit to transpile this package | ||
import { ContentPicker } from '@10up/block-components'; | ||
import { container } from './styles.css.ts'; | ||
|
||
const ExampleBlockEdit = (props) => { | ||
const { attributes, setAttributes } = props; | ||
const { title } = attributes; | ||
|
||
const blockProps = useBlockProps(); | ||
|
||
return ( | ||
<div {...blockProps} className={container}> | ||
<RichText | ||
className="wp-block-example-block__title" | ||
tagName="h2" | ||
placeholder={__('Custom Title (Vanilla Extract)')} | ||
value={title} | ||
onChange={(title) => setAttributes({ title })} | ||
/> | ||
<ContentPicker | ||
onPickChange={(pickedContent) => { | ||
console.log(pickedContent); | ||
}} | ||
mode="post" | ||
label="Please select a Post or Page:" | ||
contentTypes={['post', 'page']} | ||
/> | ||
</div> | ||
); | ||
}; | ||
export default ExampleBlockEdit; |
10 changes: 10 additions & 0 deletions
10
projects/10up-theme/includes/blocks/example-vanilla-extract/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,10 @@ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
import edit from './edit'; | ||
import save from './save'; | ||
import block from './block.json'; | ||
|
||
registerBlockType(block, { | ||
edit, | ||
save, | ||
}); |
18 changes: 18 additions & 0 deletions
18
projects/10up-theme/includes/blocks/example-vanilla-extract/markup.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,18 @@ | ||
<?php | ||
/** | ||
* Example block markup | ||
* | ||
* @package TenUpTheme\Blocks\Example | ||
* | ||
* @var array $attributes Block attributes. | ||
* @var string $content Block content. | ||
* @var WP_Block $block Block instance. | ||
* @var array $context Block context. | ||
*/ | ||
|
||
?> | ||
<div <?php echo get_block_wrapper_attributes(); // phpcs:ignore ?>> | ||
<h2 class="wp-block-tenup-example__title"> | ||
<?php echo wp_kses_post( $attributes['title'] ); ?> | ||
</h2> | ||
</div> |
15 changes: 15 additions & 0 deletions
15
projects/10up-theme/includes/blocks/example-vanilla-extract/props-shape.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,15 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
export const propsShape = { | ||
attributes: PropTypes.shape({ | ||
customTitle: PropTypes.string, | ||
}).isRequired, | ||
className: PropTypes.string, | ||
}; | ||
|
||
export const editPropsShape = { | ||
...propsShape, | ||
clientId: PropTypes.string, | ||
isSelected: PropTypes.bool, | ||
setAttributes: PropTypes.func.isRequired, | ||
}; |
49 changes: 49 additions & 0 deletions
49
projects/10up-theme/includes/blocks/example-vanilla-extract/register.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,49 @@ | ||
<?php | ||
/** | ||
* Gutenberg Blocks setup | ||
* | ||
* @package TenUpTheme\Blocks\Example | ||
*/ | ||
|
||
namespace TenUpTheme\Blocks\Example; | ||
|
||
/** | ||
* Register the block | ||
*/ | ||
function register() { | ||
$n = function( $function ) { | ||
return __NAMESPACE__ . "\\$function"; | ||
}; | ||
// Register the block. | ||
register_block_type_from_metadata( | ||
TENUP_THEME_BLOCK_DIST_DIR . '/example-vanilla-extract', | ||
[ | ||
'render_callback' => $n( 'render_block_callback' ), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Render callback method for the block | ||
* | ||
* @param array $attributes The blocks attributes | ||
* @param string $content Data returned from InnerBlocks.Content | ||
* @param array $block Block information such as context. | ||
* | ||
* @return string The rendered block markup. | ||
*/ | ||
function render_block_callback( $attributes, $content, $block ) { | ||
ob_start(); | ||
get_template_part( | ||
'includes/blocks/example-vanilla-extract/markup', | ||
null, | ||
[ | ||
'class_name' => 'wp-block-tenup-example', | ||
'attributes' => $attributes, | ||
'content' => $content, | ||
'block' => $block, | ||
] | ||
); | ||
|
||
return ob_get_clean(); | ||
} |
8 changes: 8 additions & 0 deletions
8
projects/10up-theme/includes/blocks/example-vanilla-extract/save.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,8 @@ | ||
/** | ||
* See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save | ||
* | ||
* @returns {null} Dynamic blocks do not save the HTML. | ||
*/ | ||
const ExampleBlockSave = () => null; | ||
|
||
export default ExampleBlockSave; |
6 changes: 6 additions & 0 deletions
6
projects/10up-theme/includes/blocks/example-vanilla-extract/styles.css.ts
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,6 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const container = style({ | ||
border: '2px dashed black', | ||
backgroundColor: 'blue', | ||
}); |
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