Skip to content

Commit

Permalink
Merge pull request #293 from material-components/fse/page
Browse files Browse the repository at this point in the history
Add page
  • Loading branch information
emeaguiar committed Feb 1, 2022
2 parents fee8901 + f026ada commit fa04f6b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 23 deletions.
10 changes: 7 additions & 3 deletions theme/assets/src/block-editor/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import { addFilter } from '@wordpress/hooks';
import { createHigherOrderComponent } from '@wordpress/compose';
import { useEffect } from '@wordpress/element';

const blockClassPrefillMap = {
'core/site-title': 'site-title mdc-typography mdc-typography--headline6',
'core/post-title': 'mdc-typography mdc-typography-headline2 entry-title',
};

/**
* Trigger a class change when component is rendered.
*
Expand All @@ -36,10 +41,9 @@ const withAttributeChange = createHigherOrderComponent( BlockEdit => {
} = props;

useEffect( () => {
if ( 'core/site-title' === name && ! className ) {
if ( blockClassPrefillMap[ name ] && ! className ) {
props.setAttributes( {
className:
'site-title mdc-typography mdc-typography--headline6',
className: blockClassPrefillMap[ name ],
} );
}
// Use empty array to make sure this runs only once.
Expand Down
13 changes: 8 additions & 5 deletions theme/assets/src/block-editor/plugins/hide-sections/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* global materialDesignThemeEditorVars */
/**
* Wordpress Dependencies
*/
Expand Down Expand Up @@ -117,7 +117,10 @@ const WrappedSectionControl = compose( [
} ),
] )( HideSection );

registerPlugin( 'material-hide-sections', {
render: WrappedSectionControl,
icon: <Icon icon="admin-customizer" />,
} );
/** @member {{isFse:boolean}} materialDesignThemeEditorVars */
if ( ! materialDesignThemeEditorVars?.isFse ) {
registerPlugin( 'material-hide-sections', {
render: WrappedSectionControl,
icon: <Icon icon="admin-customizer" />,
} );
}
1 change: 1 addition & 0 deletions theme/block-templates/blank.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!-- wp:post-content {"layout":{"inherit":true}} /-->
11 changes: 11 additions & 0 deletions theme/block-templates/page-no-title.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- wp:template-part {"slug":"header"} /-->

<!-- wp:group {"tagName":"main","style":{"spacing":{"padding":{"top":"0px","right":"0px","bottom":"0px","left":"0px"}}},"layout":{"wideSize":"100vw","contentSize":"100vw"}} -->
<main class="wp-block-group" style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><!-- wp:post-content {"layout":{"inherit":true}} /--></main>
<!-- /wp:group -->

<!-- wp:group {"layout":{"wideSize":"100vw","contentSize":"840px"}} -->
<div class="wp-block-group"><!-- wp:post-comments /--></div>
<!-- /wp:group -->

<!-- wp:template-part {"slug":"footer","className":"site-footer-container"} /-->
21 changes: 7 additions & 14 deletions theme/block-templates/page.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
<!-- wp:template-part {"slug":"header"} /-->

<!-- wp:group {"style":{"spacing":{"padding":{"right":"20px","bottom":"30px","left":"20px"}}},"layout":{"inherit":true}} -->
<div class="wp-block-group" style="padding-right:20px;padding-bottom:30px;padding-left:20px">
<!-- wp:post-title {"textAlign":"left","level":1} /-->
<!-- wp:post-featured-image /-->
</div>
<!-- /wp:group -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"7em","right":"0px","bottom":"0px","left":"0px"}}},"layout":{"wideSize":"100vw","contentSize":"840px"}} -->
<div class="wp-block-group" style="padding-top:7em;padding-right:0px;padding-bottom:0px;padding-left:0px"><!-- wp:post-title {"textAlign":"left","level":1,"className":"mdc-typography mdc-typography-headline2 entry-title"} /-->

<!-- wp:spacer {"height":60} -->
<div style="height:60px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:post-featured-image /--></div>
<!-- /wp:group -->

<!-- wp:group {"tagName":"main"} -->
<main class="wp-block-group">
<!-- wp:post-content {"layout":{"inherit":true}} /-->
</main>
<!-- wp:group {"tagName":"main","style":{"spacing":{"padding":{"top":"0px","right":"0px","bottom":"0px","left":"0px"}}}} -->
<main class="wp-block-group" style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px"><!-- wp:post-content {"layout":{"inherit":true}} /--></main>
<!-- /wp:group -->

<!-- wp:group {"layout":{"inherit":true}} -->
<!-- wp:group {"layout":{"wideSize":"100vw","contentSize":"840px"}} -->
<div class="wp-block-group"><!-- wp:post-comments /--></div>
<!-- /wp:group -->

Expand Down
12 changes: 11 additions & 1 deletion theme/inc/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
function setup() {
add_action( 'init', __NAMESPACE__ . '\\register_disable_section_meta' );
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\enqueue_block_editor_assets' );
add_action( 'body_class', __NAMESPACE__ . '\\filter_body_class' );
if ( ! is_fse() ) {
add_action( 'body_class', __NAMESPACE__ . '\\filter_body_class' );
}

$blocks = new Blocks();
$blocks->init();
Expand Down Expand Up @@ -84,6 +86,14 @@ function enqueue_block_editor_assets() {
false
);

wp_localize_script(
'material-block-editor-js-theme',
'materialDesignThemeEditorVars',
[
'isFse' => is_fse(),
]
);

if ( ! wp_style_is( 'material-google-fonts', 'enqueued' ) ) {
// Ideally this should be injected by the plugin if not fallback to default fonts.
wp_enqueue_style(
Expand Down
7 changes: 7 additions & 0 deletions theme/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
"page",
"post"
]
},
{
"name": "page-no-title",
"title": "Page (No Title)",
"postTypes": [
"page"
]
}
],
"templateParts": [
Expand Down

0 comments on commit fa04f6b

Please sign in to comment.