Twenty Eleven: Add styles and support for the new block-based editor.

This update adds styles and theme support related to the new block-based editor to enhance the experience of using it with Twenty Eleven.

These are the specific changes made to this theme:

- Add `blocks.css`, to style blocks on the front end, to make sure they match the theme’s existing HTML element styles.
- Add `editor-blocks.css` to style blocks in the editor, to make sure they match the theme’s existing HTML element styles.
- Add theme support for `editor-styles`, to pull the existing editor stylesheet into the new editor.
- Add theme support for `wp-block-styles`, to load the default block styles on the front end.
- Add theme support for `editor-color-palette`, to load a color palette based on the theme’s color scheme into the block-based editor. 

Props ianbelanger, laurelfulford, davidakennedy.

Merges [43794] to trunk.

Fixes #45039.

git-svn-id: https://develop.svn.wordpress.org/trunk@44139 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2018-12-14 01:50:30 +00:00
parent 82b3fac279
commit 25fd0f8438
3 changed files with 876 additions and 0 deletions

View File

@ -0,0 +1,368 @@
/*
Theme Name: Twenty Eleven
Description: Used to style Gutenberg Blocks.
*/
/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
1.0 General Block Styles
2.0 Blocks - Common Blocks
3.0 Blocks - Formatting
4.0 Blocks - Layout Elements
5.0 Blocks - Widgets
6.0 Blocks - Colors
--------------------------------------------------------------*/
/*--------------------------------------------------------------
1.0 General Block Styles
--------------------------------------------------------------*/
figure[class^="wp-block-"] {
margin-left: 0;
margin-right: 0;
}
/* Captions */
[class^="wp-block-"] figcaption {
font-family: Georgia, serif;
font-size: 12px;
}
[class^="wp-block-"]:not(.wp-block-gallery) figcaption {
color: #666;
margin-bottom: 1.625em;
max-width: 96%;
max-width: calc( 100% - 18px );
padding: 3px 0 5px 40px;
position: relative;
text-align: left;
}
[class^="wp-block-"]:not(.wp-block-gallery) figcaption:before {
color: #666;
content: '\2014';
font-size: 14px;
font-style: normal;
font-weight: bold;
margin-right: 5px;
position: absolute;
left: 10px;
top: 0;
}
.rtl [class^="wp-block-"]:not(.wp-block-gallery) figcaption {
padding-left: 0;
padding-right: 40px;
text-align: right;
}
.rtl [class^="wp-block-"]:not(.wp-block-gallery) figcaption:before {
left: 0;
margin-left: 5px;
margin-right: 0;
right: 10px;
}
/*--------------------------------------------------------------
2.0 Blocks - Common Blocks
--------------------------------------------------------------*/
/* Paragraph */
p.has-drop-cap:not(:focus)::first-letter {
font-size: 5em;
margin-top: 0.1em;
}
/* Gallery */
.wp-block-gallery {
margin: 0 0 1.625em;
}
.wp-block-gallery .blocks-gallery-item figcaption {
margin-bottom: 0;
padding-left: 0;
padding-right: 0;
}
.wp-block-gallery .blocks-gallery-item img {
border: 0;
padding: 0;
}
/* Quote */
.wp-block-quote {
margin: 0 3em;
}
.wp-block-quote:not(.is-large):not(.is-style-large) {
border: 0;
padding-left: 0;
padding-right: 0;
}
.wp-block-quote.is-large p,
.wp-block-quote.is-style-large p {
font-size: 20px;
}
.wp-block-quote cite {
color: #666;
font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.wp-block-quote.is-large cite,
.wp-block-quote.is-style-large cite {
font-size: 16px;
}
/* Audio */
.wp-block-audio audio {
display: block;
width: 100%;
}
/* Cover Image */
.wp-block-cover-image.aligncenter {
clear: both;
display: flex;
}
.wp-block-cover-image.alignleft {
margin-right: 1.625em;
}
.wp-block-cover-image.alignright {
margin-left: 1.625em;
}
/* File */
.wp-block-file .wp-block-file__button {
background: #222;
border: none;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
color: #eee;
cursor: pointer;
font-size: 15px;
padding: 5px 22px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
}
.wp-block-file .wp-block-file__button:active {
background: #1982d1;
color: #bfddf3;
}
.rtl .wp-block-file * + .wp-block-file__button {
margin-left: 0.75em;
margin-right: 0;
}
/*--------------------------------------------------------------
3.0 Blocks - Formatting
--------------------------------------------------------------*/
/* Code */
.wp-block-code {
background-color: transparent;
border: 0;
padding: 0;
}
/* Pullquote */
.wp-block-pullquote__citation,
.wp-block-pullquote cite,
.wp-block-pullquote footer {
color: #141412;
}
.wp-block-pullquote.alignleft {
margin-right: 1.625em;
}
.wp-block-pullquote.alignright {
margin-left: 1.625em;
}
/* Table */
.wp-block-table {
border-bottom: 1px solid #ddd;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
}
.wp-block-table th {
border: 0;
font-weight: bold;
padding: 6px 10px 6px 0;
text-transform: uppercase;
}
.wp-block-table td {
border: 0;
border-top: 1px solid #ddd;
padding: 6px 10px 6px 0;
}
/*--------------------------------------------------------------
4.0 Blocks - Layout Elements
--------------------------------------------------------------*/
/* Buttons */
.wp-block-button .wp-block-button__link {
background: #222;
border: none;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
color: #eee;
cursor: pointer;
font-size: 15px;
margin: 20px 0;
padding: 5px 22px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
}
.wp-block-button .wp-block-button__link:active {
background: #1982d1;
color: #bfddf3;
}
/* Separator */
.wp-block-separator {
border: 0;
max-width: 100px;
}
.wp-block-separator.is-style-wide {
max-width: 100%;
}
/*--------------------------------------------------------------
5.0 Blocks - Widgets
--------------------------------------------------------------*/
/* Latest Comments */
.wp-block-latest-comments {
margin: 0;
padding: 0;
}
.wp-block-latest-comments .avatar,
.wp-block-latest-comments__comment-avatar {
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px #ccc;
-moz-box-shadow: 0 1px 2px #ccc;
box-shadow: 0 1px 2px #ccc;
}
.wp-block-latest-comments__comment,
.wp-block-latest-comments__comment-excerpt,
.wp-block-latest-comments__comment-excerpt p {
font-size: 15px;
}
.wp-block-latest-comments__comment-excerpt p:last-child {
margin-bottom: 0;
}
.wp-block-latest-comments__comment-meta,
.wp-block-latest-comments__comment-date {
color: #666;
font-size: 12px;
line-height: 2.2em;
}
.wp-block-latest-comments__comment-meta a {
font-weight: bold;
}
.wp-block-latest-comments .wp-block-latest-comments__comment {
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0 0 2.625em;
position: relative;
}
/* Latest Posts */
.wp-block-latest-posts.is-grid {
margin-left: 0;
margin-right: 0;
}
/*--------------------------------------------------------------
6.0 Blocks - Colors
--------------------------------------------------------------*/
.has-blue-color {
color: #1982d1;
}
.has-blue-background-color {
background-color: #1982d1;
}
.has-black-color {
color: #000;
}
.has-black-background-color {
background-color: #000;
}
.has-dark-gray-color {
color: #373737;
}
.has-dark-gray-background-color {
background-color: #373737;
}
.has-medium-gray-color {
color: #666;
}
.has-medium-gray-background-color {
background-color: #666;
}
.has-light-gray-color {
color: #e2e2e2;
}
.has-light-gray-background-color {
background-color: #e2e2e2;
}
.has-white-color {
color: #fff;
}
.has-white-background-color {
background-color: #fff;
}

View File

@ -0,0 +1,443 @@
/*
Theme Name: Twenty Eleven
Description: Used to style Gutenberg Blocks in the editor.
*/
/*--------------------------------------------------------------
>>> TABLE OF CONTENTS:
----------------------------------------------------------------
1.0 General Typography
2.0 General Block Styles
3.0 Blocks - Common Blocks
4.0 Blocks - Formatting
5.0 Blocks - Layout Elements
6.0 Blocks - Widgets
--------------------------------------------------------------*/
/*--------------------------------------------------------------
1.0 General Typography
--------------------------------------------------------------*/
.edit-post-visual-editor .editor-block-list__block,
.edit-post-visual-editor .editor-block-list__block p,
.editor-default-block-appender input[type="text"].editor-default-block-appender__content {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 15px;
font-size: 300;
line-height: 1.625;
}
.edit-post-visual-editor .editor-block-list__block {
color: #333;
}
.editor-post-title__block .editor-post-title__input {
color: #000;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 36px;
line-height: 48px;
}
.edit-post-visual-editor h1,
.wp-block-freeform.block-library-rich-text__tinymce h1,
.edit-post-visual-editor h2,
.wp-block-freeform.block-library-rich-text__tinymce h2 {
font-size: 15px;
margin: 0 0 0.8125em;
}
.edit-post-visual-editor h3,
.wp-block-freeform.block-library-rich-text__tinymce h3 {
font-size: 10px;
font-weight: 300;
letter-spacing: 0.1em;
line-height: 2.6em;
text-transform: uppercase;
}
.edit-post-visual-editor h4,
.wp-block-freeform.block-library-rich-text__tinymce h4,
.edit-post-visual-editor h5,
.wp-block-freeform.block-library-rich-text__tinymce h5,
.edit-post-visual-editor h6,
.wp-block-freeform.block-library-rich-text__tinymce h6 {
font-size: 15px;
font-weight: 300;
line-height: 1.625;
}
/*--------------------------------------------------------------
2.0 General Block Styles
--------------------------------------------------------------*/
/* Main column width */
body.gutenberg-editor-page .edit-post-visual-editor .editor-post-title__block,
body.gutenberg-editor-page .edit-post-visual-editor .editor-default-block-appender,
body.gutenberg-editor-page .edit-post-visual-editor .editor-block-list__block {
max-width: 614px;
}
/* Link styles */
.edit-post-visual-editor a,
.editor-block-list__block a,
.wp-block-freeform.block-library-rich-text__tinymce a {
color: #1982d1;
}
/* List styles */
.edit-post-visual-editor ul:not(.wp-block-gallery),
.editor-block-list__block ul:not(.wp-block-gallery),
.block-library-list ul.editor-rich-text__tinymce,
.edit-post-visual-editor ol,
.editor-block-list__block ol,
.block-library-list ol.editor-rich-text__tinymce {
margin: 0 0 1.625em 2.5em;
padding: 0;
}
.block-library-list .editor-rich-text__tinymce {
padding: 0;
}
.edit-post-visual-editor ul:not(.wp-block-gallery),
.edit-post-visual-editor .editor-block-list__block ul:not(.wp-block-gallery),
.block-library-list ul {
list-style-type: square;
}
.edit-post-visual-editor ol,
.editor-block-list__block ol,
.block-library-list ol {
list-style: decimal;
}
.edit-post-visual-editor ol ol,
.editor-block-list__block ol ol,
.block-library-list ol ol {
list-style: upper-alpha;
}
.edit-post-visual-editor ol ol ol,
.editor-block-list__block ol ol ol,
.block-library-list ol ol ol {
list-style: lower-roman;
}
.edit-post-visual-editor ol ol ol ol,
.editor-block-list__block ol ol ol ol,
.block-library-list ol ol ol ol {
list-style: lower-alpha;
}
.edit-post-visual-editor ul:not(.wp-block-gallery) li > ul,
.editor-block-list__block ul:not(.wp-block-gallery) li > ul,
.block-library-list .editor-rich-text__tinymce li > ul,
.edit-post-visual-editor li > ol,
.editor-block-list__block li > ol,
.block-library-list .editor-rich-text__tinymce li > ol,
.wp-block-freeform.block-library-rich-text__tinymce li,
.editor-block-list__block li {
margin-bottom: 0;
}
.rtl .edit-post-visual-editor ul:not(.wp-block-gallery),
.rtl .editor-block-list__block ul:not(.wp-block-gallery),
.rtl .block-library-list ul,
.rtl .edit-post-visual-editor ol,
.rtl .editor-block-list__block ol,
.rtl .block-library-list ol {
margin-left: 0;
margin-right: 1.3333em;
}
/* Captions */
[class^="wp-block-"] figcaption {
font-family: Georgia, serif;
font-size: 12px;
}
[class^="wp-block-"]:not(.wp-block-gallery) figcaption {
color: #666;
margin-bottom: 1.625em;
max-width: 96%;
max-width: calc( 100% - 18px );
padding: 3px 0 5px 40px;
position: relative;
text-align: left;
}
[class^="wp-block-"]:not(.wp-block-gallery) figcaption:before {
color: #666;
content: '\2014';
font-size: 14px;
font-style: normal;
font-weight: bold;
margin-right: 5px;
position: absolute;
left: 10px;
top: 0;
}
.rtl [class^="wp-block-"]:not(.wp-block-gallery) figcaption {
padding-left: 0;
padding-right: 40px;
text-align: right;
}
.rtl [class^="wp-block-"]:not(.wp-block-gallery) figcaption:before {
left: 0;
margin-left: 5px;
margin-right: 0;
right: 10px;
}
/* Quote */
.wp-block-freeform.block-library-rich-text__tinymce blockquote {
border: 0;
font-style: italic;
margin: 0 3em;
padding: 0;
}
.wp-block-freeform.block-library-rich-text__tinymce blockquote p {
font-family: Georgia, "Bitstream Charter", serif;
font-size: 15px;
font-weight: normal;
}
.wp-block-freeform.block-library-rich-text__tinymce blockquote cite {
color: #666;
font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
letter-spacing: 0.05em;
text-transform: uppercase;
}
/* Code */
.wp-block-freeform.block-library-rich-text__tinymce code {
background: transparent;
}
/*--------------------------------------------------------------
3.0 Blocks - Common Blocks
--------------------------------------------------------------*/
/* Paragraph */
p.has-drop-cap:not(:focus)::first-letter {
font-size: 5em;
margin-top: 0.1em;
}
/* Gallery */
.editor-block-list__block .wp-block-gallery {
margin: 0 0 1.625em;
}
.wp-block-gallery figcaption {
margin-bottom: 0;
max-width: 100%;
}
.wp-block-gallery .blocks-gallery-item img {
border: 0;
padding: 0;
}
/* Quote */
.wp-block-quote {
font-style: italic;
font-weight: normal;
margin: 0 3em;
padding: 0;
}
.edit-post-visual-editor .editor-block-list__block .wp-block-quote p {
font-family: Georgia, "Bitstream Charter", serif;
}
.wp-block-quote:not(.is-large):not(.is-style-large) {
border: 0;
padding-left: 0;
padding-right: 0;
}
.wp-block-quote .wp-block-quote__citation.editor-rich-text__tinymce.mce-content-body {
color: #666;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: 300;
letter-spacing: 0.05em;
text-transform: uppercase;
}
.wp-block-quote.is-large p,
.wp-block-quote.is-style-large p {
font-size: 20px;
}
.wp-block-quote.is-large .wp-block-quote__citation,
.wp-block-quote.is-style-large .wp-block-quote__citation {
font-size: 16px;
}
/* Cover Image */
.edit-post-visual-editor .editor-block-list__block .wp-block-cover-image p.wp-block-cover-image-text {
font-size: 30px;
line-height: 37.5px;
}
/* File */
.wp-block-file .wp-block-file__textlink {
color: #1982d1;
}
.wp-block-file .wp-block-file__button {
background: #222;
border: none;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
color: #eee;
cursor: pointer;
font-size: 15px;
line-height: 24px;
padding: 5px 22px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
}
/*--------------------------------------------------------------
4.0 Blocks - Formatting
--------------------------------------------------------------*/
/* Code */
.wp-block-code {
background: transparent;
border: 0;
padding: 0;
}
/* Pullquote */
.edit-post-visual-editor .editor-block-list__block .wp-block-pullquote p {
font-family: Georgia, "Bitstream Charter", serif;
font-style: italic;
font-weight: normal;
}
.wp-block-pullquote.alignleft blockquote > .editor-rich-text p,
.wp-block-pullquote.alignright blockquote > .editor-rich-text p {
font-size: 20px;
}
/* Table */
.editor-block-list__block .wp-block-table th,
.editor-block-list__block .wp-block-table td {
padding: 0;
}
.wp-block-table__cell-content {
padding: 6px;
}
.rtl .editor-block-list__block .wp-block-table th,
.rtl .editor-block-list__block .wp-block-table td,
.rtl .editor-block-list__block th,
.rtl .editor-block-list__block td {
text-align: right;
}
/*--------------------------------------------------------------
5.0 Blocks - Layout Elements
--------------------------------------------------------------*/
/* Buttons */
.wp-block-button .wp-block-button__link {
background: #222;
border: none;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
color: #eee;
cursor: pointer;
font-size: 15px;
line-height: 24px;
margin: 20px 0;
padding: 5px 22px;
text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
}
/*--------------------------------------------------------------
6.0 Blocks - Widgets
--------------------------------------------------------------*/
/* Latest Comments */
.wp-block-latest-comments {
margin: 0;
padding: 0;
}
.wp-block-latest-comments .avatar,
.wp-block-latest-comments__comment-avatar {
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px #ccc;
-moz-box-shadow: 0 1px 2px #ccc;
box-shadow: 0 1px 2px #ccc;
padding: 0;
}
.wp-block-latest-comments__comment,
.wp-block-latest-comments__comment-excerpt,
.wp-block-latest-comments__comment-excerpt p {
font-size: 15px;
}
.wp-block-latest-comments__comment-excerpt p:last-child {
margin-bottom: 0;
}
.wp-block-latest-comments__comment-meta,
.wp-block-latest-comments__comment-date {
color: #666;
font-size: 12px;
line-height: 2.2em;
}
.wp-block-latest-comments__comment-meta a {
font-weight: bold;
}
.wp-block-latest-comments .wp-block-latest-comments__comment {
-moz-border-radius: 3px;
border-radius: 3px;
margin: 0 0 2.625em;
position: relative;
}
/* Latest Posts */
.edit-post-visual-editor .editor-block-list__block .wp-block-latest-posts.is-grid {
list-style: none;
margin-left: 0;
margin-right: 0;
}

View File

@ -83,6 +83,49 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) :
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// Load regular editor styles into the new block-based editor.
add_theme_support( 'editor-styles' );
// Load default block styles.
add_theme_support( 'wp-block-styles' );
// Add support for custom color scheme.
add_theme_support(
'editor-color-palette',
array(
array(
'name' => __( 'Blue', 'twentyeleven' ),
'slug' => 'blue',
'color' => '#1982d1',
),
array(
'name' => __( 'Black', 'twentyeleven' ),
'slug' => 'black',
'color' => '#000',
),
array(
'name' => __( 'Dark Gray', 'twentyeleven' ),
'slug' => 'dark-gray',
'color' => '#373737',
),
array(
'name' => __( 'Medium Gray', 'twentyeleven' ),
'slug' => 'medium-gray',
'color' => '#666',
),
array(
'name' => __( 'Light Gray', 'twentyeleven' ),
'slug' => 'light-gray',
'color' => '#e2e2e2',
),
array(
'name' => __( 'White', 'twentyeleven' ),
'slug' => 'white',
'color' => '#fff',
),
)
);
// Load up our theme options page and related code.
require( get_template_directory() . '/inc/theme-options.php' );
@ -239,6 +282,28 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) :
}
endif; // twentyeleven_setup
/**
* Enqueue scripts and styles for front end.
*
* @since Twenty Eleven 2.9
*/
function twentyeleven_scripts_styles() {
// Theme block stylesheet.
wp_enqueue_style( 'twentyeleven-block-style', get_template_directory_uri() . '/blocks.css', array(), '20181018' );
}
add_action( 'wp_enqueue_scripts', 'twentyeleven_scripts_styles' );
/**
* Enqueue editor styles for Gutenberg
*
* @since Twenty Eleven 2.9
*/
function twentyeleven_block_editor_styles() {
// Block styles.
wp_enqueue_style( 'twentyeleven-block-editor-style', get_template_directory_uri() . '/editor-blocks.css' );
}
add_action( 'enqueue_block_editor_assets', 'twentyeleven_block_editor_styles' );
if ( ! function_exists( 'twentyeleven_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog.