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

fix(drawing): show sub-shadow in color picker control button #1318

Merged
10 changes: 10 additions & 0 deletions src/lib/viewers/controls/color-picker/ColorPickerControl.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

.bp-ColorPickerControl-button {
@include bp-ControlButton;

&.bp-is-toggled,
&:focus,
&:hover {
.bp-ColorPickerControl-toggle-background {
padding: 8px;
background-color: $fours;
border-radius: 4px;
}
}
}

.bp-ColorPickerControl-palette {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ export default function ColorPickerControl({
return (
<div className="bp-ColorPickerControl">
<button
className="bp-ColorPickerControl-button"
className={classNames('bp-ColorPickerControl-button', { 'bp-is-toggled': isColorPickerToggled })}
ChenCodes marked this conversation as resolved.
Show resolved Hide resolved
data-testid="bp-ColorPickerControl-button"
onBlur={handleBlur}
onClick={handleClick}
type="button"
{...rest}
>
<div className="bp-ColorPickerControl-swatch" style={{ backgroundColor: activeColor }} />
<div className="bp-ColorPickerControl-toggle-background">
<div className="bp-ColorPickerControl-swatch" style={{ backgroundColor: activeColor }} />
</div>
</button>
<div
className={classNames('bp-ColorPickerControl-palette', { 'bp-is-open': isColorPickerToggled })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ describe('ColorPickerControl', () => {
expect(getColorPickerPalette(wrapper).hasClass('bp-is-open')).toBe(true);
});

test('should apply toggle background when the toggle button is clicked and remove the background when the button is blurred', () => {
const wrapper = getWrapper();
const toggleButton = getToggleButton(wrapper);

toggleButton.simulate('click');
expect(getToggleButton(wrapper).hasClass('bp-is-toggled')).toBe(true);

toggleButton.simulate('blur');
expect(getToggleButton(wrapper).hasClass('bp-is-toggled')).toBe(false);
});

test('should close the palette when button is blurred', () => {
const wrapper = getWrapper();
const toggleButton = getToggleButton(wrapper);
Expand Down