Browse Source

Libre 2: Start building out Gutenberg styles and support.

Laurel Fulford 6 years ago
parent
commit
2608cb97f0
4 changed files with 710 additions and 1 deletions
  1. 312 0
      libre-2/css/blocks.css
  2. 350 0
      libre-2/css/editor-blocks.css
  3. 27 1
      libre-2/functions.php
  4. 21 0
      libre-2/style.css

+ 312 - 0
libre-2/css/blocks.css

@@ -0,0 +1,312 @@
+/*
+Theme Name: Libre 2
+Description: Used to style Gutenberg Blocks.
+*/
+
+/*--------------------------------------------------------------
+>>> TABLE OF CONTENTS:
+----------------------------------------------------------------
+1.0 Block Alignments
+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 Block Alignments
+--------------------------------------------------------------*/
+
+.singular.no-sidebar {
+	overflow-x: hidden; /* prevents side-scrolling caused by use of vw */
+}
+
+.alignfull,
+.alignwide {
+	clear: both;
+}
+
+@media (min-width: 1140px) {
+	.singular.no-sidebar .alignwide {
+		margin-left: -25%;
+		margin-right: -25%;
+		max-width: 1000%;
+		width: auto;
+	}
+
+	.singular.no-sidebar .wp-block-embed.is-type-video.alignwide iframe {
+		width: 100% !important;
+		height: 100% !important;
+	}
+}
+
+.singular.no-sidebar .alignfull {
+	margin-left: calc(50% - 50vw);
+	margin-right: calc(50% - 50vw);
+	max-width: 1000%;
+	width: auto;
+}
+
+/* Make non image-based blocks a bit narrower, so they don't get cut off. */
+.singular.no-sidebar .wp-block-columns.alignfull,
+.singular.no-sidebar .wp-block-audio.alignfull,
+.singular.no-sidebar .wp-block-table.alignfull,
+.singular.no-sidebar .wp-block-latest-comments.alignfull,
+.singular.no-sidebar .wp-block-categories.alignfull,
+.singular.no-sidebar .wp-block-latest-posts.alignfull {
+	margin-left: calc(50% - 48vw);
+	margin-right: calc(50% - 48vw);
+}
+
+.singular.no-sidebar .wp-block-embed.is-type-video iframe {
+	max-height: 100%;
+}
+
+.singular.no-sidebar .wp-block-embed.is-type-video.alignfull iframe {
+	width: 100% !important;
+	height: 100% !important;
+}
+
+/*--------------------------------------------------------------
+2.0 General Block Styles
+--------------------------------------------------------------*/
+
+/*--------------------------------------------------------------
+3.0 Blocks - Common Blocks
+--------------------------------------------------------------*/
+
+/* Paragraph */
+
+p.has-drop-cap:not(:focus)::first-letter {
+	font-size: 5em;
+	margin-top: 0.15em;
+}
+
+/* Gallery */
+
+.wp-block-gallery {
+	margin: 0 0 1.75em;
+}
+
+/* Quote */
+
+.wp-block-quote.is-large p,
+.wp-block-quote.is-style-large p {
+	font-size: 1.25em;
+	font-style: normal;
+}
+
+.wp-block-quote.is-large,
+.wp-block-quote.is-style-large {
+	border: 0;
+	padding: 0;
+}
+
+.wp-block-quote.is-large cite,
+.wp-block-quote.is-style-large cite {
+	font-size: inherit;
+	text-align: inherit;
+}
+
+/* Audio */
+
+.wp-block-audio {
+	margin: 0 0 1.75em;
+}
+
+.wp-block-audio audio {
+	display: block;
+	width: 100%;
+}
+
+/* Cover */
+
+.wp-block-cover.aligncenter,
+.wp-block-cover-image.aligncenter,
+.wp-block-cover.alignleft,
+.wp-block-cover-image.alignleft,
+.wp-block-cover.alignright,
+.wp-block-cover-image.alignright {
+	display: flex;
+}
+
+
+/* File */
+
+.wp-block-file a:not(.wp-block-file__button),
+.wp-block-file a:not(.wp-block-file__button):hover {
+	box-shadow: none;
+}
+
+.wp-block-file a.wp-block-file__button,
+.wp-block-file a.wp-block-file__button:visited {
+	border: 0 none;
+	border-radius: 0;
+	box-shadow: 0 2px 0 0 currentColor;
+	background: transparent;
+	color: #404040;
+	font-size: 18px;
+	font-size: 1rem;
+	font-weight: bold;
+	padding: 0.21875em 0;
+	transition: 0.2s;
+}
+
+.wp-block-file a.wp-block-file__button:hover,
+.wp-block-file a.wp-block-file__button:focus,
+.wp-block-file a.wp-block-file__button:active {
+	background: transparent;
+	box-shadow: 0 4px 0 0 currentColor;
+	color: #404040;
+	outline: none;
+}
+
+.rtl .wp-block-file * + .wp-block-file__button {
+	margin-left: .75em;
+	margin-right: 0;
+}
+
+/*--------------------------------------------------------------
+4.0 Blocks - Formatting
+--------------------------------------------------------------*/
+
+/* Verse */
+
+.wp-block-verse {
+	font-family: inherit;
+	font-style: italic;
+	padding: 0;
+}
+
+/* Code */
+
+/* Preformatted */
+
+/* Pullquote */
+
+.wp-block-pullquote {
+
+}
+
+.wp-block-pullquote blockquote {
+	margin-left: inherit;
+	padding: 0;
+}
+
+.wp-block-pullquote blockquote:before {
+	display: none;
+}
+
+.wp-block-pullquote cite {
+
+}
+
+.wp-block-pullquote.alignleft cite,
+.wp-block-pullquote.alignright cite {
+	font-size: 20px;
+}
+
+/* Table */
+
+.wp-block-table th {
+	text-align: left;
+}
+
+@media (min-width: 1140px) {
+	.singular.no-sidebar .wp-block-table.alignwide {
+		width: 1100px;
+	}
+}
+
+.singular.no-sidebar .wp-block-table.alignfull {
+	width: 96vw;
+}
+
+.rtl .wp-block-table th {
+	text-align: right;
+}
+
+/*--------------------------------------------------------------
+5.0 Blocks - Layout Elements
+--------------------------------------------------------------*/
+
+/* Buttons */
+
+.wp-block-button .wp-block-button__link {
+	border: 0 none;
+	border-radius: 0;
+	box-shadow: 0 2px 0 0 currentColor;
+	background: transparent;
+	color: #404040;
+	font-size: 18px;
+	font-size: 1rem;
+	font-weight: bold;
+	padding: 0.21875em 0;
+	transition: 0.2s;
+}
+
+.wp-block-button .wp-block-button__link:hover,
+.wp-block-button .wp-block-button__link:focus,
+.wp-block-button .wp-block-button__link:active {
+	background: transparent;
+	box-shadow: 0 4px 0 0 currentColor;
+	color: #404040;
+	outline: none;
+}
+
+/* Columns */
+
+/* Separator */
+
+.wp-block-separator {
+	border: 0;
+}
+
+.wp-block-separator:not(.is-style-wide):not(.is-style-dots) {
+	margin-left: auto;
+	margin-right: auto;
+	max-width: 100px;
+}
+
+/* Media & Text */
+
+.wp-block-media-text {
+	margin-bottom: 1.75em;
+}
+
+.wp-block-media-text *:last-child {
+	margin-bottom: 0;
+}
+
+/*--------------------------------------------------------------
+6.0 Blocks - Widgets
+--------------------------------------------------------------*/
+
+/* Categories, Latest Posts & Archives */
+
+.wp-block-categories.aligncenter,
+.wp-block-categories.aligncenter ul,
+.wp-block-latest-posts.aligncenter,
+.wp-block-archives.aligncenter {
+	list-style-position: inside;
+	margin-left: 0;
+	margin-right: 0;
+	padding-left: 0;
+	padding-right: 0;
+	text-align: center;
+}
+
+/* Latest Comments */
+
+.wp-block-latest-comments {
+	margin-left: 0;
+	margin-right: 0;
+}
+
+/* Latest Posts */
+
+.wp-block-latest-posts.is-grid {
+	margin-left: 0;
+	margin-right: 0;
+}

+ 350 - 0
libre-2/css/editor-blocks.css

@@ -0,0 +1,350 @@
+/*
+Theme Name: Libre 2
+Description: Used to style Gutenberg Blocks in the editor.
+*/
+
+/*--------------------------------------------------------------
+>>> TABLE OF CONTENTS:
+----------------------------------------------------------------
+1.0 General Typography
+2.0 General Block Settings
+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,
+.editor-default-block-appender input[type="text"].editor-default-block-appender__content {
+	font-family: "Libre Baskerville", Libre, Georgia, Times, serif;
+}
+
+.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-size: 16px;
+}
+
+.edit-post-visual-editor .editor-block-list__block {
+	color: #404040;
+}
+
+/* Post title */
+
+.editor-post-title__block .editor-post-title__input {
+	color: #404040;
+	font-family: "Libre Baskerville", Libre, Georgia, Times, serif;
+	font-size: 29px;
+}
+
+@media screen and ( min-width: 720px ) {
+	.editor-post-title__block .editor-post-title__input {
+		font-size: 47px;
+	}
+}
+
+/* Headings */
+
+.edit-post-visual-editor h1,
+.wp-block-freeform.block-library-rich-text__tinymce h1 {
+	font-size: 29px;
+}
+
+.edit-post-visual-editor h2,
+.wp-block-freeform.block-library-rich-text__tinymce h2 {
+	font-size: 23px;
+}
+
+.edit-post-visual-editor h3,
+.wp-block-freeform.block-library-rich-text__tinymce h3 {
+	font-size: 18px;
+}
+
+.edit-post-visual-editor h4,
+.wp-block-freeform.block-library-rich-text__tinymce h4 {
+	font-size: 14px;
+}
+
+.edit-post-visual-editor h5,
+.wp-block-freeform.block-library-rich-text__tinymce h5 {
+	font-size: 13px;
+}
+
+.edit-post-visual-editor h6,
+.wp-block-freeform.block-library-rich-text__tinymce h6 {
+	font-size: 12px;
+}
+
+@media screen and (min-width: 720px) {
+	.edit-post-visual-editor h1,
+	.wp-block-freeform.block-library-rich-text__tinymce h1 {
+		font-size: 47px;
+	}
+
+	.edit-post-visual-editor h2,
+	.wp-block-freeform.block-library-rich-text__tinymce h2 {
+		font-size: 29px;
+	}
+
+	.edit-post-visual-editor h3,
+	.wp-block-freeform.block-library-rich-text__tinymce h3 {
+		font-size: 23px;
+	}
+
+	.edit-post-visual-editor h4,
+	.wp-block-freeform.block-library-rich-text__tinymce h4 {
+		font-size: 18px;
+	}
+
+	.edit-post-visual-editor h5,
+	.wp-block-freeform.block-library-rich-text__tinymce h5 {
+		font-size: 14px;
+	}
+
+	.edit-post-visual-editor h6,
+	.wp-block-freeform.block-library-rich-text__tinymce h6 {
+		font-size: 13px;
+	}
+}
+
+/*--------------------------------------------------------------
+2.0 General Block Settings
+--------------------------------------------------------------*/
+
+/* Main content width */
+
+.wp-block {
+	width: 705px; /* 675px + 30px to account for padding */
+}
+
+/* Link styles */
+
+.edit-post-visual-editor a,
+.editor-block-list__block a,
+.wp-block-freeform.block-library-rich-text__tinymce a {
+
+}
+
+
+/* Table styles */
+
+.wp-block-freeform.block-library-rich-text__tinymce table,
+.wp-block-freeform.block-library-rich-text__tinymce table th,
+.wp-block-freeform.block-library-rich-text__tinymce table td {
+
+}
+
+.wp-block-freeform.block-library-rich-text__tinymce table {
+
+}
+
+
+.rtl .wp-block-freeform.block-library-rich-text__tinymce td,
+.rtl .wp-block-freeform.block-library-rich-text__tinymce th {
+	text-align: right;
+}
+
+/* Quote styles */
+
+.wp-block-freeform.block-library-rich-text__tinymce blockquote {
+
+}
+
+.wp-block-freeform.block-library-rich-text__tinymce blockquote,
+.wp-block-freeform.block-library-rich-text__tinymce blockquote > p {
+
+}
+
+.wp-block-freeform.block-library-rich-text__tinymce blockquote cite {
+
+}
+
+/* Definition List styles */
+
+.wp-block-freeform.block-library-rich-text__tinymce dt {
+	font-weight: bold;
+}
+
+/* Pre styles */
+
+.wp-block-freeform.block-library-rich-text__tinymce pre {
+
+}
+
+/*--------------------------------------------------------------
+3.0 Blocks - Common Blocks
+--------------------------------------------------------------*/
+
+/* Paragraph */
+
+p.has-drop-cap:not(:focus)::first-letter {
+	font-size: 5em;
+	margin-top: 0.15em;
+}
+
+/* Quote */
+
+.wp-block-quote {
+
+}
+
+.wp-block-quote:not(.is-large):not(.is-style-large) {
+
+}
+
+.wp-block-quote__citation {
+
+}
+
+/* Cover */
+
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover-image .wp-block-cover-image-text,
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover-image .wp-block-cover-text,
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover-image h2,
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover .wp-block-cover-image-text,
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover .wp-block-cover-text,
+.edit-post-visual-editor .editor-block-list__block .wp-block-cover h2 {
+	font-size: 1.5em;
+}
+
+/* File */
+
+.wp-block-file .wp-block-file__button {
+
+}
+
+.wp-block-file .wp-block-file__button:focus,
+.wp-block-file .wp-block-file__button:active {
+
+}
+
+.wp-block-file .wp-block-file__button:hover {
+
+}
+
+/*--------------------------------------------------------------
+4.0 Blocks - Formatting
+--------------------------------------------------------------*/
+
+/* Verse */
+
+.wp-block-verse {
+	font-style: italic;
+}
+
+.wp-block-verse pre {
+	padding: 0;
+}
+
+/* Code */
+
+.wp-block-code {
+	border: none;
+	border-radius: 0;
+}
+
+.wp-block-code textarea {
+	background: transparent;
+}
+
+.wp-block-code .editor-plain-text {
+
+}
+
+/* Preformatted */
+
+.wp-block-preformatted {
+
+}
+
+.wp-block-preformatted pre {
+
+}
+
+/* Pullquote */
+
+.wp-block-pullquote {
+
+}
+
+.wp-block-pullquote blockquote {
+
+}
+
+.wp-block-pullquote .wp-block-pullquote__citation {
+
+}
+
+.wp-block-pullquote.alignleft blockquote > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
+.wp-block-pullquote.alignright blockquote > .block-library-pullquote__content .editor-rich-text__tinymce[data-is-empty="true"]::before,
+.wp-block-pullquote.alignleft blockquote > .editor-rich-text p,
+.wp-block-pullquote.alignright blockquote > .editor-rich-text p {
+	font-size: 20px;
+}
+
+/* Table */
+
+.wp-block-table {
+
+}
+
+.wp-block-table td,
+.wp-block-table th {
+
+}
+
+.wp-block-table th {
+
+}
+
+.wp-block-table td {
+
+}
+
+.wp-block-table__cell-content {
+	padding: 0;
+}
+
+/*--------------------------------------------------------------
+5.0 Blocks - Layout Elements
+--------------------------------------------------------------*/
+
+/* Buttons */
+
+.wp-block-button .wp-block-button__link {
+
+}
+
+.wp-block-button .wp-block-button__link:focus,
+.wp-block-button .wp-block-button__link:active {
+
+}
+
+.wp-block-button .wp-block-button__link:hover {
+
+}
+
+/* Separator */
+
+.wp-block-separator {
+	background-color: #ccc;
+	border: 0;
+	height: 1px;
+}
+
+/*--------------------------------------------------------------
+6.0 Blocks - Widgets
+--------------------------------------------------------------*/
+
+/* Categories, Latest Posts & Archives */
+
+[data-align="center"] .wp-block-categories ul,
+[data-align="center"] .wp-block-latest-posts ul,
+[data-align="center"] .wp-block-archives ul {
+	list-style-position: inside;
+}

+ 27 - 1
libre-2/functions.php

@@ -72,6 +72,15 @@ function libre_2_setup() {
 	add_theme_support( 'custom-background', apply_filters( 'libre_2_custom_background_args', array(
 		'default-color' => 'ffffff',
 	) ) );
+
+	// Load regular editor styles into the new block-based editor.
+	add_theme_support( 'editor-styles' );
+
+	// Add support for responsive embeds.
+	add_theme_support( 'responsive-embeds' );
+
+	// Add support for full and wide align images.
+	add_theme_support( 'align-wide' );
 }
 endif; // libre_2_setup
 add_action( 'after_setup_theme', 'libre_2_setup' );
@@ -187,7 +196,8 @@ function libre_2_fonts_url() {
  * @param array  $urls           URLs to print for resource hints.
  * @param string $relation_type  The relation type the URLs are printed.
  * @return array $urls           URLs to print for resource hints.
-
+ */
+/*
 function libre_2_resource_hints( $urls, $relation_type ) {
 	if ( wp_style_is( 'libre-2-fonts', 'queue' ) && 'preconnect' === $relation_type ) {
 		$urls[] = array(
@@ -207,6 +217,9 @@ add_filter( 'wp_resource_hints', 'libre_2_resource_hints', 10, 2 );
 function libre_2_scripts() {
 	wp_enqueue_style( 'libre-2-style', get_stylesheet_uri() );
 
+	// Theme block stylesheet.
+	wp_enqueue_style( 'libre-2-block-style', get_theme_file_uri( '/css/blocks.css' ), array( 'libre-2-style' ), '1.0' );
+
 	wp_enqueue_style( 'libre-2-fonts', libre_2_fonts_url(), array(), null );
 
 	wp_enqueue_script( 'libre-2-script', get_template_directory_uri() . '/js/libre.js', array( 'jquery' ), '20150623', true );
@@ -224,6 +237,19 @@ function libre_2_scripts() {
 }
 add_action( 'wp_enqueue_scripts', 'libre_2_scripts' );
 
+/**
+ * Enqueue editor styles for Gutenberg
+ */
+function libre_2_block_editor_styles() {
+	// Block styles.
+	wp_enqueue_style( 'libre-2-block-editor-style', get_theme_file_uri( '/css/editor-blocks.css' ) );
+
+	// Fonts.
+	wp_enqueue_style( 'libre-2-fonts', libre_2_fonts_url(), array(), null );
+}
+add_action( 'enqueue_block_editor_assets', 'libre_2_block_editor_styles' );
+
+
 /*
  * Filters the Categories archive widget to add a span around the post count
  */

+ 21 - 0
libre-2/style.css

@@ -612,6 +612,27 @@ textarea {
 	position: relative;
 	padding-top: 1.75em;
 }
+
+@media (min-width: 720px) {
+	.singular .site-header:before,
+	.singular .site-header:after {
+		background: inherit;
+		bottom: 0;
+		content: "";
+		position: absolute;
+		top: 0;
+		width: 100%;
+	}
+
+	.singular .site-header:before {
+		right: 100%;
+	}
+
+	.singular .site-header:after {
+		left: 100%;
+	}
+}
+
 .site-branding {
 	max-width: 70%;
 }