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

Price Filter block: enable global style #5559

Merged
merged 1 commit into from
Jan 17, 2022
Merged
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
1 change: 1 addition & 0 deletions assets/js/blocks/price-filter/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
* Internal dependencies
*/
import usePriceConstraints from './use-price-constraints.js';
import './style.scss';

/**
* Component displaying a price filter.
Expand Down
19 changes: 7 additions & 12 deletions assets/js/blocks/price-filter/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import classNames from 'classnames';
import { InspectorControls } from '@wordpress/block-editor';
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
import {
Placeholder,
Disabled,
Expand All @@ -26,13 +25,14 @@ import './editor.scss';

export default function ( { attributes, setAttributes } ) {
const {
className,
heading,
headingLevel,
showInputFields,
showFilterButton,
} = attributes;

const blockProps = useBlockProps();

const getInspectorControls = () => {
return (
<InspectorControls key="inspector">
Expand Down Expand Up @@ -152,16 +152,11 @@ export default function ( { attributes, setAttributes } ) {
);

return (
<>
<div { ...blockProps }>
{ blocksConfig.productCount === 0 ? (
noProductsPlaceholder()
) : (
<div
className={ classNames(
className,
'wp-block-woocommerce-price-filter'
) }
>
<>
{ getInspectorControls() }
<BlockTitle
className="wc-block-price-filter__title"
Expand All @@ -174,8 +169,8 @@ export default function ( { attributes, setAttributes } ) {
<Disabled>
<Block attributes={ attributes } isEditor={ true } />
</Disabled>
</div>
</>
) }
</>
</div>
);
}
24 changes: 15 additions & 9 deletions assets/js/blocks/price-filter/editor.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
.components-disabled .wc-block-price-filter__range-input-wrapper .wc-block-price-filter__range-input {
&::-webkit-slider-thumb {
pointer-events: none;
}
&::-moz-range-thumb {
pointer-events: none;
}
&::-ms-thumb {
pointer-events: none;
.wp-block-woocommerce-price-filter .components-disabled {
border-radius: inherit;
border-color: inherit;

.wc-block-price-filter__range-input-wrapper .wc-block-price-filter__range-input {
&::-webkit-slider-thumb {
pointer-events: none;
}
&::-moz-range-thumb {
pointer-events: none;
}
&::-ms-thumb {
pointer-events: none;
}
}
}

.wc-block-price-slider {
.components-placeholder__instructions {
border-bottom: 1px solid #e0e2e6;
Expand Down
18 changes: 17 additions & 1 deletion assets/js/blocks/price-filter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { __ } from '@wordpress/i18n';
import { registerBlockType } from '@wordpress/blocks';
import classNames from 'classnames';
import { Icon, bill } from '@woocommerce/icons';
import { isFeaturePluginBuild } from '@woocommerce/block-settings';
import { useBlockProps } from '@wordpress/block-editor';

/**
* Internal dependencies
*/
import edit from './edit.js';

registerBlockType( 'woocommerce/price-filter', {
apiVersion: 2,
title: __( 'Filter Products by Price', 'woo-gutenberg-products-block' ),
icon: {
src: (
Expand All @@ -30,6 +33,17 @@ registerBlockType( 'woocommerce/price-filter', {
supports: {
html: false,
multiple: false,
color: {
text: true,
background: false,
},
...( isFeaturePluginBuild() && {
__experimentalBorder: {
radius: true,
color: true,
width: false,
},
} ),
},
example: {},
attributes: {
Expand Down Expand Up @@ -70,7 +84,9 @@ registerBlockType( 'woocommerce/price-filter', {
};
return (
<div
className={ classNames( 'is-loading', className ) }
{ ...useBlockProps.save( {
className: classNames( 'is-loading', className ),
} ) }
{ ...data }
>
<span
Expand Down
25 changes: 25 additions & 0 deletions assets/js/blocks/price-filter/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.wp-block-woocommerce-price-filter {
border-style: none !important;
}

.wc-block-price-slider {
border-radius: inherit;
border-color: inherit;
}

.wc-block-price-filter {
border-radius: inherit;
border-color: inherit;
}


.wc-block-price-filter__controls {
border-radius: inherit;
border-color: inherit;

input {
border-radius: inherit !important;
border-color: inherit !important;
border-style: solid;
}
}