Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
spelkey-ucd committed Feb 8, 2024
1 parent 91980d3 commit e15452f
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/editor/lib/blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import landerNav from "./ucd-theme-lander-nav";
import layoutColumn from "./ucd-theme-layout-column";
import layoutColumns from "./ucd-theme-layout-columns";
import layoutContainer from "./ucd-theme-layout-container";
import layoutGutters from "./ucd-theme-layout-gutters";
import layoutBasic from "./ucd-theme-layout-basic";
import layoutShrink from "./ucd-theme-layout-shrink";
import layoutQuad from "./ucd-theme-layout-quad";
Expand Down Expand Up @@ -78,6 +79,7 @@ export default [
layoutColumn,
layoutColumns,
layoutContainer,
layoutGutters,
layoutBasic,
layoutShrink,
layoutQuad,
Expand Down Expand Up @@ -108,4 +110,4 @@ export default [
trumba,
trumbaUpcoming,
trumbaFilter
];
];
36 changes: 36 additions & 0 deletions src/editor/lib/blocks/ucd-theme-layout-gutters/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { html, UCDIcons } from "../../utils";
import {
useBlockProps,
BlockControls,
useInnerBlocksProps
} from '@wordpress/block-editor';
import { Fragment } from "@wordpress/element";
import { ToolbarButton } from '@wordpress/components';

export default ( props ) => {
const { attributes, setAttributes } = props;

const classes = attributes.narrow ? 'l-gutter--narrow' : 'l-gutter';

const blockProps = useBlockProps( {
className: classes
} );

const innerBlocksProps = useInnerBlocksProps( blockProps, {
templateLock: false,
} );

return html`
<${Fragment}>
<${BlockControls} group="block">
<${ToolbarButton}
icon=${UCDIcons.renderPublic('fa-minimize')}
onClick=${ () => {setAttributes({'narrow': !attributes.narrow})}}
isPressed=${attributes.narrow}
label="Toggle 'narrow' setting"/>
</${BlockControls}>
<div ...${ innerBlocksProps } >
</div>
</${Fragment}>
`;
}
26 changes: 26 additions & 0 deletions src/editor/lib/blocks/ucd-theme-layout-gutters/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { UCDIcons, Save } from "../../utils";
import Edit from './edit';

const name = 'ucd-theme/layout-gutters';
const settings = {
api_version: 2,
title: "Gutters",
description: "Adds spacing to the left and right of the content.",
icon: UCDIcons.renderPublic('fa-arrows-left-right-to-line'),
category: 'ucd-layout',
keywords: [ 'gutter', 'margin', 'left', 'right' ],
supports: {
"html": false,
"customClassName": false
},
attributes: {
narrow: {
type: 'boolean',
default: false
}
},
edit: Edit,
save: Save
};

export default { name, settings };
1 change: 1 addition & 0 deletions theme/includes/classes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ function __construct($editor_script_slug, $settings=array()) {
"ucd-theme/column" => array("twig" => "@ucd/blocks/layout-column.twig"),
"ucd-theme/layout-columns" => array("twig" => "@ucd/blocks/layout-columns.twig"),
"ucd-theme/layout-container" => array("twig" => "@ucd/blocks/layout-container.twig"),
"ucd-theme/layout-gutters" => ['twig' => "@ucd/blocks/layout-gutters.twig"],
"ucd-theme/layout-shrink" => array("twig" => "@ucd/blocks/layout-shrink.twig"),
"ucd-theme/layout-quad" => array("twig" => "@ucd/blocks/layout-quad.twig"),
"ucd-theme/manual-subnav" => array(
Expand Down
1 change: 1 addition & 0 deletions views/blocks/layout-gutters.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div class="{{attributes.narrow ? 'l-gutter--narrow' : 'l-gutter'}}">{{content}}</div>

0 comments on commit e15452f

Please sign in to comment.