Skip to content
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

Convert all px values in front-facing styles to relative (em) units #24523

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0ff3380
Merge pull request #1 from WordPress/master
aristath Aug 3, 2020
db8ca29
Button Block: Use relative instead of absolute units
aristath Aug 3, 2020
20e96a5
Use relative units for calendar paddings
aristath Aug 3, 2020
47efef0
Paragraph block: Use relative instead of absolute units
aristath Aug 3, 2020
3eb326a
Text Columns: Prefer relative units
aristath Aug 6, 2020
b204bf8
Quote block: Prefer relative units
aristath Aug 6, 2020
7ae267a
Pullquote block: Prefer relative units
aristath Aug 6, 2020
519dae7
also apply changes to native
aristath Aug 6, 2020
8ee37dd
Latest Comments Block: Prefer relative units
aristath Aug 6, 2020
d6ba20f
Use relative units for social-icons block
aristath Aug 6, 2020
992c777
Don't use $grid-unit-* vars for front-facing styles
aristath Aug 7, 2020
8ac774f
Avoid using $default-block-margin for front-facing styles
aristath Aug 7, 2020
e7dac0d
Merge branch 'aristath/no-front-default-block-margin' into aristath/t…
aristath Aug 12, 2020
a1d6b2d
Merge branch 'aristath/no-front-grid-vars' into aristath/try-relative…
aristath Aug 12, 2020
187a50a
Merge branch 'aristath/text-columns-relative-units' into aristath/try…
aristath Aug 12, 2020
df93076
Merge branch 'aristath/social-icons-relative-units' into aristath/try…
aristath Aug 12, 2020
28c9b99
Merge branch 'aristath/pullquote-block-relative-units' into aristath/…
aristath Aug 12, 2020
2041b02
Merge branch 'aristath/quote-block-relative-units' into aristath/try-…
aristath Aug 12, 2020
1ad1c28
Merge branch 'button-block-relative-units' into aristath/try-relative…
aristath Aug 12, 2020
dfa8e80
Merge branch 'calendar-block-relatve-units' into aristath/try-relativ…
aristath Aug 12, 2020
7922206
Merge branch 'p-block-relative-units' into aristath/try-relative-units
aristath Aug 12, 2020
7ef1e21
Merge branch 'aristath/latest-comments-relative-units' into aristath/…
aristath Aug 12, 2020
5479bc0
Convert all remaining pixel values to rem
aristath Aug 12, 2020
3a2b095
Use em instead of rem
aristath Aug 13, 2020
4d72408
Merge branch 'master' into aristath/try-relative-units
aristath Aug 13, 2020
ae64ed0
Use the vars
aristath Aug 13, 2020
31c5f91
restore original code block padding
aristath Aug 14, 2020
4afbe33
Update packages/block-library/src/button/style.scss
aristath Aug 14, 2020
0e71afe
Update packages/block-library/src/latest-comments/style.scss
aristath Aug 14, 2020
2b503a2
Move vars to separate "group" and fix comments capitalization
aristath Aug 14, 2020
f7cdac1
this value is closer to the legacy one
aristath Aug 14, 2020
9da60ff
no reason for the padding to change here since it was already using em
aristath Aug 14, 2020
b61eec5
Update packages/base-styles/_variables.scss
aristath Aug 14, 2020
3828247
Value needs to change since it's now relative to the font-size
aristath Aug 14, 2020
def9b97
Fix calculations for relative units in the gallery block
aristath Aug 14, 2020
9f7228b
Fix social links editor styles
aristath Aug 15, 2020
fe5c2f6
Revert social-icons style mods
aristath Aug 15, 2020
2bbcf37
Merge branch 'master' into aristath/try-relative-units
aristath Aug 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ $block-padding: 14px; // Space between block footprint and focus boundaries. The
$block-spacing: 4px; // Vertical space between blocks.
$block-side-ui-width: $button-size; // Width of the movers/drag handle UI.
$block-side-ui-clearance: 2px; // Space between movers/drag handle UI, and block.
$block-container-side-padding: $block-side-ui-width + $block-padding + 2 * $block-side-ui-clearance; // Total space left and right of the block footprint.
$block-bg-padding--v: $block-padding + $block-spacing + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or group)
$block-bg-padding--h: $block-side-ui-width + $block-side-ui-clearance; // padding for Blocks with a background color (eg: paragraph or group)
$dimmed-opacity: 1;

$block-edge-to-content: 16px;
Expand All @@ -101,3 +98,10 @@ $block-selected-to-content: $block-edge-to-content - $block-selected-margin - $b

$radius-round: 50%;
$radius-block-ui: 2px;

/**
* Block paddings.
*/
// Padding for blocks with a background color (e.g. paragraph or group).
$block-bg-padding--v: 1.25em;
$block-bg-padding--h: 2.375em;
6 changes: 3 additions & 3 deletions packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$blocks-button__height: 56px;
$blocks-button__height: 3.1em;
aristath marked this conversation as resolved.
Show resolved Hide resolved

// Prefer the link selector instead of the regular button classname
// to support the previous markup in addition to the new one.
Expand All @@ -10,8 +10,8 @@ $blocks-button__height: 56px;
box-shadow: none;
cursor: pointer;
display: inline-block;
font-size: $big-font-size;
padding: 12px 24px;
font-size: 1.125em;
padding: 0.667em 1.333em;
text-align: center;
text-decoration: none;
overflow-wrap: break-word;
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/buttons/style.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Increased specificity to override blocks default margin.
.wp-block-buttons .wp-block-button {
display: inline-block;
margin-right: $grid-unit-10;
margin-bottom: $grid-unit-10;
margin-right: 0.5em;
margin-bottom: 0.5em;

&:last-child {
margin-right: 0;
Expand All @@ -13,7 +13,7 @@
/*rtl:ignore*/
margin-right: 0;
/*rtl:ignore*/
margin-left: $grid-unit-10;
margin-left: 0.5em;

&:first-child {
margin-left: 0;
Expand All @@ -24,7 +24,7 @@
/*rtl:ignore*/
margin-left: 0;
/*rtl:ignore*/
margin-right: $grid-unit-10;
margin-right: 0.5em;

&:last-child {
margin-right: 0;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/calendar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

th,
tbody td {
padding: 4px;
padding: 0.25em;
border: 1px solid $gray-200;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/code/theme.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.wp-block-code {
font-family: $editor-html-font;
font-size: $text-editor-font-size;
font-size: 0.9em;
color: $gray-900;
padding: 0.8em 1em;
border: 1px solid $gray-200;
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/columns/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.wp-block-columns {
display: flex;
margin-bottom: $default-block-margin;
margin-bottom: 1.75em;

// Responsiveness: Allow wrapping on mobile.
flex-wrap: wrap;
Expand Down Expand Up @@ -35,13 +35,13 @@
// 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`.
flex-basis: calc(50% - #{$grid-unit-20}) !important;
flex-basis: calc(50% - 1em) !important;
flex-grow: 0;

// Add space between the multiple columns. Themes can customize this if they wish to work differently.
// Only apply this beyond the mobile breakpoint, as there's only a single column on mobile.
&:nth-child(even) {
margin-left: $grid-unit-20 * 2;
margin-left: 2em;
}
}

Expand All @@ -65,7 +65,7 @@

// When columns are in a single row, add space before all except the first.
&:not(:first-child) {
margin-left: $grid-unit-20 * 2;
margin-left: 2em;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/cover/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
display: flex;
justify-content: center;
align-items: center;
padding: $grid-unit-20;
padding: 1em;

&.has-parallax {
background-attachment: fixed;
Expand Down Expand Up @@ -92,7 +92,7 @@
}

.wp-block-cover__inner-container {
width: calc(100% - 70px);
width: calc(100% - 4.375em);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one is maybe something to revert. I don't 100% fully understand where those 70px come from (cc: @jorgefilipecosta perhaps?) but I think given it's part of a calc statement, it was potentially important that this remained a pixel value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the PR you submitted it seems we can just remove the rule 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasmussen @jorgefilipecosta Please see comment here:
#25103 (comment)

This is causing styling breakages on the frontend for cover blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @johnstonphilip. I believe that #26143 to fix it.

z-index: z-index(".wp-block-cover__inner-container");
color: $white;
}
Expand Down Expand Up @@ -218,6 +218,6 @@ section.wp-block-cover-image > h2,
z-index: 1;
margin-bottom: 0;
max-width: $content-width;
padding: $block-padding;
padding: 0.44em;
text-align: center;
}
2 changes: 1 addition & 1 deletion packages/block-library/src/file/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
background: $dark-gray-700;
border-radius: 2em;
color: $white;
font-size: $default-font-size;
font-size: 0.8em;
padding: 0.5em 1em;
}

Expand Down
13 changes: 7 additions & 6 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.blocks-gallery-image,
.blocks-gallery-item {
// Add space between thumbnails, and unset right most thumbnails later.
margin: 0 $grid-unit-20 $grid-unit-20 0;
margin: 0 1em 1em 0;
display: flex;
flex-grow: 1;
flex-direction: column;
Expand Down Expand Up @@ -51,11 +51,12 @@
width: 100%;
max-height: 100%;
overflow: auto;
padding: 40px 10px 9px;
padding: 3em 0.77em 0.7em;
color: $white;
text-align: center;
font-size: $default-font-size;
font-size: 0.8em;
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);
box-sizing: border-box;

img {
display: inline;
Expand Down Expand Up @@ -84,7 +85,7 @@
// On mobile and responsive viewports, we allow only 1 or 2 columns at the most.
& .blocks-gallery-image,
& .blocks-gallery-item {
width: calc(50% - #{ $grid-unit-20 });
width: calc(50% - 1em);

&:nth-of-type(even) {
margin-right: 0;
Expand All @@ -102,8 +103,8 @@
@for $i from 3 through 8 {
&.columns-#{ $i } .blocks-gallery-image,
&.columns-#{ $i } .blocks-gallery-item {
width: calc(#{ 100% / $i } - #{ $grid-unit-20 * ( $i - 1 ) / $i });
margin-right: $grid-unit-20;
width: calc(#{ 100% / $i } - #{ 1em * ( $i - 1 ) / $i });
margin-right: 1em;
}
}

Expand Down
19 changes: 9 additions & 10 deletions packages/block-library/src/latest-comments/style.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
.wp-block-latest-comments__comment {
font-size: 15px;
line-height: 1.1;
list-style: none;
margin-bottom: 1em;

.has-avatars & {
min-height: 36px;
min-height: 2.25em;
list-style: none;

.wp-block-latest-comments__comment-meta,
.wp-block-latest-comments__comment-excerpt {
margin-left: 52px;
margin-left: 3.25em;
}
}

Expand All @@ -21,22 +20,22 @@
}

.wp-block-latest-comments__comment-excerpt p {
font-size: 14px;
font-size: 0.875em;
line-height: 1.8;
margin: 5px 0 20px;
margin: 0.36em 0 1.4em;
}

.wp-block-latest-comments__comment-date {
display: block;
font-size: 12px;
font-size: 0.75em;
}

.wp-block-latest-comments .avatar,
.wp-block-latest-comments__comment-avatar {
border-radius: 24px;
border-radius: 1.5em;
display: block;
float: left;
height: 40px;
margin-right: 12px;
width: 40px;
height: 2.5em;
margin-right: 0.75em;
width: 2.5em;
}
10 changes: 5 additions & 5 deletions packages/block-library/src/latest-posts/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
padding: 0;

li {
margin: 0 20px 20px 0;
margin: 0 1.25em 1.25em 0;
width: 100%;
}
}

@include break-small {
@for $i from 2 through 6 {
&.columns-#{ $i } li {
width: calc((100% / #{ $i }) - 20px);
width: calc((100% / #{ $i }) - 1.25em);
}
}
}
Expand All @@ -38,12 +38,12 @@
.wp-block-latest-posts__post-author {
display: block;
color: $dark-gray-300;
font-size: $default-font-size;
font-size: 0.8125em;
}

.wp-block-latest-posts__post-excerpt {
margin-top: $grid-unit-10;
margin-bottom: $grid-unit-20;
margin-top: 0.5em;
margin-bottom: 1em;
}

.wp-block-latest-posts__featured-image {
Expand Down
11 changes: 5 additions & 6 deletions packages/block-library/src/navigation-link/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

// Styles for submenu flyout
.has-child {
$navigation-vertical-padding: $grid-unit-10 * 0.75;
.wp-block-navigation__container {
border: $border-width solid rgba(0, 0, 0, 0.15);
background-color: inherit;
Expand All @@ -47,12 +46,12 @@
flex-grow: 1;
}
> .wp-block-navigation-link__submenu-icon {
padding-right: $grid-unit-10;
padding-right: 0.5em;
}
}

@include break-medium {
left: $grid-unit-30;
left: 1.5em;

// Nested submenus sit to the left on large breakpoints
.wp-block-navigation__container {
Expand All @@ -66,7 +65,7 @@
right: 100%;
height: 100%;
display: block;
width: $grid-unit-10;
width: 0.5em;
background: transparent;
}
}
Expand Down Expand Up @@ -105,7 +104,7 @@
.wp-block-navigation-link__content {
color: inherit;
text-decoration: none;
padding: $grid-unit-10 $grid-unit-10 * 2;
padding: 0.5em 1em;

+ .wp-block-navigation-link__content {
padding-top: 0;
Expand All @@ -124,7 +123,7 @@

.wp-block-navigation-link__submenu-icon {
height: inherit;
padding: $grid-unit-10 * 0.75 $grid-unit-10 * 2;
padding: 0.375em 1em;

svg {
fill: currentColor;
Expand Down
8 changes: 4 additions & 4 deletions packages/block-library/src/paragraph/style.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.is-small-text {
font-size: 14px;
font-size: 0.875em;
}

.is-regular-text {
font-size: 16px;
font-size: 1em;
}

.is-large-text {
font-size: 36px;
font-size: 2.25em;
}

.is-larger-text {
font-size: 48px;
font-size: 3em;
}

// Don't show the drop cap when editing the paragraph's content. It causes a
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/post-author/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
}

&__avatar {
margin-right: $grid-unit-20;
margin-right: 1em;
}

&__bio {
margin-bottom: $grid-unit-10;
margin-bottom: 0.7em;
font-size: 0.7em;
}

Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/pullquote/blockquote.native.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.quote {
font-size: 18px;
font-size: 1.125em;
}

.citation {
font-size: 14px;
margin-top: 12px;
font-size: 0.875em;
margin-top: 0.85em;
}
Comment on lines 1 to 8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the values under .citation is correct, because I'm not sure if .citation is nested under .quote. It's not really clear to me what's going on in the native.js file for this block.

Copy link
Member Author

@aristath aristath Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part wasn't 100% clear to me either... So I opted for the safest value, it made more sense 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native mobile doesn't support em at all so it causes a crash on pull-quote. We reverted *.native.scss changes here: #24936

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't know that, thank you!

2 changes: 1 addition & 1 deletion packages/block-library/src/pullquote/figure.native.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%shared {
border-width: 3px 0;
padding: 21px 16px;
padding: 1.3125em 1em;
}

.light {
Expand Down
Loading