From d72cc23e7501010e52d0c4b4f437c0038f627524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dante=20=C3=81lvarez?= <89805481+danalvrz@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:57:27 -0600 Subject: [PATCH] hide search block fields (#213) Co-authored-by: David Glick --- news/213.bugfix | 1 + .../Blocks/Search/TopSideFacets.jsx | 60 ++++++++++--------- src/components/Blocks/Search/schema.js | 6 ++ src/index.js | 22 ++++--- src/theme/_layout.scss | 2 + src/theme/blocks/_search.scss | 19 ++++++ 6 files changed, 73 insertions(+), 37 deletions(-) create mode 100644 news/213.bugfix create mode 100644 src/components/Blocks/Search/schema.js diff --git a/news/213.bugfix b/news/213.bugfix new file mode 100644 index 00000000..fddb4cd6 --- /dev/null +++ b/news/213.bugfix @@ -0,0 +1 @@ +Hide unnecessary Search block fields. @danalvrz \ No newline at end of file diff --git a/src/components/Blocks/Search/TopSideFacets.jsx b/src/components/Blocks/Search/TopSideFacets.jsx index 1747f696..be8a6018 100644 --- a/src/components/Blocks/Search/TopSideFacets.jsx +++ b/src/components/Blocks/Search/TopSideFacets.jsx @@ -81,35 +81,37 @@ const TopSideFacets = (props) => { total={totalItems} as="h5" /> -
- - {intl.formatMessage(messages.sort)} - - { - flushSync(() => { - setSortOn(sortOn); - onTriggerSearch(searchedText || '', facets, sortOn); - }); - }} - setSortOrder={(sortOrder) => { - flushSync(() => { - setSortOrder(sortOrder); - onTriggerSearch( - searchedText || '', - facets, - sortOn, - sortOrder, - ); - }); - }} - /> -
+ {data.sortOnOptions && data.sortOnOptions.length > 0 && ( +
+ + {intl.formatMessage(messages.sort)} + + { + flushSync(() => { + setSortOn(sortOn); + onTriggerSearch(searchedText || '', facets, sortOn); + }); + }} + setSortOrder={(sortOrder) => { + flushSync(() => { + setSortOrder(sortOrder); + onTriggerSearch( + searchedText || '', + facets, + sortOn, + sortOrder, + ); + }); + }} + /> +
+ )} )} diff --git a/src/components/Blocks/Search/schema.js b/src/components/Blocks/Search/schema.js new file mode 100644 index 00000000..a5ca3afb --- /dev/null +++ b/src/components/Blocks/Search/schema.js @@ -0,0 +1,6 @@ +export const searchBlockSchemaEnhancer = ({ schema, formData, intl }) => { + schema.properties.showSortOn.default = true; + schema.fieldsets = schema.fieldsets.filter((item) => item.id !== 'views'); + + return schema; +}; diff --git a/src/index.js b/src/index.js index 13caf0db..bc2620b5 100644 --- a/src/index.js +++ b/src/index.js @@ -20,6 +20,8 @@ import { ImageBlockDataAdapter } from './components/Blocks/Image/adapter'; import { AccordionSchemaEnhancer } from './components/Blocks/Accordion/schema'; +import { searchBlockSchemaEnhancer } from './components/Blocks/Search/schema'; + import gridSVG from './icons/block_icn_grid.svg'; import accordionSVG from './icons/block_icn_accordion.svg'; import EventView from './components/Theme/EventView'; @@ -264,14 +266,18 @@ const applyConfig = (config) => { schemaEnhancer: defaultStylingSchema, }; - config.blocks.blocksConfig.search.variations = [ - { - id: 'facetsTopSide', - title: 'Facets on top', - view: TopSideFacets, - isDefault: true, - }, - ]; + config.blocks.blocksConfig.search = { + ...config.blocks.blocksConfig.search, + schemaEnhancer: searchBlockSchemaEnhancer, + variations: [ + { + id: 'facetsTopSide', + title: 'Facets on top', + view: TopSideFacets, + isDefault: true, + }, + ], + }; config.blocks.blocksConfig.__button = { ...config.blocks.blocksConfig.__button, diff --git a/src/theme/_layout.scss b/src/theme/_layout.scss index fe4db64d..e83b1695 100644 --- a/src/theme/_layout.scss +++ b/src/theme/_layout.scss @@ -266,6 +266,8 @@ footer { .block.heading .heading-wrapper, .block-editor-listing .items, .block-editor-listing .listing.message, + .block-editor-search .listing-item, + .block-editor-search .search-input-resultscount-sort, .block-editor-separator.has--align--full .block.separator, .block-editor-separator .block.separator.has--align--full, .block.teaser.has--align--center, diff --git a/src/theme/blocks/_search.scss b/src/theme/blocks/_search.scss index 38a71f2a..699a4938 100644 --- a/src/theme/blocks/_search.scss +++ b/src/theme/blocks/_search.scss @@ -6,6 +6,11 @@ .card-container > img { width: 100% !important; } + + .listing-item:last-child { + padding-bottom: 0; + border-bottom: none; + } } .items { padding: 0 !important; @@ -23,6 +28,10 @@ color: $black; @include text-heading-h2(); } + &:last-child { + padding-bottom: 40px; + border-bottom: 1px solid $black; + } &:not(.grid) { img { @@ -240,3 +249,13 @@ } } } + +// Hidden fields +.inline.field { + &.field-wrapper-showSearchInput, + &.field-wrapper-showSearchButton, + &.field-wrapper-showTotalResults, + &.field-wrapper-showSortOn { + display: none; + } +}