Skip to content

Commit

Permalink
fix #800
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Jul 4, 2024
1 parent 124d633 commit c82108f
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/blocks/child-pages/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"type": "string",
"default": "rich-media"
},
"gap": {
"type": "string",
"default": ""
},
"smCols": {
"type": "number",
"default": 0
Expand Down
77 changes: 76 additions & 1 deletion src/blocks/child-pages/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import { toNumber } from '@smb/helper';

import metadata from './block.json';

export default function ( { attributes, setAttributes } ) {
export default function ( { attributes, setAttributes, clientId } ) {
const {
title,
layout,
gap,
smCols,
itemTitleTagName,
itemThumbnailSizeSlug,
Expand All @@ -50,6 +51,21 @@ export default function ( { attributes, setAttributes } ) {

const itemTitleTagNames = [ 'h2', 'h3', 'h4' ];

const gapOptions = [
{
label: 'S',
value: 1,
},
{
label: 'M',
value: 2,
},
{
label: 'L',
value: 3,
},
];

return (
<>
<InspectorControls>
Expand Down Expand Up @@ -463,6 +479,65 @@ export default function ( { attributes, setAttributes } ) {
</ToolsPanel>
</InspectorControls>

<InspectorControls group="dimensions">
<ToolsPanelItem
hasValue={ () => gap !== metadata.attributes.gap.default }
isShownByDefault
label={ __(
'The gap between each item',
'snow-monkey-blocks'
) }
onDeselect={ () =>
setAttributes( {
gap: metadata.attributes.gap.default,
} )
}
panelId={ clientId }
>
<BaseControl
id="snow-monkey-blocks/child-pages/gap"
label={ __(
'The gap between each item',
'snow-monkey-blocks'
) }
className="spacing-sizes-control"
>
<RangeControl
className="spacing-sizes-control__range-control"
value={
gapOptions.filter(
( option ) =>
option.label?.toLowerCase() === gap
)?.[ 0 ]?.value
}
resetFallbackValue={ undefined }
onChange={ ( value ) =>
setAttributes( {
gap: gapOptions
.filter(
( option ) => option.value === value
)?.[ 0 ]
?.label?.toLowerCase(),
} )
}
withInputField={ false }
min={ 1 }
max={ 3 }
marks
renderTooltipContent={ ( _value ) =>
gapOptions
.filter(
( option ) => option.value === _value
)?.[ 0 ]
?.label?.toUpperCase()
}
hideLabelFromVision
__nextHasNoMarginBottom
/>
</BaseControl>
</ToolsPanelItem>
</InspectorControls>

<div { ...useBlockProps() }>
<Disabled>
<ServerSideRender
Expand Down
2 changes: 2 additions & 0 deletions src/blocks/child-pages/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'_context' => 'snow-monkey-blocks/child-pages',
'_parent_id' => $parent_id,
'_entries_layout' => $attributes['layout'],
'_entries_gap' => $attributes['gap'],
'_force_sm_1col' => $force_sm_1col,
'_item_thumbnail_size' => $attributes['itemThumbnailSizeSlug'],
'_item_title_tag' => $attributes['itemTitleTagName'],
Expand All @@ -65,6 +66,7 @@
'_context' => 'snow-monkey-blocks/child-pages',
'_parent_id' => ! empty( $attributes['parent']['id'] ) ? $attributes['parent']['id'] : get_the_ID(),
'_entries_layout' => $attributes['layout'],
'_entries_gap' => $attributes['gap'],
'_force_sm_1col' => $force_sm_1col,
'_item_thumbnail_size' => $attributes['itemThumbnailSizeSlug'],
'_item_title_tag' => $attributes['itemTitleTagName'],
Expand Down
9 changes: 9 additions & 0 deletions src/css/blocks-editor-wrapper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
.block-editor-link-control__search-enter {
right: 0;
}

.block-editor-link-control__search-results {
margin-top: 8px;
padding: 0;
}

.components-button.has-icon.has-text {
padding: 4px 0;
}
}
}

Expand Down

0 comments on commit c82108f

Please sign in to comment.