Adds option to define filters inline width.

This commit is contained in:
mateuswetah 2024-06-14 10:44:00 -03:00
parent 900ed4e766
commit c03a9331db
9 changed files with 38 additions and 15 deletions

View File

@ -72,7 +72,7 @@
.wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters .fake-filter { .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters .fake-filter {
margin: 6px 12px; margin: 6px 12px;
display: inline-flex; display: inline-flex;
width: 16.666%; } width: var(--tainacan-filters-inline-width, 272px); }
.wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control .filters { .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control .filters {
flex: 0 1 var(--tainacan-filter-menu-width-theme, 20%); flex: 0 1 var(--tainacan-filter-menu-width-theme, 20%);
display: flex; display: flex;

File diff suppressed because one or more lines are too long

View File

@ -74,6 +74,9 @@
// Filter Menu Width when not a modal // Filter Menu Width when not a modal
--tainacan-filter-menu-width-theme: #{$filter-menu-width-theme}; --tainacan-filter-menu-width-theme: #{$filter-menu-width-theme};
// Each filter width when in horizontal panel
--tainacan-filters-inline-width: #{$filters-inline-width};
// One column is 1/24% and it is used a lot in the horizontal space distribution // One column is 1/24% and it is used a lot in the horizontal space distribution
--tainacan-one-column: #{$one-column}; --tainacan-one-column: #{$one-column};

View File

@ -145,6 +145,7 @@ $sidebar-width: 3.0em;
$subheader-height: 2.35em; $subheader-height: 2.35em;
$filter-menu-width: 16.666666667%; $filter-menu-width: 16.666666667%;
$filter-menu-width-theme: 20%; $filter-menu-width-theme: 20%;
$filters-inline-width: 272px;
$page-height: calc(100vh - 5.35em); $page-height: calc(100vh - 5.35em);
// Overall Pages padding: // Overall Pages padding:

View File

@ -224,6 +224,10 @@
"hideColllapseAllFiltersButton": { "hideColllapseAllFiltersButton": {
"type": "boolean", "type": "boolean",
"default": false "default": false
},
"filtersInlineWidth": {
"type": "number",
"default": 272
} }
}, },
"supports": { "supports": {

View File

@ -79,7 +79,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
collectionOrderByType, collectionOrderByType,
shouldNotHideFiltersOnMobile, shouldNotHideFiltersOnMobile,
displayFiltersHorizontally, displayFiltersHorizontally,
hideColllapseAllFiltersButton hideColllapseAllFiltersButton,
filtersInlineWidth
} = attributes; } = attributes;
// Gets blocks props from hook // Gets blocks props from hook
@ -600,13 +601,24 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
setAttributes( { baseFontSize: newFontSize } ); setAttributes( { baseFontSize: newFontSize } );
} } } }
/> />
<RangeControl { !displayFiltersHorizontally && !filtersAsModal ?
label={ __('Filters Area Width (%)', 'tainacan') } <RangeControl
value={ filtersAreaWidth } label={ __('Filters Area Width (%)', 'tainacan') }
onChange={ ( width ) => setAttributes( { filtersAreaWidth: width } ) } value={ filtersAreaWidth }
min={ 10 } onChange={ ( width ) => setAttributes( { filtersAreaWidth: width } ) }
max={ 40 } min={ 10 }
/> max={ 40 }
/>
: null }
{ displayFiltersHorizontally ?
<RangeControl
label={ __('Filters Inline Width (px)', 'tainacan') }
value={ filtersInlineWidth }
onChange={ ( width ) => setAttributes( { filtersInlineWidth: width } ) }
min={ 100 }
max={ 800 }
/>
: null }
</PanelBody> </PanelBody>
<PanelBody <PanelBody
title={__('Colors', 'tainacan')} title={__('Colors', 'tainacan')}
@ -846,6 +858,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
style={{ style={{
'--tainacan-background-color': backgroundColor, '--tainacan-background-color': backgroundColor,
'--tainacan-filter-menu-width-theme': filtersAreaWidth + '%', '--tainacan-filter-menu-width-theme': filtersAreaWidth + '%',
'--tainacan-filters-inline-width': filtersInlineWidth + 'px',
'--tainacan-input-color': inputColor, '--tainacan-input-color': inputColor,
'--tainacan-input-background-color': inputBackgroundColor, '--tainacan-input-background-color': inputBackgroundColor,
'--tainacan-input-border-color': inputBorderColor, '--tainacan-input-border-color': inputBorderColor,

View File

@ -51,7 +51,8 @@ export default function({ attributes }) {
collectionOrderByMeta, collectionOrderByMeta,
collectionOrderByType, collectionOrderByType,
shouldNotHideFiltersOnMobile, shouldNotHideFiltersOnMobile,
displayFiltersHorizontally displayFiltersHorizontally,
filtersInlineWidth
} = attributes; } = attributes;
let updatedListType = '' + listType; let updatedListType = '' + listType;
@ -70,6 +71,7 @@ export default function({ attributes }) {
'--tainacan-base-font-size': baseFontSize + 'px', '--tainacan-base-font-size': baseFontSize + 'px',
'--tainacan-background-color': backgroundColor, '--tainacan-background-color': backgroundColor,
'--tainacan-filter-menu-width-theme': filtersAreaWidth + '%', '--tainacan-filter-menu-width-theme': filtersAreaWidth + '%',
'--tainacan-filters-inline-width': filtersInlineWidth + 'px',
'--tainacan-input-color': inputColor, '--tainacan-input-color': inputColor,
'--tainacan-input-background-color': inputBackgroundColor, '--tainacan-input-background-color': inputBackgroundColor,
'--tainacan-input-border-color': inputBorderColor, '--tainacan-input-border-color': inputBorderColor,

View File

@ -78,7 +78,7 @@
.fake-filter { .fake-filter {
margin: 6px 12px; margin: 6px 12px;
display: inline-flex; display: inline-flex;
width: 16.666%; width: var(--tainacan-filters-inline-width, 272px);
} }
} }
} }

View File

@ -190,11 +190,11 @@
} }
.filter-item-forms { .filter-item-forms {
width: 100%; width: 100%;
min-width: 272px; min-width: var(--tainacan-filters-inline-width, 272px);
break-inside: avoid; break-inside: avoid;
display: inline-block; display: inline-block;
vertical-align: text-top; vertical-align: text-top;
margin-bottom: 12px; margin-bottom: 1rem;
} }
@media screen and (min-width: 769px) { @media screen and (min-width: 769px) {
@ -202,7 +202,7 @@
margin-right: 2.25em; margin-right: 2.25em;
} }
.filter-item-forms { .filter-item-forms {
width: 272px; width: var(--tainacan-filters-inline-width, 272px);
} }
.filter-item-forms:not(:last-child) { .filter-item-forms:not(:last-child) {
margin-right: 2.25em; margin-right: 2.25em;