Skip to content
Closed
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
Switch BorderBoxControl to popoversProps
  • Loading branch information
aaronrobertshaw committed May 5, 2022
commit cfdf0e80ffff63fa0400eb01005d46cafdab2180
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const BorderBoxControlSplitControls = (
enableAlpha,
enableStyle,
onChange,
popoverClassNames,
popoversProps,
value,
__experimentalHasMultipleOrigins,
__experimentalIsRenderedInSidebar,
Expand All @@ -50,23 +50,23 @@ const BorderBoxControlSplitControls = (
hideLabelFromVision={ true }
label={ __( 'Top border' ) }
onChange={ ( newBorder ) => onChange( newBorder, 'top' ) }
popoverProps={ { className: popoverClassNames?.top } }
popoverProps={ popoversProps?.top }
value={ value?.top }
{ ...sharedBorderControlProps }
/>
<BorderControl
hideLabelFromVision={ true }
label={ __( 'Left border' ) }
onChange={ ( newBorder ) => onChange( newBorder, 'left' ) }
popoverProps={ { className: popoverClassNames?.left } }
popoverProps={ popoversProps?.left }
value={ value?.left }
{ ...sharedBorderControlProps }
/>
<BorderControl
hideLabelFromVision={ true }
label={ __( 'Right border' ) }
onChange={ ( newBorder ) => onChange( newBorder, 'right' ) }
popoverProps={ { className: popoverClassNames?.right } }
popoverProps={ popoversProps?.right }
value={ value?.right }
{ ...sharedBorderControlProps }
/>
Expand All @@ -75,7 +75,7 @@ const BorderBoxControlSplitControls = (
hideLabelFromVision={ true }
label={ __( 'Bottom border' ) }
onChange={ ( newBorder ) => onChange( newBorder, 'bottom' ) }
popoverProps={ { className: popoverClassNames?.bottom } }
popoverProps={ popoversProps?.bottom }
value={ value?.bottom }
{ ...sharedBorderControlProps }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const BorderBoxControl = (
linkedValue,
onLinkedChange,
onSplitChange,
popoverClassNames,
popoversProps,
splitValue,
toggleLinked,
__experimentalHasMultipleOrigins,
Expand All @@ -77,9 +77,7 @@ const BorderBoxControl = (
placeholder={
hasMixedBorders ? __( 'Mixed' ) : undefined
}
popoverProps={ {
className: popoverClassNames?.linked,
} }
popoverProps={ popoversProps?.linked }
shouldSanitizeBorder={ false } // This component will handle that.
value={ linkedValue }
withSlider={ true }
Expand All @@ -98,7 +96,7 @@ const BorderBoxControl = (
enableAlpha={ enableAlpha }
enableStyle={ enableStyle }
onChange={ onSplitChange }
popoverClassNames={ popoverClassNames }
popoversProps={ popoversProps }
value={ splitValue }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
Expand Down
34 changes: 21 additions & 13 deletions packages/components/src/border-box-control/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/**
* Internal dependencies
*/
import type { Border, ColorProps, LabelProps } from '../border-control/types';
import type {
Border,
ColorProps,
DropdownPopoverProps,
LabelProps,
} from '../border-control/types';

export type Borders = {
top?: Border;
Expand All @@ -14,12 +19,15 @@ export type AnyBorder = Border | Borders | undefined;
export type BorderProp = keyof Border;
export type BorderSide = keyof Borders;

export type PopoverClassNames = {
linked?: string;
top?: string;
right?: string;
bottom?: string;
left?: string;
/**
* Collection of `popoverProps` for each of the inner border controls.
*/
export type PopoversProps = {
linked?: DropdownPopoverProps;
top?: DropdownPopoverProps;
right?: DropdownPopoverProps;
bottom?: DropdownPopoverProps;
left?: DropdownPopoverProps;
};

export type BorderBoxControlProps = ColorProps &
Expand All @@ -35,10 +43,10 @@ export type BorderBoxControlProps = ColorProps &
*/
onChange: ( value: AnyBorder ) => void;
/**
* An object defining CSS classnames for all the inner `BorderControl`
* popover content.
* An object defining the `popoverProps` for all the inner
* `BorderControl` dropdowns.
*/
popoverClassNames?: PopoverClassNames;
popoversProps?: PopoversProps;
/**
* An object representing the current border configuration.
*
Expand Down Expand Up @@ -85,10 +93,10 @@ export type SplitControlsProps = ColorProps & {
*/
onChange: ( value: Border | undefined, side: BorderSide ) => void;
/**
* An object defining CSS classnames for the split side `BorderControl`s'
* popover content.
* An object defining the `popoverProps` for the split side
* `BorderControl` dropdowns.
*/
popoverClassNames?: PopoverClassNames;
popoversProps?: PopoversProps;
/**
* An object representing the current border configuration. It contains
* properties for each side, with each side an object reflecting the border
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/border-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type Colors = ColorOrigin[] | Color[];
* dropdown's `popoverProps`. This should be replaced once the Dropdown or
* Popover components are typed.
*/
type DropdownPopoverProps = {
export type DropdownPopoverProps = {
className?: string;
focusOnMount?: boolean;
position?: string;
Expand Down