Make WordPress Core


Ignore:
Timestamp:
10/25/2016 10:32:55 PM (8 years ago)
Author:
westonruter
Message:

Customize: Add hue-only mode to color picker.

The color control in the customizer can use the new mode by supplying the mode param with hue (as opposed to the new default full value). New control replaces the range control in Twenty Seventeen for colorscheme_hue. The wpColorPicker can opt for hue-only mode via supplying hue as the type option. Iris Color Picker is updated from v1.0.7 to v1.1.0-beta.

Props mattwiebe, celloexpressions.
Fixes #38263.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-color-control.php

    r35389 r38931  
    2727     */
    2828    public $statuses;
     29
     30    /**
     31    * @access public
     32    * @var string
     33    */
     34    public $mode = 'full';
    2935
    3036    /**
     
    6369        $this->json['statuses'] = $this->statuses;
    6470        $this->json['defaultValue'] = $this->setting->default;
     71        $this->json['mode'] = $this->mode;
    6572    }
    6673
     
    7986    public function content_template() {
    8087        ?>
    81         <# var defaultValue = '';
    82         if ( data.defaultValue ) {
     88        <# var defaultValue = '',
     89            isHueSlider = data.mode === 'hue';
     90
     91        if ( data.defaultValue && ! isHueSlider ) {
    8392            if ( '#' !== data.defaultValue.substring( 0, 1 ) ) {
    8493                defaultValue = '#' + data.defaultValue;
     
    96105            <# } #>
    97106            <div class="customize-control-content">
    98                 <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} />
     107                <# if ( isHueSlider ) { #>
     108                    <input class="color-picker-hue" type="text" data-type="hue" />
     109                <# } else { #>
     110                    <input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ); ?>" {{ defaultValue }} />
     111                <# } #>
    99112            </div>
    100113        </label>
Note: See TracChangeset for help on using the changeset viewer.