From c34eb7acdcf9f0511aec0b8fa4cae1c8f79b28eb Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 9 Aug 2022 11:30:54 +0700 Subject: [PATCH 01/35] make toggle control full width --- assets/js/blocks/price-filter/edit.tsx | 1 + assets/js/blocks/price-filter/editor.scss | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/assets/js/blocks/price-filter/edit.tsx b/assets/js/blocks/price-filter/edit.tsx index df830023625..7028532665f 100644 --- a/assets/js/blocks/price-filter/edit.tsx +++ b/assets/js/blocks/price-filter/edit.tsx @@ -57,6 +57,7 @@ export default function ( { showInputFields: value === 'editable', } ) } + className="wc-block-price-filter__price-range-toggle" > div { + flex-grow: 1; + } +} + .wc-block-price-slider { .components-placeholder__instructions { border-bottom: 1px solid #e0e2e6; From 2bb8c34c0a420d16f0bfe0eeac066a021ce17e6e Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 9 Aug 2022 11:49:18 +0700 Subject: [PATCH 02/35] add inlineInput attribute --- assets/js/blocks/price-filter/block.json | 4 ++++ assets/js/blocks/price-filter/frontend.ts | 1 + assets/js/blocks/price-filter/types.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/assets/js/blocks/price-filter/block.json b/assets/js/blocks/price-filter/block.json index 3219b673952..4e8323204ad 100644 --- a/assets/js/blocks/price-filter/block.json +++ b/assets/js/blocks/price-filter/block.json @@ -27,6 +27,10 @@ "type": "boolean", "default": true }, + "inlineInput": { + "type": "boolean", + "default": false + }, "showFilterButton": { "type": "boolean", "default": false diff --git a/assets/js/blocks/price-filter/frontend.ts b/assets/js/blocks/price-filter/frontend.ts index ac4e2badb83..ef69736b03d 100644 --- a/assets/js/blocks/price-filter/frontend.ts +++ b/assets/js/blocks/price-filter/frontend.ts @@ -14,6 +14,7 @@ const getProps = ( el: HTMLElement ) => { return { attributes: { showInputFields: el.dataset.showinputfields === 'true', + inlineInput: el.dataset.inlineInput === 'true', showFilterButton: el.dataset.showfilterbutton === 'true', heading: el.dataset.heading || blockAttributes.heading.default, headingLevel: el.dataset.headingLevel diff --git a/assets/js/blocks/price-filter/types.ts b/assets/js/blocks/price-filter/types.ts index 429c298998c..bb574ff6638 100644 --- a/assets/js/blocks/price-filter/types.ts +++ b/assets/js/blocks/price-filter/types.ts @@ -1,6 +1,7 @@ export interface Attributes { showFilterButton: boolean; showInputFields: boolean; + inlineInput: boolean; heading: string; headingLevel: number; className?: string; From d90037cecfa98571c0c2978ffddac6751467e5d4 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Tue, 9 Aug 2022 11:49:35 +0700 Subject: [PATCH 03/35] add inlineInput sidebar setting --- assets/js/blocks/price-filter/edit.tsx | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/assets/js/blocks/price-filter/edit.tsx b/assets/js/blocks/price-filter/edit.tsx index 7028532665f..ffc15de3135 100644 --- a/assets/js/blocks/price-filter/edit.tsx +++ b/assets/js/blocks/price-filter/edit.tsx @@ -32,8 +32,13 @@ export default function ( { attributes, setAttributes, }: BlockEditProps< Attributes > ) { - const { heading, headingLevel, showInputFields, showFilterButton } = - attributes; + const { + heading, + headingLevel, + showInputFields, + inlineInput, + showFilterButton, + } = attributes; const blockProps = useBlockProps(); @@ -74,6 +79,20 @@ export default function ( { ) } /> + { showInputFields && ( + + setAttributes( { + inlineInput: ! inlineInput, + } ) + } + /> + ) } Date: Tue, 9 Aug 2022 13:13:39 +0700 Subject: [PATCH 04/35] add inlineInput help text --- assets/js/blocks/price-filter/edit.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/js/blocks/price-filter/edit.tsx b/assets/js/blocks/price-filter/edit.tsx index ffc15de3135..2e260e937b7 100644 --- a/assets/js/blocks/price-filter/edit.tsx +++ b/assets/js/blocks/price-filter/edit.tsx @@ -91,6 +91,10 @@ export default function ( { inlineInput: ! inlineInput, } ) } + help={ __( + 'Show input fields inline with the slider.', + 'woo-gutenberg-products-block' + ) } /> ) } Date: Tue, 9 Aug 2022 15:15:52 +0700 Subject: [PATCH 05/35] style the filter button --- assets/js/base/components/filter-submit-button/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/base/components/filter-submit-button/index.tsx b/assets/js/base/components/filter-submit-button/index.tsx index 3dc739eb2d2..76e5cb92b6f 100644 --- a/assets/js/base/components/filter-submit-button/index.tsx +++ b/assets/js/base/components/filter-submit-button/index.tsx @@ -30,6 +30,7 @@ const FilterSubmitButton = ( { + + ) } diff --git a/assets/js/base/components/price-slider/style.scss b/assets/js/base/components/price-slider/style.scss index 733bb7a8846..f408ac990ef 100644 --- a/assets/js/base/components/price-slider/style.scss +++ b/assets/js/base/components/price-slider/style.scss @@ -208,6 +208,28 @@ } } +.wc-block-components-price-slider__actions { + align-items: center; + display: flex; + justify-content: flex-end; + margin-left: auto; +} + +.wc-block-components-price-slider__button { + border: none; +} + +.wc-block-components-price-slider__button-reset { + background: transparent; + border: none; + cursor: pointer; + margin-right: $gap; + + &:hover { + text-decoration: underline; + } +} + .rtl { .wc-block-components-price-slider__range-input-progress { --track-background: linear-gradient(to left, transparent var(--low), var(--range-color) 0, var(--range-color) var(--high), transparent 0) no-repeat 0 100% / 100% 100%; From f6fca92102176801b540e14f0e62d2fdcf256cfa Mon Sep 17 00:00:00 2001 From: Tung Du Date: Wed, 10 Aug 2022 11:14:59 +0700 Subject: [PATCH 08/35] clicking on reset button will reset the price query --- assets/js/base/components/price-slider/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/js/base/components/price-slider/index.tsx b/assets/js/base/components/price-slider/index.tsx index e869ed778c4..5fe3d38094a 100644 --- a/assets/js/base/components/price-slider/index.tsx +++ b/assets/js/base/components/price-slider/index.tsx @@ -12,6 +12,7 @@ import { import classnames from 'classnames'; import FormattedMonetaryAmount from '@woocommerce/base-components/formatted-monetary-amount'; import { Currency, isObject } from '@woocommerce/types'; +import { useDebouncedCallback } from 'use-debounce'; /** * Internal dependencies @@ -274,6 +275,8 @@ const PriceSlider = ( { [ onChange, stepValue, minPriceInput, maxPriceInput ] ); + const debouncedUpdateQuery = useDebouncedCallback( onSubmit, 600 ); + const classes = classnames( 'wc-block-price-filter', 'wc-block-components-price-slider', @@ -433,8 +436,8 @@ const PriceSlider = ( { ) } - disabled={ disabled } - onClick={ onClick } - > -