Skip to content

Commit

Permalink
Merge pull request #22 from eighteen73/feature/carousel-improvements
Browse files Browse the repository at this point in the history
Feature/carousel improvements
  • Loading branch information
brettsmason authored Sep 4, 2024
2 parents d236a2d + 1e00656 commit 46548d1
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 69 deletions.
9 changes: 7 additions & 2 deletions dist/carousel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@
false
]
},
"allowedBlocks": {
"type": "array"
"allowedBlock": {
"type": "string",
"default": "pulsar/carousel-slide"
},
"disabledControls": {
"type": "boolean",
"default": false
}
},
"usesContext": [
Expand Down
2 changes: 1 addition & 1 deletion dist/carousel/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '78471dc35de435e2208f');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'd00ff3f5faa94a8ac399');
2 changes: 1 addition & 1 deletion dist/carousel/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pulsar-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: A collection of blocks we use at eighteen73.
* Requires at least: 6.3
* Requires PHP: 7.4
* Version: 0.6.2
* Version: 0.7.0
* Author: eighteen73
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
11 changes: 8 additions & 3 deletions src/carousel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@
"type": [ "string", "boolean" ],
"enum": [ "all", "insert", "contentOnly", false ]
},
"allowedBlocks": {
"type": "array"
}
"allowedBlock": {
"type": "string",
"default": "pulsar/carousel-slide"
},
"disabledControls": {
"type": "boolean",
"default": false
}
},
"usesContext": [
"isLinked"
Expand Down
112 changes: 59 additions & 53 deletions src/carousel/components/inspector-controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,67 +11,73 @@ export default function CarouselInspectorControls({
attributes,
context,
}) {
const { carouselOptions, advancedCarouselOptions, mergeOptions } =
attributes;
const {
carouselOptions,
advancedCarouselOptions,
mergeOptions,
disabledControls,
} = attributes;

const isDisabled = advancedCarouselOptions && !mergeOptions;

return (
<>
<InspectorControls>
<PanelBody title={__('Settings', 'pulsar-blocks')}>
<GlobalControls
onChange={onChange}
attributes={attributes}
context={context}
isDisabled={isDisabled}
></GlobalControls>
</PanelBody>
!disabledControls && (
<>
<InspectorControls>
<PanelBody title={__('Settings', 'pulsar-blocks')}>
<GlobalControls
onChange={onChange}
attributes={attributes}
context={context}
isDisabled={isDisabled}
></GlobalControls>
</PanelBody>

<PanelBody
title={__('Desktop settings', 'pulsar-blocks')}
initialOpen={true}
>
<BreakpointControls
onChange={onChange}
carouselOptions={carouselOptions}
size={false}
isDisabled={isDisabled}
/>
</PanelBody>
<PanelBody
title={__('Desktop settings', 'pulsar-blocks')}
initialOpen={true}
>
<BreakpointControls
onChange={onChange}
carouselOptions={carouselOptions}
size={false}
isDisabled={isDisabled}
/>
</PanelBody>

<PanelBody
title={__('Tablet settings', 'pulsar-blocks')}
initialOpen={false}
>
<BreakpointControls
onChange={onChange}
carouselOptions={carouselOptions}
size={1024}
isDisabled={isDisabled}
/>
</PanelBody>
<PanelBody
title={__('Tablet settings', 'pulsar-blocks')}
initialOpen={false}
>
<BreakpointControls
onChange={onChange}
carouselOptions={carouselOptions}
size={1024}
isDisabled={isDisabled}
/>
</PanelBody>

<PanelBody
title={__('Mobile settings', 'pulsar-blocks')}
initialOpen={false}
>
<BreakpointControls
onChange={onChange}
carouselOptions={carouselOptions}
size={640}
isDisabled={isDisabled}
/>
</PanelBody>
</InspectorControls>

<PanelBody
title={__('Mobile settings', 'pulsar-blocks')}
initialOpen={false}
>
<BreakpointControls
<InspectorControls group="advanced">
<AdvancedControls
onChange={onChange}
carouselOptions={carouselOptions}
size={640}
isDisabled={isDisabled}
advancedCarouselOptions={advancedCarouselOptions}
mergeOptions={mergeOptions}
/>
</PanelBody>
</InspectorControls>

<InspectorControls group="advanced">
<AdvancedControls
onChange={onChange}
advancedCarouselOptions={advancedCarouselOptions}
mergeOptions={mergeOptions}
/>
</InspectorControls>
</>
</InspectorControls>
</>
)
);
}
11 changes: 7 additions & 4 deletions src/carousel/components/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { Placeholder } from '@wordpress/components';
import SingleBlockTypeAppender from '../../components/single-block-type-appender';
import { Carousel as Icon } from '../../components/icons';

export default function CarouselPlaceholder({ clientId, children }) {
export default function CarouselPlaceholder({
allowedBlock,
clientId,
children,
}) {
return (
<Placeholder
icon={Icon}
Expand All @@ -18,9 +22,8 @@ export default function CarouselPlaceholder({ clientId, children }) {
>
<SingleBlockTypeAppender
onClickAfter={() => {}}
variant="primary"
text={__('Add slide', 'pulsar-blocks')}
allowedBlock="pulsar/carousel-slide"
variant="secondary"
allowedBlock={allowedBlock}
clientId={clientId}
isEnabled={true}
style={{ alignSelf: 'center' }}
Expand Down
10 changes: 6 additions & 4 deletions src/carousel/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Edit({
mergeOptions,
ariaLabel,
hasTrack,
allowedBlocks,
allowedBlock,
template,
templateLock,
} = attributes;
Expand All @@ -54,7 +54,6 @@ export default function Edit({
const blockProps = useBlockProps();
const { children, ...innerBlocksProps } = useInnerBlocksProps(blockProps, {
orientation: 'horizontal',
allowedBlocks,
template,
templateLock,
renderAppender: false,
Expand Down Expand Up @@ -186,7 +185,10 @@ export default function Edit({

<div {...innerBlocksProps}>
{!isReady || innerBlocks.length === 0 ? (
<CarouselPlaceholder clientId={clientId}>
<CarouselPlaceholder
allowedBlock={allowedBlock}
clientId={clientId}
>
{children}
</CarouselPlaceholder>
) : (
Expand Down Expand Up @@ -229,7 +231,7 @@ export default function Edit({
}}
variant="secondary"
text={__('Add slide', 'pulsar-blocks')}
allowedBlock="pulsar/carousel-slide"
allowedBlock={allowedBlock}
style={{ width: '100%', justifyContent: 'center' }}
clientId={clientId}
isEnabled={
Expand Down

0 comments on commit 46548d1

Please sign in to comment.