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

Add color classes to the editor styles #898

Merged
merged 2 commits into from
Apr 28, 2020
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
32 changes: 32 additions & 0 deletions newspack-theme/inc/color-patterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,22 @@ function newspack_custom_colors_css() {
color: ' . esc_html( $primary_color_contrast ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-primary-color {
color: ' . esc_html( $primary_color ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-primary-variation-color {
color: ' . esc_html( newspack_adjust_brightness( $primary_color, -30 ) ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-primary-background-color {
background-color: ' . esc_html( $primary_color ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-primary-variation-background-color {
background-color: ' . esc_html( newspack_adjust_brightness( $primary_color, -30 ) ) . ';
}

/* Secondary color */

.block-editor-block-list__layout .block-editor-block-list__block .wp-block-file .wp-block-file__button,
Expand Down Expand Up @@ -641,6 +657,22 @@ function newspack_custom_colors_css() {
.block-editor-block-list__layout .block-editor-block-list__block .wp-block-cover .article-section-title {
color: inherit;
}

.edit-post-visual-editor.editor-styles-wrapper .has-secondary-color {
color: ' . esc_html( $secondary_color ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-secondary-variation-color {
color: ' . esc_html( newspack_adjust_brightness( $secondary_color, -30 ) ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-secondary-background-color {
background-color: ' . esc_html( $secondary_color ) . ';
}

.edit-post-visual-editor.editor-styles-wrapper .has-secondary-variation-background-color {
background-color: ' . esc_html( newspack_adjust_brightness( $secondary_color, -30 ) ) . ';
}
';

if ( newspack_is_active_style_pack( 'default', 'style-3', 'style-4' ) ) {
Expand Down
66 changes: 66 additions & 0 deletions newspack-theme/sass/style-editor-base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -827,3 +827,69 @@ ul.wp-block-archives,
#newspack-post-subtitle-element {
font-style: italic;
}

/** === Custom Colors === */

.has-primary-background-color {
background-color: $color__primary;
}

.has-primary-variation-background-color {
background-color: $color__primary-variation;
}

.has-secondary-background-color {
background-color: $color__secondary;
}

.has-secondary-variation-background-color {
background-color: $color__secondary-variation;
}

.has-dark-gray-background-color {
background-color: #111;
}

.has-medium-gray-background-color {
background-color: #767676;
}

.has-light-gray-background-color {
background-color: #eee;
}

.has-white-background-color {
background-color: #fff;
}

.has-primary-color {
color: $color__primary;
}

.has-primary-variation-color {
color: $color__primary-variation;
}

.has-secondary-color {
color: $color__secondary;
}

.has-secondary-variation-color {
color: $color__secondary-variation;
}

.has-dark-gray-color {
color: #111;
}

.has-medium-gray-color {
color: #767676;
}

.has-light-gray-color {
color: #eee;
}

.has-white-color {
color: #fff;
}