Skip to content
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
Prev Previous commit
Next Next commit
CustomGradientPicker: move styles from dropdown toggle to dropdown wr…
…apper
  • Loading branch information
ciampo committed Aug 19, 2022
commit f16c7be84a00a457e40872a65864e59dc6f36403
38 changes: 24 additions & 14 deletions packages/components/src/custom-gradient-bar/control-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ function ControlPointButton( { isOpen, position, color, ...additionalProps } ) {
'is-active': isOpen,
}
) }
style={ {
left: `${ position }%`,
transform: 'translateX( -50% )',
} }
{ ...additionalProps }
/>
<VisuallyHidden id={ descriptionId }>
Expand All @@ -74,7 +70,11 @@ function ControlPointButton( { isOpen, position, color, ...additionalProps } ) {
);
}

function GradientColorPickerDropdown( { isRenderedInSidebar, ...props } ) {
function GradientColorPickerDropdown( {
isRenderedInSidebar,
className,
...props
} ) {
// Open the popover below the gradient control/insertion point
const popoverProps = useMemo(
() => ( {
Expand All @@ -84,10 +84,16 @@ function GradientColorPickerDropdown( { isRenderedInSidebar, ...props } ) {
[]
);

const mergedClassName = classnames(
'components-custom-gradient-picker__control-point-dropdown',
className
);

return (
<CustomColorPickerDropdown
isRenderedInSidebar={ isRenderedInSidebar }
popoverProps={ popoverProps }
className={ mergedClassName }
{ ...props }
/>
);
Expand Down Expand Up @@ -271,6 +277,10 @@ function ControlPoints( {
) }
</>
) }
style={ {
left: `${ point.position }%`,
transform: 'translateX( -50% )',
} }
/>
)
);
Expand Down Expand Up @@ -307,16 +317,8 @@ function InsertPoint( {
}
onToggle();
} }
className="components-custom-gradient-picker__insert-point"
className="components-custom-gradient-picker__insert-point-dropdown"
icon={ plus }
style={
insertPosition !== null
? {
left: `${ insertPosition }%`,
transform: 'translateX( -50% )',
}
: undefined
}
/>
) }
renderContent={ () => (
Expand Down Expand Up @@ -344,6 +346,14 @@ function InsertPoint( {
} }
/>
) }
style={
insertPosition !== null
? {
left: `${ insertPosition }%`,
transform: 'translateX( -50% )',
}
: undefined
}
/>
);
}
Expand Down
32 changes: 21 additions & 11 deletions packages/components/src/custom-gradient-picker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,27 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1
margin-right: auto;
}

.components-custom-gradient-picker__insert-point {
.components-custom-gradient-picker__control-point-dropdown {
position: absolute;
height: $grid-unit-20;
width: $grid-unit-20;
top: $components-custom-gradient-picker__padding;
// Trim any internal white spacing that would be cause d by inline positioned elements
display: flex;
}

.components-custom-gradient-picker__insert-point-dropdown {
position: relative;

// Same size as the .components-custom-gradient-picker__control-point-dropdown parent
height: inherit;
width: inherit;
min-width: $grid-unit-20;
border-radius: 50%;

background: $white;
padding: 2px;
top: $components-custom-gradient-picker__padding;
min-width: $grid-unit-20;
width: $grid-unit-20;
height: $grid-unit-20;
position: relative;

color: $gray-900;

svg {
Expand All @@ -36,12 +48,11 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1
}

.components-custom-gradient-picker__control-point-button {
// Same size as the .components-custom-gradient-picker__control-point-dropdown parent
height: inherit;
width: inherit;
border-radius: 50%;
height: $grid-unit-20;
width: $grid-unit-20;
padding: 0;
position: absolute;
top: $components-custom-gradient-picker__padding;

// Shadow and stroke.
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) $white, 0 0 $border-width-focus 0 rgba($black, 0.25);
Expand All @@ -66,7 +77,6 @@ $components-custom-gradient-picker__padding: $grid-unit-20; // 48px container, 1
.components-custom-gradient-picker__inserter {
/*rtl:ignore*/
direction: ltr;
width: 100%;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not necessary anymore, since components-custom-gradient-picker__insert-point-dropdown also sets the width

}

.components-custom-gradient-picker__liner-gradient-indicator {
Expand Down