Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions inc/css/blocks/class-icon-list-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public function render_css( $block ) {
'property' => '--gap-icon-label',
'value' => 'gapIconLabel',
),
array(
'property' => '--sublist-indent',
'value' => 'sublistIndent',
'unit' => 'px',
'condition' => function ( $attrs ) {
return isset( $attrs['sublistIndent'] ) && is_numeric( $attrs['sublistIndent'] );
},
),
array(
'property' => '--sublist-indent',
'value' => 'sublistIndent',
'condition' => function ( $attrs ) {
return isset( $attrs['sublistIndent'] ) && is_string( $attrs['sublistIndent'] ) && ! is_numeric( $attrs['sublistIndent'] );
},
),
array(
'property' => '--content-color',
'value' => 'defaultContentColor',
Expand Down
3 changes: 3 additions & 0 deletions src/blocks/blocks/icon-list/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"gapIconLabel": {
"type": ["string"]
},
"sublistIndent": {
"type": ["number", "string"]
},
"horizontalAlign": {
"type": "string"
},
Expand Down
34 changes: 34 additions & 0 deletions src/blocks/blocks/icon-list/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* WordPress dependencies
*/
import {
InnerBlocks,
useBlockProps
} from '@wordpress/block-editor';

import classNames from 'classnames';

import metadata from './block.json';

const deprecated = [{
// Markup before sub-list support, which added the list role.
attributes: { ...metadata.attributes },

save: ({
attributes,
className
}) => {
const blockProps = useBlockProps.save({
id: attributes.id,
className: classNames( className, { 'has-divider': Boolean( attributes.hasDivider ) })
});

return (
<div { ...blockProps }>
<InnerBlocks.Content />
</div>
);
}
}];

export default deprecated;
1 change: 1 addition & 0 deletions src/blocks/blocks/icon-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const Edit = ({
'--icon-align-mobile': attributes.alignmentMobile,
'--gap': _px( attributes.gap ),
'--gap-icon-label': attributes.gapIconLabel,
'--sublist-indent': _px( attributes.sublistIndent ),
'--font-size': _px( attributes.defaultSize ),
'--icon-size': attributes.defaultIconSize,
'--label-visibility': attributes.hideLabels ? 'none' : undefined,
Expand Down
35 changes: 34 additions & 1 deletion src/blocks/blocks/icon-list/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,27 @@
align-items: var( --icon-align-tablet );
justify-content: var( --icon-align-tablet );
}

@media (max-width: 600px) {
align-items: var( --icon-align-mobile );
justify-content: var( --icon-align-mobile );
}
}

// The editor nests items inside the inner blocks wrappers, so mirror the
// direct-child rules from style.scss for the editor DOM.
&:not(.is-style-horizontal) > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block-themeisle-blocks-icon-list-item {
@include icon-list-item-vertical;
}

&.has-divider:not(.is-style-horizontal) > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block-themeisle-blocks-icon-list-item:not(:last-child)::after {
@include icon-list-divider-vertical;
}

&.is-style-horizontal.has-divider > .block-editor-inner-blocks > .block-editor-block-list__layout > .wp-block-themeisle-blocks-icon-list-item:not(:last-child)::after {
@include icon-list-divider-horizontal;
}

&.is-selected.has-divider {
&.is-style-horizontal, &:not(.is-style-horizontal) {
.wp-block-themeisle-blocks-icon-list-item:nth-last-child(2)::after {
Expand All @@ -39,6 +53,25 @@
}
}

// Sub-list area inside an item: hidden while empty, on its own line once filled.
.wp-block-themeisle-blocks-icon-list .wp-block-themeisle-blocks-icon-list-item {
flex-wrap: wrap;

> .block-editor-inner-blocks {
display: none;
}

&.has-sublist > .block-editor-inner-blocks {
display: block;
flex-basis: 100%;
width: 100%;
}

> .o-block-appender-button {
flex-basis: 100%;
}
}

.editor-styles-wrapper .wp-block.wp-block-themeisle-blocks-icon-list-item,
.editor-styles-wrapper .block-editor-block-list__layout.is-root-container p.wp-block-themeisle-blocks-icon-list-item-content {
/* We add this to override Neve styles */
Expand Down
2 changes: 2 additions & 0 deletions src/blocks/blocks/icon-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { registerBlockType } from '@wordpress/blocks';
*/
import metadata from './block.json';
import { iconListIcon as icon } from '../../helpers/icons.js';
import deprecated from './deprecated.js';
import edit from './edit.js';
import save from './save.js';
import './item/index.js';
Expand All @@ -26,6 +27,7 @@ registerBlockType( name, {
'list',
'items'
],
deprecated,
edit,
save,
example: {
Expand Down
16 changes: 16 additions & 0 deletions src/blocks/blocks/icon-list/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,22 @@ const Inspector = ({
}
]}
/>

<br/>

<UnitControl
label={ __( 'Sub-list Indent', 'otter-blocks' ) }
value={ attributes.sublistIndent ?? '32px' }
onChange={ sublistIndent => setAttributes({ sublistIndent }) }
units={[
{
a11yLabel: 'Pixels (px)',
label: 'px',
step: 1,
value: 'px'
}
]}
/>
</PanelBody>
<PanelBody
title={ __( 'Divider', 'otter-blocks' ) }
Expand Down
52 changes: 52 additions & 0 deletions src/blocks/blocks/icon-list/item/deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
* Internal dependencies
*/
import themeIsleIcons from './../../../helpers/themeisle-icons.js';
import metadata from './block.json';

const attributes = {
id: {
Expand All @@ -41,6 +42,57 @@ const attributes = {
};

const deprecated = [{
// Markup before sub-list support, which added the list role.
attributes: { ...metadata.attributes },

save: ({
attributes
}) => {
const iconClassName = `${ attributes.iconPrefix } fa-${ attributes.icon }`;
const Icon = themeIsleIcons.icons[ attributes.icon ];

const blockProps = useBlockProps.save({
id: attributes.id
});

return (
<div { ...blockProps }>
{
'image' === attributes.library && attributes.icon ? (
<img src={ attributes.icon } alt={ attributes.iconAlt || '' } />
) : (
'themeisle-icons' === attributes.library && attributes.icon ? (
<Icon
className={ classnames(
{ 'wp-block-themeisle-blocks-icon-list-item-icon': ! attributes.iconColor },
{ 'wp-block-themeisle-blocks-icon-list-item-icon-custom': attributes.iconColor }
) }
/>
) : (
<i
className={ classnames(
iconClassName,
{ 'wp-block-themeisle-blocks-icon-list-item-icon': ! attributes.iconColor },
{ 'wp-block-themeisle-blocks-icon-list-item-icon-custom': attributes.iconColor }
) }
></i>
)
)
}


<RichText.Content
tagName="p"
className={ classnames(
{ 'wp-block-themeisle-blocks-icon-list-item-content': ! attributes.contentColor },
{ 'wp-block-themeisle-blocks-icon-list-item-content-custom': attributes.contentColor }
) }
value={ attributes.content }
/>
</div>
);
}
}, {
attributes,

migrate: oldAttributes => ({
Expand Down
Loading