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

Generate inline styles for the block editor from theme support declarations #198

Merged
merged 14 commits into from
Mar 14, 2019
Merged
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
56 changes: 56 additions & 0 deletions config/block-editor-settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Block Editor settings specific to Genesis Sample.
*
* @package Genesis Sample
* @author StudioPress
* @license GPL-2.0-or-later
* @link https://www.studiopress.com/
*/

$genesis_sample_link_color = get_theme_mod( 'genesis_sample_link_color', genesis_sample_customizer_get_default_link_color() );
$genesis_sample_link_color_contrast = genesis_sample_color_contrast( $genesis_sample_link_color );
$genesis_sample_link_color_brightness = genesis_sample_color_brightness( $genesis_sample_link_color, 35 );

return array(
'admin-fonts-url' => 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700',
'content-width' => 1062,
'default-button-bg' => $genesis_sample_link_color,
'default-button-color' => $genesis_sample_link_color_contrast,
'default-button-outline-hover' => $genesis_sample_link_color_brightness,
'default-link-color' => $genesis_sample_link_color,
'editor-color-palette' => array(
array(
'name' => __( 'Custom color', 'genesis-sample' ), // Called “Link Color” in the Customizer options. Renamed because “Link Color” implies it can only be used for links.
'slug' => 'theme-primary',
'color' => get_theme_mod( 'genesis_sample_link_color', genesis_sample_customizer_get_default_link_color() ),
),
array(
'name' => __( 'Accent color', 'genesis-sample' ),
'slug' => 'theme-secondary',
'color' => get_theme_mod( 'genesis_sample_accent_color', genesis_sample_customizer_get_default_accent_color() ),
),
),
'editor-font-sizes' => array(
array(
'name' => __( 'Small', 'genesis-sample' ),
'size' => 12,
'slug' => 'small',
),
array(
'name' => __( 'Normal', 'genesis-sample' ),
'size' => 18,
'slug' => 'normal',
),
array(
'name' => __( 'Large', 'genesis-sample' ),
'size' => 20,
'slug' => 'large',
),
array(
'name' => __( 'Larger', 'genesis-sample' ),
'size' => 24,
'slug' => 'larger',
),
),
);
29 changes: 0 additions & 29 deletions config/editor-color-palette.php

This file was deleted.

34 changes: 0 additions & 34 deletions config/editor-font-sizes.php

This file was deleted.

22 changes: 7 additions & 15 deletions config/import/content/homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,19 @@
<!-- /wp:atomic-blocks/ab-spacer -->

<!-- wp:atomic-blocks/ab-container {"containerPaddingTop":12,"containerPaddingRight":5,"containerPaddingBottom":2.5,"containerPaddingLeft":5,"containerMarginTop":6,"containerMarginBottom":5,"containerWidth":"full","containerMaxWidth":1062,"containerBackgroundColor":"#333"} -->
<div style="background-color:#333;padding-left:5%;padding-right:5%;padding-bottom:2.5%;padding-top:12%;margin-top:6%;margin-bottom:5%" class="wp-block-atomic-blocks-ab-container alignfull ab-block-container"><div class="ab-container-inside"><div class="ab-container-content" style="max-width:1062px"><!-- wp:columns -->
<div style="background-color:#333;padding-left:5%;padding-right:5%;padding-bottom:2.5%;padding-top:12%;margin-top:6%;margin-bottom:5%" class="wp-block-atomic-blocks-ab-container ab-block-container alignfull"><div class="ab-container-inside"><div class="ab-container-content" style="max-width:1062px"><!-- wp:columns -->
<div class="wp-block-columns has-2-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:paragraph {"align":"left","textColor":"light-gray","customFontSize":40} -->
<p style="font-size:40px;text-align:left" class="has-text-color has-light-gray-color">Contact us today</p>
<div class="wp-block-column"><!-- wp:paragraph {"align":"left","customTextColor":"#f5f5f5","customFontSize":40} -->
<p style="color:#f5f5f5;font-size:40px;text-align:left" class="has-text-color">Contact us today</p>
<!-- /wp:paragraph --></div>
<!-- /wp:column -->

<!-- wp:column -->
<div class="wp-block-column"><!-- wp:button {"align":"right","className":"is-style-outline"} -->
<div class="wp-block-button alignright is-style-outline"><a class="wp-block-button__link" href="#">Get in touch</a></div>
<!-- /wp:button -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div>
<div class="wp-block-column"><!-- wp:button {"customTextColor":"#f5f5f5","align":"right","className":"is-style-outline"} -->
<div class="wp-block-button alignright is-style-outline"><a class="wp-block-button__link has-text-color" href="#" style="color:#f5f5f5">Get in touch</a></div>
<!-- /wp:button --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div></div></div>
<!-- /wp:columns --></div></div></div>
<!-- /wp:atomic-blocks/ab-container -->

<!-- wp:atomic-blocks/ab-spacer {"spacerHeight":60} -->
Expand Down
71 changes: 11 additions & 60 deletions lib/gutenberg/front-end.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/* Font Sizes
---------------------------------------------------------------------------- */

.site-container p.has-small-font-size {
font-size: 12px;
}

.site-container p.has-regular-font-size {
font-size: 16px;
}

.site-container p.has-large-font-size {
font-size: 20px;
}

.site-container p.has-larger-font-size {
font-size: 24px;
}

/* Drop Caps
---------------------------------------------------------------------------- */

Expand All @@ -41,33 +22,6 @@ h6.light {
color: #f5f5f5;
}

/* Color Palette
---------------------------------------------------------------------------- */

.site-container .has-light-gray-background-color {
background-color: #f5f5f5 !important;
}

.site-container .has-light-gray-color {
color: #f5f5f5 !important;
}

.site-container .has-medium-gray-background-color {
background-color: #999 !important;
}

.site-container .has-medium-gray-color {
color: #999 !important;
}

.site-container .has-dark-gray-background-color {
background-color: #333 !important;
}

.site-container .has-dark-gray-color {
color: #333 !important;
}

/* Background Color
---------------------------------------------------------------------------- */

Expand Down Expand Up @@ -175,13 +129,12 @@ h6.light {
font-weight: 600;
}

.wp-block-button .wp-block-button__link {
background-color: #333;
border: 0;
.site-container .wp-block-button .wp-block-button__link {
border-width: 0;
border-radius: 5px;
color: #fff;
cursor: pointer;
font-size: 16px;
font-family: "Source Sans Pro", sans-serif;
font-weight: 600;
padding: 15px 30px;
text-align: center;
Expand All @@ -190,26 +143,24 @@ h6.light {
width: auto;
}

.wp-block-button.is-style-outline .wp-block-button__link:focus,
.wp-block-button.is-style-outline .wp-block-button__link:hover,
.wp-block-button .wp-block-button__link:focus,
.wp-block-button .wp-block-button__link:hover {
box-shadow: inset 0 0 200px rgba(230, 230, 230, 0.15);
}

/* Button Variations */
.wp-block-button.is-style-squared .wp-block-button__link {
.site-container .wp-block-button.is-style-squared .wp-block-button__link {
border-radius: 0;
}

.wp-block-button.is-style-outline .wp-block-button__link {
.site-container .wp-block-button.is-style-outline .wp-block-button__link {
background-color: transparent;
border: 2px solid currentColor;
border-radius: 0;
color: #333;
padding: 13px 28px;
}

.site-container .wp-block-button .wp-block-button__link:focus,
.site-container .wp-block-button .wp-block-button__link:hover,
.site-container .wp-block-button.is-style-outline .wp-block-button__link:focus,
.site-container .wp-block-button.is-style-outline .wp-block-button__link:hover {
box-shadow: inset 0 0 200px rgba(230, 230, 230, 0.25);
}

/* Blockquotes and captions
---------------------------------------------------------------------------- */
Expand Down
16 changes: 12 additions & 4 deletions lib/gutenberg/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ function genesis_sample_enqueue_gutenberg_frontend_styles() {
*/
function genesis_sample_block_editor_styles() {

$block_editor_settings = genesis_get_config( 'block-editor-settings' );

wp_enqueue_style(
'genesis-sample-gutenberg-fonts',
'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700',
$block_editor_settings['admin-fonts-url'],
array(),
CHILD_THEME_VERSION
);
Expand Down Expand Up @@ -95,25 +97,31 @@ function genesis_sample_blocks_body_classes( $classes ) {
// Make media embeds responsive.
add_theme_support( 'responsive-embeds' );

$genesis_sample_block_editor_settings = genesis_get_config( 'block-editor-settings' );

// Adds support for editor font sizes.
add_theme_support(
'editor-font-sizes',
genesis_get_config( 'editor-font-sizes' )
$genesis_sample_block_editor_settings['editor-font-sizes']
);

// Adds support for editor color palette.
add_theme_support(
'editor-color-palette',
genesis_get_config( 'editor-color-palette' )
$genesis_sample_block_editor_settings['editor-color-palette']
);

require_once get_stylesheet_directory() . '/lib/gutenberg/inline-styles.php';

add_action( 'after_setup_theme', 'genesis_sample_content_width', 0 );
/**
* Set content width to match the “wide” Gutenberg block width.
*/
function genesis_sample_content_width() {

$block_editor_settings = genesis_get_config( 'block-editor-settings' );

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/924
$GLOBALS['content_width'] = apply_filters( 'genesis_sample_content_width', 1062 );
$GLOBALS['content_width'] = apply_filters( 'genesis_sample_content_width', $block_editor_settings['content-width'] );

}
Loading