Skip to content

Commit

Permalink
Testing with block styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed May 31, 2022
1 parent c4f5415 commit 1a0456c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
8 changes: 8 additions & 0 deletions packages/block-library/src/columns/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
}
}
},
"styles": [
{
"name": "regular",
"label": "Default",
"isDefault": true
},
{ "name": "tablet-stack", "label": "Tablet stack" }
],
"editorStyle": "wp-block-columns-editor",
"style": "wp-block-columns"
}
33 changes: 20 additions & 13 deletions packages/block-library/src/columns/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,12 @@
}

&:not(.is-not-stacked-on-mobile) > .wp-block-column {
@media (max-width: #{ ($break-small - 1) }) {
@media (max-width: #{ ($break-medium - 1) }) {
// Responsiveness: Show at most one columns on mobile. This must be
// important since the Column assigns its own width as an inline style.
flex-basis: 100% !important;
}

// Between mobile and large viewports (tablet), allow 2 columns.
@media (min-width: #{ ($break-small) }) and (max-width: #{ ($break-medium - 1) }) {
// Only add two column styling if there are two or more columns
&:not(:only-child) {
// As with mobile styles, this must be important since the Column
// assigns its own width as an inline style, which should take effect
// starting at `break-medium`.
// Note: to calculate the offset we have to add the root block gap value with any block support spacing value (stored in --wp--style--unstable-columns-gap).
flex-basis: calc(50% - calc(var(--wp--style--block-gap, 2em) + var(--wp--style--unstable-columns-gap, 0em) / 2)) !important;
}
}

// At large viewports, show all columns horizontally.
@include break-medium() {
// Available space should be divided equally amongst columns without an
Expand All @@ -68,6 +56,25 @@
}
}

&.is-style-tablet-stack:not(.is-not-stacked-on-mobile) > .wp-block-column {
@media (max-width: #{ ($break-small - 1) }) {
// Responsiveness: Show at most one columns on mobile. This must be
// important since the Column assigns its own width as an inline style.
flex-basis: 100% !important;
}
// Between mobile and large viewports (tablet), allow 2 columns.
@media (min-width: #{ ($break-small) }) and (max-width: #{ ($break-medium - 1) }) {
// Only add two column styling if there are two or more columns
&:not(:only-child) {
// As with mobile styles, this must be important since the Column
// assigns its own width as an inline style, which should take effect
// starting at `break-medium`.
// Note: to calculate the offset we have to add the root block gap value with any block support spacing value (stored in --wp--style--unstable-columns-gap).
flex-basis: calc(50% - calc(var(--wp--style--block-gap, 2em) + var(--wp--style--unstable-columns-gap, 0em) / 2)) !important;
}
}
}

&.is-not-stacked-on-mobile {
flex-wrap: nowrap !important;

Expand Down

0 comments on commit 1a0456c

Please sign in to comment.