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

Iterate on the design of the colors and gradients panel #35535

Merged
merged 3 commits into from
Oct 12, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,104 +14,135 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
margin-bottom: inherit;
}

.emotion-4 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: normal;
-webkit-box-align: normal;
-ms-flex-align: normal;
align-items: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
}

.emotion-4>*+*:not( marquee ) {
margin-top: calc(4px * 2);
}

.emotion-4>* {
min-height: 0;
}

<div
className="components-base-control block-editor-color-gradient-control emotion-0 emotion-1"
>
<div
className="components-base-control__field emotion-2 emotion-3"
>
<fieldset>
<legend>
<div
className="block-editor-color-gradient-control__color-indicator"
>
<span
className="components-base-control__label"
<div
className="components-flex components-h-stack components-v-stack emotion-4 emotion-5"
data-wp-c16t={true}
data-wp-component="VStack"
>
<legend>
<div
className="block-editor-color-gradient-control__color-indicator"
>
Test Color
<span
aria-label="(Color: #f00)"
className="component-color-indicator"
style={
Object {
"background": "#f00",
className="components-base-control__label"
>
Test Color
<span
aria-label="(Color: #f00)"
className="component-color-indicator"
style={
Object {
"background": "#f00",
}
}
}
/>
</span>
</div>
</legend>
<div
className="components-circular-option-picker"
>
/>
</span>
</div>
</legend>
<div
className="components-circular-option-picker__swatches"
className="components-circular-option-picker"
>
<div
className="components-circular-option-picker__option-wrapper"
className="components-circular-option-picker__swatches"
>
<button
aria-describedby={null}
aria-label="Color: red"
aria-pressed={true}
className="components-button components-circular-option-picker__option is-pressed"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={
Object {
"backgroundColor": "#f00",
"color": "#f00",
}
}
type="button"
/>
<svg
aria-hidden={true}
fill="#000"
focusable={false}
height={24}
role="img"
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
<div
className="components-circular-option-picker__option-wrapper"
>
<path
d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
<button
aria-describedby={null}
aria-label="Color: red"
aria-pressed={true}
className="components-button components-circular-option-picker__option is-pressed"
onBlur={[Function]}
onClick={[Function]}
onFocus={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
onMouseLeave={[Function]}
style={
Object {
"backgroundColor": "#f00",
"color": "#f00",
}
}
type="button"
/>
</svg>
<svg
aria-hidden={true}
fill="#000"
focusable={false}
height={24}
role="img"
viewBox="0 0 24 24"
width={24}
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
/>
</svg>
</div>
</div>
</div>
<div
className="components-circular-option-picker__custom-clear-wrapper"
>
<div
className="components-dropdown components-circular-option-picker__dropdown-link-action"
tabIndex="-1"
className="components-circular-option-picker__custom-clear-wrapper"
>
<div
className="components-dropdown components-circular-option-picker__dropdown-link-action"
tabIndex="-1"
>
<button
aria-describedby={null}
aria-expanded={false}
aria-haspopup="true"
aria-label="Custom color picker"
className="components-button is-link"
onClick={[Function]}
type="button"
>
Custom color
</button>
</div>
<button
aria-describedby={null}
aria-expanded={false}
aria-haspopup="true"
aria-label="Custom color picker"
className="components-button is-link"
className="components-button components-circular-option-picker__clear is-secondary is-small"
onClick={[Function]}
type="button"
>
Custom color
Clear
</button>
</div>
<button
aria-describedby={null}
className="components-button components-circular-option-picker__clear is-secondary is-small"
onClick={[Function]}
type="button"
>
Clear
</button>
</div>
</div>
</fieldset>
Expand Down
125 changes: 64 additions & 61 deletions packages/block-editor/src/components/colors-gradients/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { every, isEmpty } from 'lodash';
import { useState } from '@wordpress/element';
import {
BaseControl,
Button,
ButtonGroup,
__experimentalVStack as VStack,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
ColorIndicator,
ColorPalette,
GradientPicker,
Expand Down Expand Up @@ -110,66 +111,68 @@ function ColorGradientControlInner( {
) }
>
<fieldset>
<legend>
<div className="block-editor-color-gradient-control__color-indicator">
<BaseControl.VisualLabel>
<VisualLabel
currentTab={ currentTab }
label={ label }
colorValue={ colorValue }
gradientValue={ gradientValue }
/>
</BaseControl.VisualLabel>
</div>
</legend>
{ canChooseAColor && canChooseAGradient && (
<ButtonGroup className="block-editor-color-gradient-control__button-tabs">
<Button
isSmall
isPressed={ currentTab === 'color' }
onClick={ () => setCurrentTab( 'color' ) }
>
{ __( 'Solid' ) }
</Button>
<Button
isSmall
isPressed={ currentTab === 'gradient' }
onClick={ () => setCurrentTab( 'gradient' ) }
<VStack space={ 3 }>
Copy link
Contributor

@ciampo ciampo Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working with this component in a completely different PR, I realised that the correct prop name was spacing (see docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be solved in #35583

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

<legend>
<div className="block-editor-color-gradient-control__color-indicator">
<BaseControl.VisualLabel>
<VisualLabel
currentTab={ currentTab }
label={ label }
colorValue={ colorValue }
gradientValue={ gradientValue }
/>
</BaseControl.VisualLabel>
</div>
</legend>
{ canChooseAColor && canChooseAGradient && (
<ToggleGroupControl
value={ currentTab }
onChange={ setCurrentTab }
label={ __( 'Select color type' ) }
hideLabelFromVision
isBlock
>
{ __( 'Gradient' ) }
</Button>
</ButtonGroup>
) }
{ ( currentTab === 'color' || ! canChooseAGradient ) && (
<ColorPalette
value={ colorValue }
onChange={
canChooseAGradient
? ( newColor ) => {
onColorChange( newColor );
onGradientChange();
}
: onColorChange
}
{ ...{ colors, disableCustomColors } }
clearable={ clearable }
/>
) }
{ ( currentTab === 'gradient' || ! canChooseAColor ) && (
<GradientPicker
value={ gradientValue }
onChange={
canChooseAColor
? ( newGradient ) => {
onGradientChange( newGradient );
onColorChange();
}
: onGradientChange
}
{ ...{ gradients, disableCustomGradients } }
clearable={ clearable }
/>
) }
<ToggleGroupControlOption
value="color"
label={ __( 'Solid' ) }
/>
<ToggleGroupControlOption
value="gradient"
label={ __( 'Gradient' ) }
/>
</ToggleGroupControl>
) }
{ ( currentTab === 'color' || ! canChooseAGradient ) && (
<ColorPalette
value={ colorValue }
onChange={
canChooseAGradient
? ( newColor ) => {
onColorChange( newColor );
onGradientChange();
}
: onColorChange
}
{ ...{ colors, disableCustomColors } }
clearable={ clearable }
/>
) }
{ ( currentTab === 'gradient' || ! canChooseAColor ) && (
<GradientPicker
value={ gradientValue }
onChange={
canChooseAColor
? ( newGradient ) => {
onGradientChange( newGradient );
onColorChange();
}
: onGradientChange
}
{ ...{ gradients, disableCustomGradients } }
clearable={ clearable }
/>
) }
</VStack>
</fieldset>
</BaseControl>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
.block-editor-color-gradient-control__color-indicator {
margin-bottom: $grid-unit-15;
}

.block-editor-color-gradient-control__button-tabs {
display: block;
margin-bottom: $grid-unit-15;
}
}

.block-editor-panel-color-gradient-settings {
Expand Down Expand Up @@ -45,4 +40,12 @@
margin-right: 0;
}
}


// This shouldn't be needed but there's a rule in the inspector controls
// overriding this causing too much spacing.
// That generic rule should ideally be removed.
.block-editor-block-inspector & .components-base-control {
margin-bottom: inherit;
}
}
Loading