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

Try global styles at blocks #20273

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ function gutenberg_experimental_global_styles_enqueue_assets() {
wp_register_style( 'global-styles', false, array(), true, true );
wp_add_inline_style( 'global-styles', $inline_style );
wp_enqueue_style( 'global-styles' );

wp_register_style(
'global-styles-block-library',
gutenberg_url( 'build/block-library/global.css' ),
array(),
filemtime( gutenberg_dir_path() . 'build/block-library/global.css' )
);
wp_enqueue_style( 'global-styles-block-library' );
}

/**
Expand Down
10 changes: 3 additions & 7 deletions packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$blocks-button__height: 56px;

.wp-block-button {
color: $white;
color: var(--wp--color--white, $white);
Copy link
Member Author

Choose a reason for hiding this comment

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

This covers the case where --wp--color--white is not present, so it fallbacks to $white. However, we also need to cover cases where the browser doesn't have support for CSS Custom Properties and write something like:

.wp-block-button {
	color: $white;
	color: var(--wp--color--white, $white);
}

which can be done automatically with some plugins.

Copy link
Member Author

Choose a reason for hiding this comment

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

We also don't want to do this until we're certain this is the way to go.


&.aligncenter {
text-align: center;
Expand All @@ -14,7 +14,7 @@ $blocks-button__height: 56px;
}

.wp-block-button__link {
background-color: $dark-gray-700;
background-color: var(--wp--color--background, $dark-gray-700);
border: none;
border-radius: $blocks-button__height / 2;
box-shadow: none;
Expand All @@ -36,10 +36,6 @@ $blocks-button__height: 56px;
}
}

.wp-gs .wp-block-button__link:not(.has-background) {
background-color: var(--wp--color--primary);
}

.is-style-squared .wp-block-button__link {
border-radius: 0;
}
Expand All @@ -48,7 +44,7 @@ $blocks-button__height: 56px;
}

.is-style-outline {
color: $dark-gray-700;
color: var(--wp--color--background, $dark-gray-700);

.wp-block-button__link {
background-color: transparent;
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import "./paragraph/global.scss";
@import "./heading/global.scss";
@import "./list/global.scss";
@import "./quote/global.scss";
@import "./pullquote/global.scss";
11 changes: 11 additions & 0 deletions packages/block-library/src/heading/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
h1,
h2,
h3,
h4,
h5,
h6 {
color: var(--wp--color--foreground--headings);
font-size: var(--wp--type--size--headings);
font-weight: var(--wp--type--weight);
line-height: var(--wp--type--line-height--headings);
}
6 changes: 6 additions & 0 deletions packages/block-library/src/list/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ul,
ol {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--base);
line-height: var(--wp--type--line-height--base);
}
5 changes: 5 additions & 0 deletions packages/block-library/src/paragraph/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
p {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--base);
line-height: var(--wp--type--line-height--base);
}
11 changes: 11 additions & 0 deletions packages/block-library/src/pullquote/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wp-block-pullquote p {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--base);
line-height: var(--wp--type--line-height--base);
}

.wp-block-pullquote cite {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--smaller);
line-height: var(--wp--type--line-height--smaller);
}
8 changes: 4 additions & 4 deletions packages/block-library/src/pullquote/theme.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.wp-block-pullquote {
border-top: 4px solid $dark-gray-500;
border-bottom: 4px solid $dark-gray-500;
border-top: 4px solid var(--wp--color--foreground-500, $dark-gray-500);
Copy link
Member Author

Choose a reason for hiding this comment

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

border-bottom: 4px solid var(--wp--color--foreground-500, $dark-gray-500);
margin-bottom: $default-block-margin;
color: $dark-gray-600;
color: var(--wp--color--foreground-600, $dark-gray-600);

cite,
footer,
&__citation {
color: $dark-gray-600;
color: var(--wp--color--foreground-600, $dark-gray-600);
text-transform: uppercase;
font-size: $default-font-size;
font-style: normal;
Expand Down
11 changes: 11 additions & 0 deletions packages/block-library/src/quote/global.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.wp-block-quote p {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--base);
line-height: var(--wp--type--line-height--base);
}

.wp-block-quote cite {
color: var(--wp--color--foreground--base);
font-size: var(--wp--type--size--smaller);
line-height: var(--wp--type--line-height--smaller);
}
6 changes: 3 additions & 3 deletions packages/block-library/src/quote/theme.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.wp-block-quote {
border-left: 4px solid $black;
border-left: 4px solid var(--wp--color--border, $black);
Copy link
Member Author

Choose a reason for hiding this comment

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

margin: 0 0 $default-block-margin 0;
padding-left: 1em;

cite,
footer,
&__citation {
color: $dark-gray-300;
color: var(--wp--foreground-300, $dark-gray-300);
font-size: $default-font-size;
margin-top: 1em;
position: relative;
Expand All @@ -16,7 +16,7 @@
&.has-text-align-right,
&.has-text-align-right {
border-left: none;
border-right: 4px solid $black;
border-right: 4px solid var(--wp--color--border, $black);
padding-left: 0;
padding-right: 1em;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/table/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
background-color: transparent;

tbody tr:nth-child(odd) {
background-color: $light-gray-200;
background-color: var(--wp--color--foreground-200, $light-gray-200);
Copy link
Member Author

Choose a reason for hiding this comment

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

}

&.has-subtle-light-gray-background-color {
Expand Down Expand Up @@ -93,6 +93,6 @@
border-color: transparent;
}

border-bottom: 1px solid $light-gray-200;
border-bottom: 1px solid var(--wp--color--foreground-200, $light-gray-200);
}
}
2 changes: 1 addition & 1 deletion packages/block-library/src/verse/editor.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pre.wp-block-verse {
color: $dark-gray-900;
color: var(--wp--color--foreground-900, $dark-gray-900);
Copy link
Member Author

Choose a reason for hiding this comment

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

white-space: nowrap;
font-family: inherit;
font-size: inherit;
Expand Down