Skip to content

Commit

Permalink
Leverage popover props to modify palette popovers on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Apr 21, 2023
1 parent d1bcaa6 commit 458a2b8
Showing 1 changed file with 13 additions and 0 deletions.
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import { useViewportMatch } from '@wordpress/compose';
import {
__experimentalPaletteEdit as PaletteEdit,
__experimentalVStack as VStack,
Expand Down Expand Up @@ -43,6 +44,15 @@ export default function ColorPalettePanel( { name } ) {
'color.defaultPalette',
name
);

const isMobileViewport = useViewportMatch( 'small', '<' );
const popoverProps = isMobileViewport
? {
placement: 'bottom-start',
offset: 8,
}
: undefined;

return (
<VStack
className="edit-site-global-styles-color-palette-panel"
Expand All @@ -56,6 +66,7 @@ export default function ColorPalettePanel( { name } ) {
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
{ !! defaultColors &&
Expand All @@ -68,6 +79,7 @@ export default function ColorPalettePanel( { name } ) {
onChange={ setDefaultColors }
paletteLabel={ __( 'Default' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
/>
) }
<PaletteEdit
Expand All @@ -79,6 +91,7 @@ export default function ColorPalettePanel( { name } ) {
'Custom colors are empty! Add some colors to create your own color palette.'
) }
slugPrefix="custom-"
popoverProps={ popoverProps }
/>
</VStack>
);
Expand Down

0 comments on commit 458a2b8

Please sign in to comment.