Closed kauaicreative closed 3 years ago
Seems like automation marked this as merged. Configurable colors is a good idea and is now implemented in background and media & text blocks in UI and applied automatically. Colors are registered at inc/_conf/register-colors.php
. This creates a small inline style block but registering them via PHP allows localization and easier usage in select fields etc.
That makes sense. For now I am modifying your x_enqueue_color_variables
to include wp colors, backgrounds, and vars
/**
* Enqueue inline color varaibles
*/
function x_enqueue_color_variables() {
$return = '';
$vars = '';
// Gather all Colors from above and modules
$colors = apply_filters( 'x_background_colors', [] );
if ( ! empty( $colors ) ) {
foreach ( $colors as $name => $arr ) {
if ( isset( $arr['color'] ) && ! empty( $arr['color'] ) ) {
$name = esc_attr( $name );
$color = esc_attr( $arr['color'] );
$vars .= "--color-$name: $color;\n";
$return .= ".background-color.background-color--$name {background: $color;}\n";
$return .= ".has-$name-color {color: $color;}\n";
$return .= ".has-$name-background-color {background: $color;}\n";
}
}
$return .= ":root{\n$vars}";
}
return $return;
}
Not sure if this is the best place to offer this but...
Here is a modified gulp script I have been using for some years which will automate the creation of editor-color-palette theme_support and related scss and css files all from the manifest.js.