Skip to content

Commit

Permalink
Global Styles: Fix positioning of gradient palette popovers on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed May 2, 2023
1 parent 1efa153 commit c907ce6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { useViewportMatch } from '@wordpress/compose';
import {
__experimentalVStack as VStack,
__experimentalPaletteEdit as PaletteEdit,
Expand All @@ -17,6 +18,7 @@ import Subtitle from './subtitle';
import { unlock } from '../../private-apis';

const { useGlobalSetting } = unlock( blockEditorPrivateApis );
const mobilePopoverProps = { placement: 'bottom-start', offset: 8 };

const noop = () => {};

Expand Down Expand Up @@ -63,6 +65,9 @@ export default function GradientPalettePanel( { name } ) {
...( defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [] ),
];

const isMobileViewport = useViewportMatch( 'small', '<' );
const popoverProps = isMobileViewport ? mobilePopoverProps : undefined;

return (
<VStack
className="edit-site-global-styles-gradient-palette-panel"
Expand All @@ -76,6 +81,7 @@ export default function GradientPalettePanel( { name } ) {
onChange={ setThemeGradients }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
{ !! defaultGradients &&
Expand All @@ -88,6 +94,7 @@ export default function GradientPalettePanel( { name } ) {
onChange={ setDefaultGradients }
paletteLabel={ __( 'Default' ) }
paletteLabelLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
<PaletteEdit
Expand All @@ -99,6 +106,7 @@ export default function GradientPalettePanel( { name } ) {
'Custom gradients are empty! Add some gradients to create your own palette.'
) }
slugPrefix="custom-"
popoverProps={ popoverProps }
/>
{ !! duotonePalette && !! duotonePalette.length && (
<div>
Expand Down

0 comments on commit c907ce6

Please sign in to comment.