-
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
Remove the default block margins from themes with theme.json file #30375
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
// This needs specificity to override the editor styles. | ||
.editor-styles-wrapper .wp-block { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
// Depreacted style needed for the block widths and alignments. | ||
// for themes that don't support the new layout (theme.json) | ||
.wp-block { | ||
max-width: $content-width; | ||
|
||
// Provide every block with a default base margin. This margin provides a consistent spacing | ||
// between blocks in the editor. | ||
margin-top: $default-block-margin; | ||
margin-bottom: $default-block-margin; | ||
|
||
&[data-align="wide"] { | ||
max-width: $wide-content-width; | ||
} | ||
|
||
&[data-align="full"] { | ||
max-width: none; | ||
} | ||
|
||
// Alignments. | ||
&[data-align="left"], | ||
&[data-align="right"] { | ||
width: 100%; | ||
|
||
// When images are floated, the block itself should collapse to zero height. | ||
height: 0; | ||
|
||
&::before { | ||
content: none; | ||
} | ||
} | ||
|
||
// Left. | ||
&[data-align="left"] > * { | ||
/*!rtl:begin:ignore*/ | ||
float: left; | ||
margin-right: 2em; | ||
/*!rtl:end:ignore*/ | ||
} | ||
|
||
// Right. | ||
&[data-align="right"] > * { | ||
/*!rtl:begin:ignore*/ | ||
float: right; | ||
margin-left: 2em; | ||
/*!rtl:end:ignore*/ | ||
} | ||
|
||
// Wide and full-wide. | ||
&[data-align="full"], | ||
&[data-align="wide"] { | ||
clear: both; | ||
} | ||
} | ||
|
||
// Full Width Blocks | ||
// specificity required to only target immediate child Blocks of a Group | ||
.wp-block-group > [data-align="full"] { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
|
||
// Full Width Blocks with a background (ie: has padding) | ||
.wp-block-group.has-background > [data-align="full"] { | ||
// note: using position `left` causes hoz scrollbars so | ||
// we opt to use margin instead | ||
// the 30px matches the hoz padding applied in `theme.scss` | ||
// added when the Block has a background set | ||
margin-left: -30px; | ||
|
||
// 60px here is x2 the hoz padding from `theme.scss` added when | ||
// the Block has a background set | ||
// note: also duplicated below for full width Groups | ||
width: calc(100% + 60px); | ||
} | ||
|
||
/** | ||
* Group: Full Width Alignment | ||
*/ | ||
[data-align="full"] .wp-block-group { | ||
// Non-full Width Blocks | ||
// specificity required to only target immediate child Blocks of Group | ||
> .wp-block { | ||
padding-left: $block-padding; | ||
padding-right: $block-padding; | ||
|
||
@include break-small() { | ||
padding-left: 0; | ||
padding-right: 0; | ||
} | ||
} | ||
|
||
// Full Width Blocks | ||
// specificity required to only target immediate child Blocks of Group | ||
> [data-align="full"] { | ||
padding-right: 0; | ||
padding-left: 0; | ||
left: 0; | ||
width: 100%; | ||
max-width: none; | ||
} | ||
|
||
// Full Width Blocks with a background (ie: has padding) | ||
// note: also duplicated above for all Group widths | ||
&.has-background > [data-align="full"] { | ||
width: calc(100% + 60px); | ||
} | ||
} |
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
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.
This is such a nice way to ensure backward compatibility. ❤️