Skip to content

Commit

Permalink
Colors: Move the default colors to the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jan 31, 2018
1 parent 1114052 commit a2a8e95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
13 changes: 13 additions & 0 deletions editor/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ import store from '../../store';
*/
const DEFAULT_SETTINGS = {
alignWide: false,
colors: [
'#f78da7',
'#cf2e2e',
'#ff6900',
'#fcb900',
'#7bdcb5',
'#00d084',
'#8ed1fc',
'#0693e3',
'#eee',
'#abb8c3',
'#313131',
],

// This is current max width of the block inner area
// It's used to constraint image resizing and this value could be overriden later by themes
Expand Down
36 changes: 6 additions & 30 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -680,29 +680,6 @@ function gutenberg_enqueue_registered_block_scripts_and_styles() {
add_action( 'enqueue_block_assets', 'gutenberg_enqueue_registered_block_scripts_and_styles' );
add_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_registered_block_scripts_and_styles' );

/**
* Returns a default color palette.
*
* @return array Color strings in hex format.
*
* @since 0.7.0
*/
function gutenberg_color_palette() {
return array(
'#f78da7',
'#cf2e2e',
'#ff6900',
'#fcb900',
'#7bdcb5',
'#00d084',
'#8ed1fc',
'#0693e3',
'#eee',
'#abb8c3',
'#313131',
);
}

/**
* Scripts & Styles.
*
Expand Down Expand Up @@ -870,12 +847,8 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
$color_palette = get_theme_support( 'editor-color-palette' );

// Backcompat for Color Palette set through `gutenberg` array.
if ( empty( $color_palette ) ) {
if ( ! empty( $gutenberg_theme_support[0]['colors'] ) ) {
$color_palette = $gutenberg_theme_support[0]['colors'];
} else {
$color_palette = gutenberg_color_palette();
}
if ( empty( $color_palette ) && ! empty( $gutenberg_theme_support[0]['colors'] ) ) {
$color_palette = $gutenberg_theme_support[0]['colors'];
}

if ( ! empty( $gutenberg_theme_support ) ) {
Expand All @@ -899,11 +872,14 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
$editor_settings = array(
'alignWide' => $align_wide || ! empty( $gutenberg_theme_support[0]['wide-images'] ), // Backcompat. Use `align-wide` outside of `gutenberg` array.
'availableTemplates' => wp_get_theme()->get_page_templates( get_post( $post_to_edit['id'] ) ),
'colors' => $color_palette,
'blockTypes' => $allowed_block_types,
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title', 'gutenberg' ), $post ),
);

if ( ! empty( $color_palette ) ) {
$editor_settings['colors'] = $color_palette;
}

$post_type_object = get_post_type_object( $post_to_edit['type'] );
if ( ! empty( $post_type_object->template ) ) {
$editor_settings['template'] = $post_type_object->template;
Expand Down

0 comments on commit a2a8e95

Please sign in to comment.