Skip to content

Commit

Permalink
Breaking: block padding property (fixes #358) (#359)
Browse files Browse the repository at this point in the history
Breaking: block padding property (fixes #358)
  • Loading branch information
guywillis authored Nov 22, 2022
1 parent 446d923 commit aa8a3b4
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 118 deletions.
115 changes: 63 additions & 52 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapt-contrib-vanilla",
"version": "7.2.0",
"framework": ">=5.20.1",
"framework": ">=5.22.9",
"homepage": "https://github.com/adaptlearning/adapt-contrib-vanilla",
"bugs": "https://github.com/adaptlearning/adapt-contrib-vanilla/issues",
"theme": "vanilla",
Expand Down
20 changes: 2 additions & 18 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ blocks.json
},
// Divider Block - adds class to `.block` element
"_isDividerBlock": false,
"_paddingTop": "double",
"_paddingBottom": "half",
// Defines the vertical alignment of the child component(s) in relation to the block.
// Top: Aligns descendents to the top of the block. Center: Aligns descendents to the center of the block. Bottom: Aligns descendents to the bottom of the block.
// The default alignment is `top`.
Expand Down Expand Up @@ -155,24 +157,6 @@ Block classes
"_classes": "extend-container",
"_comment": "Extend width of block to max page width (default is 1440px).",

"_classes": "remove-padding-top | remove-top-padding",
"_comment": "Removes the top padding from block.",

"_classes": "remove-padding-bottom | remove-bottom-padding",
"_comment": "Removes the bottom padding from block.",

"_classes": "reduce-padding-top",
"_comment": "Reduce the blocks top padding by half.",

"_classes": "reduce-padding-bottom",
"_comment": "Reduce the blocks bottom padding by half.",

"_classes": "increase-padding-top",
"_comment": "Double the blocks top padding.",

"_classes": "increase-padding-bottom",
"_comment": "Double the blocks bottom padding.",

Component classes
--------------------------------------------------

Expand Down
14 changes: 14 additions & 0 deletions js/themeBlockView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ export default class ThemeBlockView extends ThemeView {
}

setCustomStyles() {
this.setPaddingTop();
this.setPaddingBottom();
this.setComponentVerticalAlignment();
}

setPaddingTop() {
const paddingTop = this.model.get('_paddingTop');
if (!paddingTop) return;
this.$el.addClass(`${paddingTop}-padding-top`);
}

setPaddingBottom() {
const paddingBottom = this.model.get('_paddingBottom');
if (!paddingBottom) return;
this.$el.addClass(`${paddingBottom}-padding-bottom`);
}

setComponentVerticalAlignment() {
const componentVerticalAlignment = this.model.get('_componentVerticalAlignment');
if (!componentVerticalAlignment) return;
Expand Down
20 changes: 14 additions & 6 deletions less/core/block.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@
.link-text;
}

// Double the blocks top or bottom padding
&.double-padding-top &__inner { padding-top: @block-padding-ver * 2; }
&.double-padding-bottom &__inner { padding-bottom: @block-padding-ver * 2; }

// Half the blocks top or bottom padding
&.half-padding-top &__inner { padding-top: @block-padding-ver / 2; }
&.half-padding-bottom &__inner { padding-bottom: @block-padding-ver / 2; }

// Remove the top or bottom padding from block
&.remove-padding-top &__inner { padding-top: 0; }
&.remove-padding-bottom &__inner { padding-bottom: 0; }

// Aligns child components centrally on the vertical axis
&.align-vert-center .component__container {
align-items: center;
}
&.align-vert-center .component__container { align-items: center; }

// Aligns child components to the bottom of the parent block on the vertical axis
&.align-vert-bottom .component__container {
align-items: flex-end;
}
&.align-vert-bottom .component__container {align-items: flex-end; }
}
38 changes: 0 additions & 38 deletions less/project/theme-extras.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,6 @@
max-width: @max-width;
}

// Remove top padding from block
// --------------------------------------------------
.block.remove-padding-top .block__inner,
.block.remove-top-padding .block__inner {
padding-top: 0;
}

// Remove bottom padding from block
// --------------------------------------------------
.block.remove-padding-bottom .block__inner,
.block.remove-bottom-padding .block__inner {
padding-bottom: 0;
}

// Reduce the blocks top padding by half
// --------------------------------------------------
.block.reduce-padding-top .block__inner {
padding-top: @block-padding-ver / 2;
}

// Reduce the blocks bottom padding by half
// --------------------------------------------------
.block.reduce-padding-bottom .block__inner {
padding-bottom: @block-padding-ver / 2;
}

// Double the blocks top padding
// --------------------------------------------------
.block.increase-padding-top .block__inner {
padding-top: @block-padding-ver * 2;
}

// Double the blocks bottom padding
// --------------------------------------------------
.block.increase-padding-bottom .block__inner {
padding-bottom: @block-padding-ver * 2;
}

// DEPRECATED in favour of bg-color-mixin
// Block background color mixin
// Add to block to enable
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapt-contrib-vanilla",
"version": "7.2.0",
"framework": ">=5.20.1",
"framework": ">=5.22.9",
"homepage": "https://github.com/adaptlearning/adapt-contrib-vanilla",
"bugs": "https://github.com/adaptlearning/adapt-contrib-vanilla/issues",
"theme": "vanilla",
Expand Down
18 changes: 17 additions & 1 deletion properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -1147,12 +1147,28 @@
"validators": [],
"help": "If enabled, applies a divider class to the block"
},
"_paddingTop": {
"type": "string",
"required": false,
"default": "standard",
"inputType": {"type":"Select", "options":["double","standard","half","remove"]},
"title": "Spacing top",
"help": "Changes the value of the blocks top spacing. Double: Doubles the blocks top spacing. Standard: Retains the standard blocks top spacing. Half: Halves the blocks top spacing. Remove: Removes the blocks top spacing. The default value is `standard`."
},
"_paddingBottom": {
"type": "string",
"required": false,
"default": "standard",
"inputType": {"type":"Select", "options":["double","standard","half","remove"]},
"title": "Spacing bottom",
"help": "Changes the value of the blocks bottom spacing. Double: Doubles the blocks bottom spacing. Standard: Retains the standard blocks bottom spacing. Half: Halves the blocks bottom spacing. Remove: Removes the blocks bottom spacing. The default value is `standard`."
},
"_componentVerticalAlignment": {
"type": "string",
"required": false,
"default": "top",
"inputType": {"type":"Select", "options":["top","center","bottom"]},
"title": "Set the vertical alignment of the child component(s).",
"title": "Set the vertical alignment of the child component(s)",
"help": "Defines the vertical alignment of the child component(s) in relation to the block. Top: Aligns descendents to the top of the block. Center: Aligns descendents to the center of the block. Bottom: Aligns descendents to the bottom of the block. The default alignment is `top`."
}
}
Expand Down
28 changes: 27 additions & 1 deletion schema/block.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,35 @@
"description": "If enabled, applies a divider class to the block",
"default": false
},
"_paddingTop": {
"type": "string",
"title": "Spacing top",
"description": "Changes the value of the blocks top spacing. Double: Doubles the blocks top spacing. Standard: Retains the standard blocks top spacing. Half: Halves the blocks top spacing. Remove: Removes the blocks top spacing. The default value is `standard`.",
"default": "standard",
"enum": [
"double",
"standard",
"half",
"remove"
],
"_backboneForms": "Select"
},
"_paddingBottom": {
"type": "string",
"title": "Spacing bottom",
"description": "Changes the value of the blocks bottom spacing. Double: Doubles the blocks bottom spacing. Standard: Retains the standard blocks bottom spacing. Half: Halves the blocks bottom spacing. Remove: Removes the blocks bottom spacing. The default value is `standard`.",
"default": "standard",
"enum": [
"double",
"standard",
"half",
"remove"
],
"_backboneForms": "Select"
},
"_componentVerticalAlignment": {
"type": "string",
"title": "Set the vertical alignment of the child component(s).",
"title": "Set the vertical alignment of the child component(s)",
"description": "Defines the vertical alignment of the child component(s) in relation to the block. Top: Aligns descendents to the top of the block. Center: Aligns descendents to the center of the block. Bottom: Aligns descendents to the bottom of the block. The default alignment is `top`.",
"default": "top",
"enum": [
Expand Down

0 comments on commit aa8a3b4

Please sign in to comment.