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 1 commit
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
123 changes: 62 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,66 @@ 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 }
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;
}
}