This repository has been archived by the owner on Jan 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
Sync customizer color settings to Gutenberg and frontend #373
Merged
Merged
Changes from 32 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
f1cce8f
Merge pull request #5 from WordPress/master
fabiankaegy 418e655
Merge pull request #6 from WordPress/master
fabiankaegy f254535
Merge pull request #7 from WordPress/master
fabiankaegy 924f4df
Merge pull request #8 from WordPress/master
fabiankaegy 3fb0305
Merge pull request #9 from WordPress/master
fabiankaegy 30a323f
Merge pull request #10 from WordPress/master
fabiankaegy ed41d5e
Added ability to change primary color of theme
fabiankaegy f5834d2
very crude working version
fabiankaegy 2fd0c30
Fix minor variable typo
kjellr 8f2f569
Merge branch 'master' into try/sync-customizer-colors-to-gutenberg
allancole a800aef
Fixing merge problems
allancole ee3040b
recompiling styles and fixing old hentry selectors
allancole a1a06f4
rename primary-color-hover strings
allancole 816ea9e
Site title and site footer should not inherit color options
allancole 629438c
syncing color styles between backend and frontend
allancole 2962e9f
Fixes cover image editor colors
allancole 4e18c94
Add custom color support for media&text block
allancole 69d6ee0
SYncing button styles between editor and frontend
allancole 7b1cefd
Clean up pull-quote styles in editor/frontend
allancole 99ad81e
Cleaning up floating for pullquotes in editor
allancole aff372b
removing unused function
allancole 410eb6f
Fix pullquote color overrides
allancole effdcbc
Cleaning up styles
allancole fd84047
recompiling styles
allancole 9e45cb1
Adds HSL support for better contrast consitency
allancole 8fe4e67
More improvements and code clean up
allancole d470e64
Various styling improvements for editor and frontend
allancole 09cc925
Re-syncing with master, add HSL color support, add dynamic styles for…
allancole 3c5a128
Code tidying
allancole 2112c57
Avoid overwriting changes from #375
kjellr 22636e6
Restore body selector to pullquote editor styles.
kjellr 86a0abf
Compile editor styles.
kjellr fbca675
Set pullquote background color to custom color by default.
kjellr 9d5e057
Fix issue where site title would appear black on single post pages wi…
kjellr cd896fc
Fix footer hover color, border for blockquotes inserted via classic e…
kjellr ce784c1
Add hover colors for Gutenberg text.
kjellr cd4891e
Fix solid color pullquote link color.
kjellr 78a870a
Make sure we don't overwrite editor color styles for links that are o…
kjellr 3935cff
Fixing display of text on blocks that use the custom primary color.
kjellr d36b6aa
Fix hover colors in post footers.
kjellr a6ea555
Fix classic editor blockquote color in Gutenberg.
kjellr 8ccd08f
code tidying
allancole f3b83d3
Merge branch 'master' into try/sync-customizer-colors-to-gutenberg
allancole 338751e
Add a default color option
allancole c134e19
Fixing travis.ci errors
allancole 6a1ca76
recompiling styles
allancole 4368a52
More fixes for travis.ci error
allancole 04f8036
More travius.ci errors fixed
allancole 2b84034
Fixeing more travis errors
allancole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
<?php | ||
/** | ||
* Twenty Nineteen: Color Patterns | ||
* | ||
* @package WordPress | ||
* @subpackage TwentyNineteen | ||
* @since 1.0 | ||
*/ | ||
|
||
/** | ||
* Generate the CSS for the current custom color scheme. | ||
*/ | ||
function twentynineteen_custom_colors_css() { | ||
|
||
$default_primary_color = 199; | ||
$primary_color = absint( get_theme_mod( 'primary-color', $default_primary_color ) ); | ||
|
||
/** | ||
* Filter Twenty Nineteen default saturation level. | ||
* | ||
* @since Twenty Nineteen 1.0 | ||
* | ||
* @param int $saturation Color saturation level. | ||
*/ | ||
|
||
$saturation = absint( apply_filters( 'twentynineteen_custom_colors_saturation', 100 ) ); | ||
$reduced_saturation = ( .8 * $saturation ) . '%'; | ||
$saturation = $saturation . '%'; | ||
|
||
$theme_css = ' | ||
/* | ||
* Set background for: | ||
* - featured image :before | ||
* - featured image :before | ||
* - post thumbmail :before | ||
* - post thumbmail :before | ||
* - Submenu | ||
* - Sticky Post | ||
* - buttons | ||
* - WP Block Button | ||
* - Blocks | ||
*/ | ||
.image-filters-enabled .site-header.featured-image .site-featured-image:before, | ||
.image-filters-enabled .site-header.featured-image .site-featured-image:after, | ||
.image-filters-enabled .entry .post-thumbnail:before, | ||
.image-filters-enabled .entry .post-thumbnail:after, | ||
.main-navigation .sub-menu, | ||
.sticky-post, | ||
.entry-content .wp-block-button .wp-block-button__link, | ||
.button, button, input[type="button"], input[type="reset"], input[type="submit"], | ||
.entry-content > *[class^="wp-block-"].has-primary-background-color, | ||
.entry-content > *[class^="wp-block-"] .has-primary-background-color, | ||
.entry-content > *[class^="wp-block-"].is-style-solid-color .has-primary-background-color, | ||
.entry-content .wp-block-file .wp-block-file__button { | ||
background-color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
/* | ||
* Set Color for: | ||
* - all links | ||
* - main navigation links | ||
* - Post navigation links | ||
* - Post entry meta hover | ||
* - Post entry header more-link hover | ||
* - main navigation svg | ||
* - comment navigation | ||
* - Comment edit link hover | ||
* - Site Footer Link hover | ||
*/ | ||
a, | ||
a:visited, | ||
.main-navigation ul.main-menu > li > a, | ||
.post-navigation .post-title, | ||
.entry .entry-meta a:hover, | ||
.entry .entry-footer a:hover, | ||
.entry .entry-content .more-link:hover, | ||
.main-navigation .main-menu > li > a + svg, | ||
.comment-navigation .nav-previous a:hover, | ||
.comment-navigation .nav-next a:hover, | ||
.comment .comment-metadata .comment-edit-link:hover, | ||
.site-footer a:hover, | ||
.entry-content .wp-block-button.is-style-outline .wp-block-button__link, | ||
.entry-content .wp-block-button.is-style-outline .wp-block-button__link, | ||
.entry-content .wp-block-button.is-style-outline .wp-block-button__link, | ||
.entry-content > *[class^="wp-block-"] .has-primary-color, | ||
.entry-content > *[class^="wp-block-"].is-style-solid-color .has-primary-color { | ||
color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
/* | ||
* Set left border color for: | ||
* wp block quote | ||
*/ | ||
.entry-content .wp-block-quote:not(.is-large), .entry-content .wp-block-quote:not(.is-style-large) { | ||
border-left-color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
/* | ||
* Set border color for: | ||
* :focus | ||
*/ | ||
input[type="text"]:focus, | ||
input[type="email"]:focus, | ||
input[type="url"]:focus, | ||
input[type="password"]:focus, | ||
input[type="search"]:focus, | ||
input[type="number"]:focus, | ||
input[type="tel"]:focus, | ||
input[type="range"]:focus, | ||
input[type="date"]:focus, | ||
input[type="month"]:focus, | ||
input[type="week"]:focus, | ||
input[type="time"]:focus, | ||
input[type="datetime"]:focus, | ||
input[type="datetime-local"]:focus, | ||
input[type="color"]:focus, | ||
textarea:focus { | ||
border-color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
.gallery-item > div > a:focus { | ||
box-shadow: 0 0 0 2px hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
/* Hover colors */ | ||
a:hover, a:active, | ||
.main-navigation .main-menu > li > a:hover, | ||
.main-navigation .main-menu > li > a:hover + svg, | ||
.post-navigation .nav-links a:hover, | ||
.comment .comment-author .fn a:hover, | ||
.comment-reply-link:hover, | ||
#cancel-comment-reply-link:hover { | ||
color: hsl( ' . $primary_color . ', ' . $saturation . ', 23% ); /* base: #005177; */ | ||
} | ||
|
||
.main-navigation .sub-menu > li > a:hover, | ||
.main-navigation .sub-menu > li > a:focus, | ||
.main-navigation .sub-menu > li > a:hover:after, | ||
.main-navigation .sub-menu > li > a:focus:after { | ||
background: hsl( ' . $primary_color . ', ' . $saturation . ', 23% ); /* base: #005177; */ | ||
}'; | ||
|
||
$editor_css = ' | ||
/* | ||
* Set colors for: | ||
* - links | ||
* - blockquote | ||
* - pullquote (solid color) | ||
* - buttons | ||
*/ | ||
.editor-block-list__layout .editor-block-list__block a, | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button.is-style-outline .wp-block-button__link:not(.has-text-color), | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button.is-style-outline:hover .wp-block-button__link:not(.has-text-color), | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button.is-style-outline:focus .wp-block-button__link:not(.has-text-color), | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button.is-style-outline:active .wp-block-button__link:not(.has-text-color) { | ||
color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
.editor-block-list__layout .editor-block-list__block .wp-block-quote:not(.is-large):not(.is-style-large), | ||
.editor-block-list__layout .wp-block-freeform blockquote { | ||
border-left: 2px solid hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
.editor-block-list__layout .editor-block-list__block .wp-block-pullquote.is-style-solid-color:not(.has-background-color) { | ||
background-color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
} | ||
|
||
.editor-block-list__layout .editor-block-list__block .wp-block-file .wp-block-file__button, | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button:not(.is-style-outline) .wp-block-button__link, | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button:not(.is-style-outline) .wp-block-button__link:active, | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button:not(.is-style-outline) .wp-block-button__link:focus, | ||
.editor-block-list__layout .editor-block-list__block .wp-block-button:not(.is-style-outline) .wp-block-button__link:hover { | ||
background-color: hsl( ' . $primary_color . ', ' . $saturation . ', 33% ); /* base: #0073a8; */ | ||
}'; | ||
|
||
$css = ''; | ||
if ( function_exists( 'register_block_type' ) && is_admin() ) { | ||
$css .= $editor_css; | ||
} else if ( ! is_admin() ) { | ||
$css = $theme_css; | ||
} | ||
|
||
/** | ||
* Filters Twenty Nineteen custom colors CSS. | ||
* | ||
* @since Twenty Nineteen 1.0 | ||
* | ||
* @param string $css Base theme colors CSS. | ||
* @param int $primary_color The user's selected color hue. | ||
* @param string $saturation Filtered theme color saturation level. | ||
*/ | ||
return apply_filters( 'twentynineteen_custom_colors_css', $css, $primary_color, $saturation ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the existing styles in this file move over to our usual editor stylesheet (#262), this file will be empty by default. That seems weird, right? This approach is functional for now, but I think we'll want to come up with a better way to handle this, probably in concert with the Gutenberg team.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, good catch! Agreed that there’s probably a more efficient way to get Gutenberg to catch these theme color overrides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The best way I've found for passing dynamic CSS to the new editor is to add it to the
styles
array in https://github.com/WordPress/gutenberg/blob/master/lib/client-assets.php#L1691Registered editor stylesheets get processed here: https://github.com/WordPress/gutenberg/blob/master/lib/client-assets.php#L1567-L1581
The same thing can be done by passing the generated CSS string directly instead of a file. This will ensure that the CSS gets wrapped/scoped when #262 is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure I’m following here @spencerfinnell
When I pass an array with the css string to
add_editor_style()
, I get an “expects parameter 1 to be string” error. Can you explain in a little more detail or offer a snippet on how you did these two things?