Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

[Experiment] Product search block Elements API support #6560

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions assets/js/blocks/product-search/edit.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/* eslint-disable @wordpress/no-unsafe-wp-apis */

/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { InspectorControls, PlainText } from '@wordpress/block-editor';
import {
InspectorControls,
PlainText,
__experimentalElementButtonClassName,
} from '@wordpress/block-editor';
import { PanelBody, ToggleControl, TextControl } from '@wordpress/components';
import { withInstanceId } from '@wordpress/compose';
import { useEffect } from '@wordpress/element';
Expand Down Expand Up @@ -114,7 +120,10 @@ const Edit = ( {
/>
<button
type="submit"
className="wc-block-product-search__button"
className={ classnames(
'wc-block-product-search__button',
__experimentalElementButtonClassName
) }
label={ __( 'Search', 'woo-gutenberg-products-block' ) }
onClick={ ( e ) => e.preventDefault() }
tabIndex="-1"
Expand Down
3 changes: 3 additions & 0 deletions assets/js/blocks/product-search/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@
flex-grow: 1;
}
}
.wc-block-product-search__field {
border: 0;
}
}
14 changes: 12 additions & 2 deletions assets/js/blocks/product-search/style.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
.wc-block-product-search {
:where(.wc-block-product-search) {
.wc-block-product-search__fields {
display: flex;
}
.wc-block-product-search__field {
padding: 6px 8px;
line-height: 1.8;
flex-grow: 1;
border-style: solid;
border-width: 1px;
}

.wc-block-product-search__field,
.wc-block-product-search__field > * {
display: flex;
flex-grow: 1;
}

.wc-block-product-search__button {
display: flex;
align-items: center;
margin: 0 0 0 6px;
border: 1px solid #ccc;
margin: 0 0 0 0.625em;
cursor: pointer;
padding: 0 0.5em;
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion src/BlockTypes/ProductSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function render( $attributes, $content ) {
esc_attr( $attributes['placeholder'] )
);
$button_markup = sprintf(
'<button type="submit" class="wc-block-product-search__button" aria-label="%s">
'<button type="submit" class="wc-block-product-search__button wp-element-button" aria-label="%s">
<svg aria-hidden="true" role="img" focusable="false" class="dashicon dashicons-arrow-right-alt2" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<path d="M6 15l5-5-5-5 1-2 7 7-7 7z" />
</svg>
Expand Down