Block control adjustments to facets blocks. #399

This commit is contained in:
mateuswetah 2020-07-10 15:10:11 -03:00
parent ecd617e75e
commit fc80421e61
6 changed files with 69 additions and 175 deletions

View File

@ -7,33 +7,6 @@
--tainacan-block-gray5: #454647;
--tainacan-block-primary: #298596; }
[data-align='full'] .tainacan-block-control {
width: calc(100% + 14px); }
.tainacan-block-control {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 5px;
position: relative;
top: -14px;
left: -14px;
width: calc(100% + 28px);
background: var(--tainacan-block-gray1, #f2f2f2); }
.tainacan-block-control p {
font-size: 0.875em !important;
margin: 12px 1.5em !important;
fill: var(--tainacan-block-gray4, #555758); }
.tainacan-block-control p svg {
top: 6px;
margin-right: 0.75em;
position: relative;
fill: var(--tainacan-block-gray4, #555758); }
.tainacan-block-control .components-base-control .components-base-control__field {
margin-bottom: 0; }
.tainacan-block-placeholder.components-placeholder {
align-items: center !important;
margin-bottom: 0 !important;

View File

@ -1,6 +1,6 @@
{
"version": 3,
"mappings": "AAIA,KAAM;EACF,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,sBAAsB,CAAC,QAAU;EACjC,wBAAwB,CAAC,QAAY;;AAIzC,2CAA4C;EACxC,KAAK,EAAE,iBAAiB;;AAE5B,uBAAwB;EACpB,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI;EACf,cAAc,EAAE,GAAG;EACnB,eAAe,EAAE,MAAM;EACvB,WAAW,EAAE,MAAM;EACnB,OAAO,EAAE,GAAG;EACZ,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,KAAK;EACV,IAAI,EAAE,KAAK;EACX,KAAK,EAAE,iBAAiB;EACxB,UAAU,EAAE,oCAAmC;EAE/C,yBAAE;IACE,SAAS,EAAE,kBAAkB;IAC7B,MAAM,EAAE,qBAAqB;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B,QAAQ,EAAE,MAAM;MAChB,YAAY,EAAE,GAAG;IAGrB;uHAAyC;MACrC,IAAI,EAAE,KAAK;IAGf;;;gHACkC;MAC9B,OAAO,EAAE,IAAI;MACb,eAAe,EAAE,UAAU;MAE3B;;;sHAAI;QACA,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;MAEtB;;;wHAAM;QACF,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,QAAQ;QACvB,QAAQ,EAAE,MAAM;QAChB,OAAO,EAAE,YAAY;QACrB,SAAS,EAAE,GAAG;QAEd,yCAA0C;UAP9C;;;4HAAM;YAO0C,SAAS,EAAE,GAAG;EAItE,gDAAwB;IACpB,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,MAAM;IAEvB,kDAAE;MACE,KAAK,EAAE,oCAAmC;MAC1C,YAAY,EAAE,IAAI;MAClB,UAAU,EAAE,GAAG;EAGvB,2CAAmB;IACf,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,aAAa;IAC9B,OAAO,EAAE,gBAAgB;IACzB,MAAM,EAAE,OAAO;IAEf,6CAAE;MACE,OAAO,EAAE,MAAM;MACf,KAAK,EAAE,oCAAmC",
"sources": ["../../views/gutenberg-blocks/gutenberg-blocks-style.scss","../../views/gutenberg-blocks/gutenberg-blocks-variables.scss"],
"names": [],
"file": "tainacan-gutenberg-block-common-styles.css"

View File

@ -13,39 +13,6 @@
}
// Control and placeholder region ----------------------------------------------------
[data-align='full'] .tainacan-block-control {
width: calc(100% + 14px);
}
.tainacan-block-control {
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 5px;
position: relative;
top: -14px;
left: -14px;
width: calc(100% + 28px);
background: var(--tainacan-block-gray1, $gray1);
p {
font-size: 0.875em !important;
margin: 12px 1.5em !important;
fill: var(--tainacan-block-gray4, $gray4);
svg {
top: 6px;
margin-right: 0.75em;
position: relative;
fill: var(--tainacan-block-gray4, $gray4);
}
}
.components-base-control .components-base-control__field {
margin-bottom: 0;
}
}
.tainacan-block-placeholder.components-placeholder {
align-items: center !important;
margin-bottom: 0 !important;

View File

@ -756,66 +756,6 @@ registerBlockType('tainacan/faceted-search', {
</InspectorControls>
</div>
{ isSelected ?
(
<div>
<div className="tainacan-block-control">
<p style={{ display: 'flex', alignItems: 'baseline' }}>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 6.3499998 6.3499998"
height="24px"
width="24px">
<g transform="matrix(0.2891908,0,0,0.2891908,-30.465367,-38.43427)">
<path
transform="matrix(0.26458333,0,0,0.26458333,104.32258,131.88168)"
fill="var(--tainacan-block-primary, $primary)"
d="M 16.662109,14.712891 V 24.927734 H 84.753906 V 14.712891 Z m 6.810547,17.021484 v 9.748047 c 6.857764,2.272819 11.798639,8.605281 11.798828,16.078125 -7.56e-4,2.313298 -0.496344,4.586348 -1.421875,6.693359 l 8.375,8.375 -3.365234,3.367188 H 77.945312 V 31.734375 Z m 17.019532,10.216797 h 20.429687 v 10.21289 H 40.492188 Z m -22.835938,3.84375 a 9.1779065,9.1779065 0 0 0 -0.916016,0.03906 11.753475,11.753475 0 0 0 1.671875,23.445313 11.455635,11.455635 0 0 0 6.466797,-1.910156 l 1.908203,1.910156 2.88086,2.982422 3.820312,3.716797 3.347657,-3.347657 -3.851563,-3.855468 -2.847656,-2.845703 -1.941407,-1.941407 a 11.455635,11.455635 0 0 0 1.941407,-6.433593 11.723603,11.723603 0 0 0 -6.697266,-10.583985 11.422139,11.422139 0 0 0 -5.027344,-1.136719 9.1779065,9.1779065 0 0 0 -0.755859,-0.03906 z m 0.755859,6.736328 a 5.0244015,5.0244015 0 0 1 5.027344,5.025391 v 0.101562 a 5.0244015,5.0244015 0 0 1 -0.269531,1.570313 4.9574094,4.9574094 0 0 1 -4.757813,3.351562 5.0244015,5.0244015 0 0 1 -1.671875,-9.746094 4.6559456,4.6559456 0 0 1 1.671875,-0.302734 z m 6.376953,20.601562 c -0.431168,0.183308 -0.872311,0.335613 -1.316406,0.484376 v 2.378906 h 4.179688 z "/>
</g>
</svg>
{__('Show items list from: ', 'tainacan')}
&nbsp;
<SelectControl
label={ __('Items list source', 'tainacan') }
hideLabelFromVision
value={ listType }
options={ [
{ label: __('a Collection', 'tainacan'), value: 'collection' },
{ label: __('a Taxonomy Term', 'tainacan'), value: 'term' },
{ label: __('the Repository', 'tainacan'), value: 'repository' },
] }
onChange={ ( aListType) => {
listType = aListType;
if (listType != 'collection') {
enabledViewModes = registeredViewModesKeys;
defaultViewMode = 'masonry';
}
setAttributes({
listType: aListType,
enabledViewModes: enabledViewModes,
defaultViewMode: defaultViewMode
});
} }
/>
&nbsp;
{
(listType == 'collection' && collectionId != undefined) || (listType == 'term' && termId != undefined) ?
<Button
isPrimary
type="submit"
onClick={ () => listType == 'term' ? openTermModal() : openCollectionModal() }>
{ listType == 'term' ? __('Change Term', 'tainacan') : __('Change Collection', 'tainacan') }
</Button>
: null
}
</p>
</div>
</div>
) : null
}
{ ( termId == undefined && listType == 'term' ) || ( collectionId == undefined && listType == 'collection' ) ? (
<Placeholder
className="tainacan-block-placeholder"
@ -838,8 +778,33 @@ registerBlockType('tainacan/faceted-search', {
d="M 16.662109,14.712891 V 24.927734 H 84.753906 V 14.712891 Z m 6.810547,17.021484 v 9.748047 c 6.857764,2.272819 11.798639,8.605281 11.798828,16.078125 -7.56e-4,2.313298 -0.496344,4.586348 -1.421875,6.693359 l 8.375,8.375 -3.365234,3.367188 H 77.945312 V 31.734375 Z m 17.019532,10.216797 h 20.429687 v 10.21289 H 40.492188 Z m -22.835938,3.84375 a 9.1779065,9.1779065 0 0 0 -0.916016,0.03906 11.753475,11.753475 0 0 0 1.671875,23.445313 11.455635,11.455635 0 0 0 6.466797,-1.910156 l 1.908203,1.910156 2.88086,2.982422 3.820312,3.716797 3.347657,-3.347657 -3.851563,-3.855468 -2.847656,-2.845703 -1.941407,-1.941407 a 11.455635,11.455635 0 0 0 1.941407,-6.433593 11.723603,11.723603 0 0 0 -6.697266,-10.583985 11.422139,11.422139 0 0 0 -5.027344,-1.136719 9.1779065,9.1779065 0 0 0 -0.755859,-0.03906 z m 0.755859,6.736328 a 5.0244015,5.0244015 0 0 1 5.027344,5.025391 v 0.101562 a 5.0244015,5.0244015 0 0 1 -0.269531,1.570313 4.9574094,4.9574094 0 0 1 -4.757813,3.351562 5.0244015,5.0244015 0 0 1 -1.671875,-9.746094 4.6559456,4.6559456 0 0 1 1.671875,-0.302734 z m 6.376953,20.601562 c -0.431168,0.183308 -0.872311,0.335613 -1.316406,0.484376 v 2.378906 h 4.179688 z "/>
</g>
</svg>
{__('Show a complete items list with faceted search.', 'tainacan')}
{__('Show a complete items list with faceted search from: ', 'tainacan')}
</p>
<SelectControl
label={ __('Items list source', 'tainacan') }
hideLabelFromVision
value={ listType }
options={ [
{ label: __('a Collection', 'tainacan'), value: 'collection' },
{ label: __('a Taxonomy Term', 'tainacan'), value: 'term' },
{ label: __('the Repository', 'tainacan'), value: 'repository' },
] }
onChange={ ( aListType) => {
listType = aListType;
if (listType != 'collection') {
enabledViewModes = registeredViewModesKeys;
defaultViewMode = 'masonry';
}
setAttributes({
listType: aListType,
enabledViewModes: enabledViewModes,
defaultViewMode: defaultViewMode
});
} }
/>
&nbsp;
<Button
isPrimary
type="submit"

View File

@ -2,7 +2,7 @@ const { registerBlockType } = wp.blocks;
const { __ } = wp.i18n;
const { BaseControl, RangeControl, Spinner, Button, ToggleControl, Tooltip, Placeholder, Toolbar, PanelBody } = wp.components;
const { BaseControl, RangeControl, Spinner, Button, ToggleControl, Tooltip, Placeholder, Toolbar, ToolbarButton, PanelBody } = wp.components;
const { InspectorControls, BlockControls } = wp.editor;
@ -380,6 +380,23 @@ registerBlockType('tainacan/facets-list', {
<div>
<BlockControls>
<Toolbar controls={ layoutControls } />
{ facets.length ? (
<Toolbar>
<ToolbarButton onClick={ () => openMetadataModal() }>
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<path d="M21.43,13.64,19.32,16a2.57,2.57,0,0,1-2,1H11a3.91,3.91,0,0,0,0-.49,5.49,5.49,0,0,0-5-5.47V9.64A2.59,2.59,0,0,1,8.59,7H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,13.64ZM4,3A2,2,0,0,0,2,5v7.3a5.32,5.32,0,0,1,2-1V5H16V3ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1,0-7,2.74,2.74,0,0,1,.5,0A3.5,3.5,0,0,1,9,16a2.92,2.92,0,0,1,0,.51,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,1,0,5.5,18,1.5,1.5,0,0,0,7,16.53Z"/>
</svg>
</p>&nbsp;
{__('Select facets', 'tainacan')}
</ToolbarButton>
</Toolbar>
): null
}
</BlockControls>
</div>
@ -578,28 +595,6 @@ registerBlockType('tainacan/facets-list', {
onCancelSelection={ () => setAttributes({ isParentTermModalOpen: false }) }/>
: null
}
{ facets.length ? (
<div className="tainacan-block-control">
<p>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
height="24px"
width="24px">
<path d="M21.43,13.64,19.32,16a2.57,2.57,0,0,1-2,1H11a3.91,3.91,0,0,0,0-.49,5.49,5.49,0,0,0-5-5.47V9.64A2.59,2.59,0,0,1,8.59,7H17.3a2.57,2.57,0,0,1,2,1l2.11,2.38A2.59,2.59,0,0,1,21.43,13.64ZM4,3A2,2,0,0,0,2,5v7.3a5.32,5.32,0,0,1,2-1V5H16V3ZM11,21l-1,1L8.86,20.89,8,20H8l-.57-.57A3.42,3.42,0,0,1,5.5,20a3.5,3.5,0,0,1,0-7,2.74,2.74,0,0,1,.5,0A3.5,3.5,0,0,1,9,16a2.92,2.92,0,0,1,0,.51,3.42,3.42,0,0,1-.58,1.92L9,19H9l.85.85Zm-4-4.5A1.5,1.5,0,1,0,5.5,18,1.5,1.5,0,0,0,7,16.53Z"/>
</svg>
{__('List facets from a Tainacan Collection or Repository', 'tainacan')}
</p>
<Button
isPrimary
type="submit"
onClick={ () => openMetadataModal() }>
{__('Select facets', 'tainacan')}
</Button>
</div>
): null
}
</div>
) : null
}

View File

@ -2,7 +2,7 @@ const { registerBlockType } = wp.blocks;
const { __ } = wp.i18n;
const { RangeControl, TextControl, Toolbar, SelectControl, Button, ToggleControl, Placeholder, ColorPicker, ColorPalette, BaseControl, PanelBody } = wp.components;
const { RangeControl, TextControl, Toolbar, ToolbarButton, SelectControl, Button, ToggleControl, Placeholder, ColorPicker, ColorPalette, BaseControl, PanelBody } = wp.components;
const { InspectorControls, BlockControls } = wp.editor;
@ -31,7 +31,8 @@ registerBlockType('tainacan/search-bar', {
description: __('Set up a custom search bar to redirect to an item\'s list', 'tainacan'),
example: {
attributes: {
content: 'preview'
collectionId: 'default',
collectionSlug: 'preview'
}
},
attributes: {
@ -316,6 +317,27 @@ registerBlockType('tainacan/search-bar', {
<div>
<BlockControls>
<Toolbar controls={ alignmentControls } />
{ collectionId ? (
<ToolbarButton onClick={ () => openSearchBarModal() }>
<p>
<span class="icon">
<i>
<svg width="24" height="24" viewBox="-2 -4 20 20">
<path d="M0,5.8C0,5,0.2,4.2,0.5,3.5s0.7-1.3,1.2-1.8s1.1-0.9,1.8-1.2C4.2,0.1,5,0,5.8,0S7.3,0.1,8,0.5
c0.7,0.3,1.3,0.7,1.8,1.2s0.9,1.1,1.2,1.8c0.5,1.2,0.5,2.5,0.2,3.7c0,0.2-0.1,0.4-0.2,0.6c0,0.1-0.2,0.6-0.2,0.6
c0.6,0.6,1.3,1.3,1.9,1.9c0.7,0.7,1.3,1.3,2,2c0,0,0.3,0.2,0.3,0.3c0,0.3-0.1,0.7-0.3,1c-0.2,0.6-0.8,1-1.4,1.2
c-0.1,0-0.6,0.2-0.6,0.1c0,0-4.2-4.2-4.2-4.2c0,0-0.8,0.3-0.8,0.4c-1.3,0.4-2.8,0.5-4.1-0.1c-0.7-0.3-1.3-0.7-1.8-1.2
C1.2,9.3,0.8,8.7,0.5,8S0,6.6,0,5.8z M1.6,5.8c0,0.4,0.1,0.9,0.2,1.3C2.1,8.2,3,9.2,4.1,9.6c0.5,0.2,1,0.3,1.6,0.3
c0.6,0,1.1-0.1,1.6-0.3C8.7,9,9.7,7.6,9.8,6c0.1-1.5-0.6-3.1-2-3.9c-0.9-0.5-2-0.6-3-0.4C4.6,1.8,4.4,1.9,4.1,2
c-0.5,0.2-1,0.5-1.4,0.9C2,3.7,1.6,4.7,1.6,5.8z"/>
</svg>
</i>
</span>
</p>&nbsp;
{__('Configure search source', 'tainacan')}
</ToolbarButton>
): null
}
</BlockControls>
</div>
@ -471,34 +493,6 @@ registerBlockType('tainacan/search-bar', {
onCancelSelection={ () => setAttributes({ isModalOpen: false }) }/>
: null
}
{ collectionId ? (
<div className="tainacan-block-control">
<p>
<span class="icon">
<i>
<svg width="24" height="24" viewBox="-2 -2 20 20">
<path d="M0,5.8C0,5,0.2,4.2,0.5,3.5s0.7-1.3,1.2-1.8s1.1-0.9,1.8-1.2C4.2,0.1,5,0,5.8,0S7.3,0.1,8,0.5
c0.7,0.3,1.3,0.7,1.8,1.2s0.9,1.1,1.2,1.8c0.5,1.2,0.5,2.5,0.2,3.7c0,0.2-0.1,0.4-0.2,0.6c0,0.1-0.2,0.6-0.2,0.6
c0.6,0.6,1.3,1.3,1.9,1.9c0.7,0.7,1.3,1.3,2,2c0,0,0.3,0.2,0.3,0.3c0,0.3-0.1,0.7-0.3,1c-0.2,0.6-0.8,1-1.4,1.2
c-0.1,0-0.6,0.2-0.6,0.1c0,0-4.2-4.2-4.2-4.2c0,0-0.8,0.3-0.8,0.4c-1.3,0.4-2.8,0.5-4.1-0.1c-0.7-0.3-1.3-0.7-1.8-1.2
C1.2,9.3,0.8,8.7,0.5,8S0,6.6,0,5.8z M1.6,5.8c0,0.4,0.1,0.9,0.2,1.3C2.1,8.2,3,9.2,4.1,9.6c0.5,0.2,1,0.3,1.6,0.3
c0.6,0,1.1-0.1,1.6-0.3C8.7,9,9.7,7.6,9.8,6c0.1-1.5-0.6-3.1-2-3.9c-0.9-0.5-2-0.6-3-0.4C4.6,1.8,4.4,1.9,4.1,2
c-0.5,0.2-1,0.5-1.4,0.9C2,3.7,1.6,4.7,1.6,5.8z"/>
</svg>
</i>
</span>
{__('Set up a custom search bar to redirect to an item\'s list', 'tainacan')}
</p>
<Button
isPrimary
type="submit"
onClick={ () => openSearchBarModal() }>
{__('Configure search source', 'tainacan')}
</Button>
</div>
): null
}
</div>
) : null
}