Skip to content
This repository has been archived by the owner on Mar 18, 2020. It is now read-only.

Commit

Permalink
Improved readability of section block, added wide option
Browse files Browse the repository at this point in the history
  • Loading branch information
gubbigubbi committed May 14, 2018
1 parent 99af298 commit e44455b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/blocks/section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ registerBlockType("cgb/block-section", {
<BlockAlignmentToolbar
value={alignment}
onChange={updateAlignment}
controls={["full"]}
controls={["full", "wide"]}
/>
</BlockControls>

Expand Down Expand Up @@ -158,28 +158,32 @@ registerBlockType("cgb/block-section", {
},

// The "save" property must be specified and must be a valid function.
save: function(props) {
save: props => {
const classes = classnames(
"transition-all",
props.attributes.alignment ? `align${props.attributes.alignment}` : null
);

// if it is wide or full show a container

const innerClasses = classnames(
props.attributes.alignment == "full" ? "container container-bd" : null
props.attributes.alignment == "wide" ? "container" : null
);

const { attributes: { id, sectionBackgroundColor, verticalPadding, horizontalPadding, topMargin, bottomMargin } } = props;

return (
<div
id={props.attributes.id}
id={id}
className={classes}
style={{
backgroundColor: props.attributes.sectionBackgroundColor,
paddingTop: props.attributes.verticalPadding + "rem",
paddingBottom: props.attributes.verticalPadding + "rem",
paddingLeft: props.attributes.horizontalPadding + "rem",
paddingRight: props.attributes.horizontalPadding + "rem",
marginTop: props.attributes.topMargin + "rem",
marginBottom: props.attributes.bottomMargin + "rem"
backgroundColor: sectionBackgroundColor,
paddingTop: verticalPadding + "rem",
paddingBottom: verticalPadding + "rem",
paddingLeft: horizontalPadding + "rem",
paddingRight: horizontalPadding + "rem",
marginTop: topMargin + "rem",
marginBottom: bottomMargin + "rem"
}}
>
<div className={innerClasses}>
Expand Down

0 comments on commit e44455b

Please sign in to comment.