-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Columns block: Add stack on mobile setting to allow for columns without mobile breakpoints #31816
Merged
kjellr
merged 4 commits into
WordPress:trunk
from
andrewserong:add/columns-stack-on-mobile-option
Jul 7, 2021
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8044880
Columns block: Add stack on mobile setting
andrewserong faa4870
Update selector to specify the direct child
andrewserong b226d91
Fix deprecations to include the new attribute, add another set of tes…
andrewserong 2076c72
Add nowrap to is-not-stacked-on-mobile
andrewserong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/e2e-tests/fixtures/blocks/core__columns__is-not-stacked-on-mobile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- wp:columns {"isStackedOnMobile":false,"backgroundColor":"secondary"} --> | ||
<div class="wp-block-columns is-not-stacked-on-mobile has-secondary-background-color has-background"> | ||
<!-- wp:column --> | ||
<div class="wp-block-column"> | ||
<!-- wp:paragraph --> | ||
<p>Column One, Paragraph One</p> | ||
<!-- /wp:paragraph --> | ||
<!-- wp:paragraph --> | ||
<p>Column One, Paragraph Two</p> | ||
<!-- /wp:paragraph --> | ||
</div> | ||
<!-- /wp:column --> | ||
<!-- wp:column --> | ||
<div class="wp-block-column"> | ||
<!-- wp:paragraph --> | ||
<p>Column Two, Paragraph One</p> | ||
<!-- /wp:paragraph --> | ||
<!-- wp:paragraph --> | ||
<p>Column Three, Paragraph One</p> | ||
<!-- /wp:paragraph --> | ||
</div> | ||
<!-- /wp:column --> | ||
</div> | ||
<!-- /wp:columns --> |
76 changes: 76 additions & 0 deletions
76
packages/e2e-tests/fixtures/blocks/core__columns__is-not-stacked-on-mobile.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
[ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "core/columns", | ||
"isValid": true, | ||
"attributes": { | ||
"isStackedOnMobile": false, | ||
"backgroundColor": "secondary" | ||
}, | ||
"innerBlocks": [ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "core/column", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "core/paragraph", | ||
"isValid": true, | ||
"attributes": { | ||
"content": "Column One, Paragraph One", | ||
"dropCap": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<p>Column One, Paragraph One</p>" | ||
}, | ||
{ | ||
"clientId": "_clientId_1", | ||
"name": "core/paragraph", | ||
"isValid": true, | ||
"attributes": { | ||
"content": "Column One, Paragraph Two", | ||
"dropCap": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<p>Column One, Paragraph Two</p>" | ||
} | ||
], | ||
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>" | ||
}, | ||
{ | ||
"clientId": "_clientId_1", | ||
"name": "core/column", | ||
"isValid": true, | ||
"attributes": {}, | ||
"innerBlocks": [ | ||
{ | ||
"clientId": "_clientId_0", | ||
"name": "core/paragraph", | ||
"isValid": true, | ||
"attributes": { | ||
"content": "Column Two, Paragraph One", | ||
"dropCap": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<p>Column Two, Paragraph One</p>" | ||
}, | ||
{ | ||
"clientId": "_clientId_1", | ||
"name": "core/paragraph", | ||
"isValid": true, | ||
"attributes": { | ||
"content": "Column Three, Paragraph One", | ||
"dropCap": false | ||
}, | ||
"innerBlocks": [], | ||
"originalContent": "<p>Column Three, Paragraph One</p>" | ||
} | ||
], | ||
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>" | ||
} | ||
], | ||
"originalContent": "<div class=\"wp-block-columns is-not-stacked-on-mobile has-secondary-background-color has-background\">\n\t\n\t\n</div>" | ||
} | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the benefit of moving these rules inside
&:not(.is-not-stacked-on-mobile) > .wp-block-column
?These previously were on
.wp-block-column
directly, and it was a lot cleaner. I haven't checked, but would it not be simpler to have these in.wp-block-column
like before, and then simply override these rules where necessary in&.is-not-stacked-on-mobile
?Is there a reason I'm missing for the added complexity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main benefit is that using the
:not()
rules avoids duplicate code. There are also some!important
rules here, so we'd need to override those with more!important
rules. 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's an awkward rule, but results in fewer lines of CSS, while preserving the existing styling / similar specificity. I couldn't quite come up with a neat way to handle it otherwise, so it was a bit of a trade-off! 😅