Skip to content

Commit

Permalink
Iterate on the popover behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 11, 2022
1 parent e107ec9 commit ecf677b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/components/src/color-palette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,24 @@ export function CustomColorPickerDropdown( {
popoverProps: receivedPopoverProps,
...props
} ) {
// Open below the control point (centered aligned).
const popoverProps = useMemo(
() => ( {
__unstableShift: true,
placement: 'bottom',
offset: 8,
...( isRenderedInSidebar
? {
// When in the sidebar: open to the left (stacking)
placement: 'left-start',
offset: 20,
// anchor?
}
: {
// Default behavior: open below the anchor
placement: 'bottom',
offset: 8,
} ),
...receivedPopoverProps,
} ),
[ receivedPopoverProps ]
[ isRenderedInSidebar, receivedPopoverProps ]
);

return (
Expand Down
10 changes: 10 additions & 0 deletions packages/components/src/custom-gradient-bar/control-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,19 @@ function ControlPointButton( { isOpen, position, color, ...additionalProps } ) {
}

function GradientColorPickerDropdown( { isRenderedInSidebar, ...props } ) {
// Open the popover below the gradient control/insertion point
const popoverProps = useMemo(
() => ( {
placement: 'bottom',
offset: 8,
} ),
[]
);

return (
<CustomColorPickerDropdown
isRenderedInSidebar={ isRenderedInSidebar }
popoverProps={ popoverProps }
{ ...props }
/>
);
Expand Down

0 comments on commit ecf677b

Please sign in to comment.