diff --git a/theme/assets/css/src/front-end.css b/theme/assets/css/src/front-end.css
index 314b578d1..43bd2b7fc 100644
--- a/theme/assets/css/src/front-end.css
+++ b/theme/assets/css/src/front-end.css
@@ -29,3 +29,4 @@
/* Block editor */
@import "./../../src/block-editor/plugins/hide-sections/style.css";
@import "./../../src/block-editor/style/horizontal-line/style.css";
+@import "./../../src/block-editor/blocks/card-image/style.css";
diff --git a/theme/assets/src/block-editor/blocks/card-image/block.json b/theme/assets/src/block-editor/blocks/card-image/block.json
new file mode 100644
index 000000000..be52f0722
--- /dev/null
+++ b/theme/assets/src/block-editor/blocks/card-image/block.json
@@ -0,0 +1,19 @@
+{
+ "$schema": "https://schemas.wp.org/trunk/block.json",
+ "name": "material/image-card-query",
+ "category": "material",
+ "attributes": {
+ "isEditMode": {
+ "type": "boolean",
+ "default": false
+ }
+ },
+ "title": "Material Image Card for Query loop",
+ "supports": {},
+ "apiVersion": 2,
+ "description": "Material image card for query loop block",
+ "editorStyle": ["material-google-fonts-cdn", "material-block-editor-css-theme"],
+ "editorScript": "material-block-editor-js-theme",
+ "usesContext": [ "postId", "postType", "queryId" ],
+ "textdomain": "material-design-google"
+}
diff --git a/theme/assets/src/block-editor/blocks/card-image/edit.js b/theme/assets/src/block-editor/blocks/card-image/edit.js
new file mode 100644
index 000000000..1b1b18807
--- /dev/null
+++ b/theme/assets/src/block-editor/blocks/card-image/edit.js
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2020 Google LLC
+ *
+ * Licensed uder the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * External dependencies
+ */
+/**
+ * WordPress dependencies
+ */
+import { useBlockProps } from '@wordpress/block-editor';
+import ServerSideRender from '@wordpress/server-side-render';
+
+/**
+ * Internal dependencies
+ */
+import { name } from './block.json';
+
+/**
+ * Edit.
+ *
+ * @param {Object} props
+ * @param {{postType:string,postId:number,queryId:number}} props.context
+ * @param {Object} props.attributes
+ * @return {JSX.Element} Block edit.
+ */
+const Edit = ( { context, attributes } ) => {
+ const urlQueryArgs = {
+ materialParamContext: [],
+ };
+ // Server side rendering doesn't support passing context yet. This hack adds context as url param to later manually parse in php.
+ for ( const key in context ) {
+ urlQueryArgs.materialParamContext[ key ] = context[ key ];
+ }
+ const ssrAttributes = {
+ ...attributes,
+ ...{ isEditMode: true },
+ };
+ return (
+ <>
+
+
+
+ >
+ );
+};
+
+export default Edit;
diff --git a/theme/assets/src/block-editor/blocks/card-image/icon.js b/theme/assets/src/block-editor/blocks/card-image/icon.js
new file mode 100644
index 000000000..51f30c69e
--- /dev/null
+++ b/theme/assets/src/block-editor/blocks/card-image/icon.js
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Block Icon component.
+ *
+ * @return {JSX.Element} Function returning the HTML markup for the component.
+ */
+export const icon = () => (
+ chrome_reader_mode
+);
diff --git a/theme/assets/src/block-editor/blocks/card-image/index.js b/theme/assets/src/block-editor/blocks/card-image/index.js
new file mode 100644
index 000000000..14752c107
--- /dev/null
+++ b/theme/assets/src/block-editor/blocks/card-image/index.js
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Internal dependencies
+ */
+import metadata from './block.json';
+import { icon } from './icon';
+import edit from './edit';
+
+const { name, title } = metadata;
+
+export { metadata, name };
+
+export const settings = {
+ title,
+ description: metadata.description,
+ icon,
+ edit,
+};
diff --git a/theme/assets/src/block-editor/blocks/card-image/style.css b/theme/assets/src/block-editor/blocks/card-image/style.css
new file mode 100644
index 000000000..5c57463d0
--- /dev/null
+++ b/theme/assets/src/block-editor/blocks/card-image/style.css
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.wp-block-material-image-card-query a {
+ display: block;
+}
+
+.wp-block-material-image-card-query {
+ position: relative;
+
+ .mdc-image-list__supporting {
+ position: absolute;
+ background: rgba(0, 0, 0, .6);
+ bottom: 7.5px;
+ color: #fff;
+ height: auto;
+ width: 100%;
+ align-items: start;
+ border-bottom-left-radius: var(--mdc-image-list-radius, 4px);
+ border-bottom-right-radius: var(--mdc-image-list-radius, 4px);
+ max-height: 100%;
+ min-height: 48px;
+ overflow: hidden;
+ padding: 8px 16px;
+ }
+}
diff --git a/theme/assets/src/customizer/customize-controls.js b/theme/assets/src/customizer/customize-controls.js
index 56792a641..69e9722b2 100644
--- a/theme/assets/src/customizer/customize-controls.js
+++ b/theme/assets/src/customizer/customize-controls.js
@@ -89,7 +89,7 @@
};
api.bind( 'ready', () => {
- api( 'archive_layout' ).bind( value => {
+ api( 'archive_layout' )?.bind( value => {
const isCardLayout = 'card' === value;
const controls = [
diff --git a/theme/inc/blocks/class-blocks.php b/theme/inc/blocks/class-blocks.php
index 2c19b27a8..23d6bfc25 100644
--- a/theme/inc/blocks/class-blocks.php
+++ b/theme/inc/blocks/class-blocks.php
@@ -33,6 +33,7 @@ class Blocks {
const DYNAMIC_BLOCKS = [
'material/search' => 'template-parts/blocks/search.php',
'material/card-query' => 'template-parts/blocks/card-query.php',
+ 'material/image-card-query' => 'template-parts/blocks/image-card-query.php',
'material/query-pagination' => 'template-parts/blocks/query-pagination.php',
'material/query-pagination-next' => 'template-parts/blocks/query-pagination-next.php',
'material/query-pagination-previous' => 'template-parts/blocks/query-pagination-previous.php',
diff --git a/theme/inc/customizer/layout.php b/theme/inc/customizer/layout.php
index 4d13b18bd..f9ece836f 100644
--- a/theme/inc/customizer/layout.php
+++ b/theme/inc/customizer/layout.php
@@ -26,6 +26,7 @@
namespace MaterialDesign\Theme\Customizer\Layout;
use MaterialDesign\Theme\Customizer;
+use function MaterialDesign\Theme\BlockEditor\is_fse;
/**
* Attach hooks
@@ -95,61 +96,7 @@ function add_settings( $wp_customize ) {
* @return array
*/
function get_controls() {
- return [
- [
- 'id' => 'archive_width',
- 'label' => esc_html__( 'Posts layout width', 'material-design-google' ),
- 'type' => 'radio',
- 'choices' => [
- 'wide' => esc_html__( 'Wide', 'material-design-google' ),
- 'normal' => esc_html__( 'Normal', 'material-design-google' ),
- ],
- ],
- [
- 'id' => 'archive_layout',
- 'label' => esc_html__( 'Posts layout', 'material-design-google' ),
- 'type' => 'radio',
- 'choices' => [
- 'card' => esc_html__( 'Card', 'material-design-google' ),
- 'image' => esc_html__( 'Image List', 'material-design-google' ),
- ],
- ],
- [
- 'id' => 'archive_card_options',
- 'label' => esc_html__( 'Card display options', 'material-design-google' ),
- 'type' => 'hidden',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
- [
- 'id' => 'archive_comments',
- 'label' => esc_html__( 'Comments', 'material-design-google' ),
- 'type' => 'checkbox',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
- [
- 'id' => 'archive_author',
- 'label' => esc_html__( 'Author', 'material-design-google' ),
- 'type' => 'checkbox',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
- [
- 'id' => 'archive_excerpt',
- 'label' => esc_html__( 'Excerpt', 'material-design-google' ),
- 'type' => 'checkbox',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
- [
- 'id' => 'archive_date',
- 'label' => esc_html__( 'Date', 'material-design-google' ),
- 'type' => 'checkbox',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
- [
- 'id' => 'archive_outlined',
- 'label' => esc_html__( 'Outlined', 'material-design-google' ),
- 'type' => 'checkbox',
- 'active_callback' => __NAMESPACE__ . '\is_card_layout',
- ],
+ $controls = [
[
'id' => 'comment_fields_style',
'label' => esc_html__( 'Comment field display options', 'material-design-google' ),
@@ -161,6 +108,69 @@ function get_controls() {
],
],
];
+
+ if ( ! is_fse() ) {
+ $non_fse_controls = [
+ [
+ 'id' => 'archive_width',
+ 'label' => esc_html__( 'Posts layout width', 'material-design-google' ),
+ 'type' => 'radio',
+ 'choices' => [
+ 'wide' => esc_html__( 'Wide', 'material-design-google' ),
+ 'normal' => esc_html__( 'Normal', 'material-design-google' ),
+ ],
+ ],
+ [
+ 'id' => 'archive_layout',
+ 'label' => esc_html__( 'Posts layout', 'material-design-google' ),
+ 'type' => 'radio',
+ 'choices' => [
+ 'card' => esc_html__( 'Card', 'material-design-google' ),
+ 'image' => esc_html__( 'Image List', 'material-design-google' ),
+ ],
+ ],
+ [
+ 'id' => 'archive_card_options',
+ 'label' => esc_html__( 'Card display options', 'material-design-google' ),
+ 'type' => 'hidden',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ [
+ 'id' => 'archive_comments',
+ 'label' => esc_html__( 'Comments', 'material-design-google' ),
+ 'type' => 'checkbox',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ [
+ 'id' => 'archive_author',
+ 'label' => esc_html__( 'Author', 'material-design-google' ),
+ 'type' => 'checkbox',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ [
+ 'id' => 'archive_excerpt',
+ 'label' => esc_html__( 'Excerpt', 'material-design-google' ),
+ 'type' => 'checkbox',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ [
+ 'id' => 'archive_date',
+ 'label' => esc_html__( 'Date', 'material-design-google' ),
+ 'type' => 'checkbox',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ [
+ 'id' => 'archive_outlined',
+ 'label' => esc_html__( 'Outlined', 'material-design-google' ),
+ 'type' => 'checkbox',
+ 'active_callback' => __NAMESPACE__ . '\is_card_layout',
+ ],
+ ];
+
+ $controls = array_merge( $controls, $non_fse_controls );
+ }
+
+ return $controls;
}
/**
diff --git a/theme/template-parts/blocks/image-card-query.php b/theme/template-parts/blocks/image-card-query.php
new file mode 100644
index 000000000..b76b16fd3
--- /dev/null
+++ b/theme/template-parts/blocks/image-card-query.php
@@ -0,0 +1,43 @@
+context['postId']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+$post_link = $is_edit ? '#link-to-' . $post_ID : get_the_permalink( $post );
+if ( has_post_thumbnail( $post_ID ) ) {
+ $thumbnail = get_the_post_thumbnail_url( $post_ID );
+} else {
+ $thumbnail = get_template_directory_uri() . '/assets/images/placeholder.png';
+}
+$wrapper_attributes = get_block_wrapper_attributes();
+?>
+