Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ad80204
Add BorderControl component
aaronrobertshaw Jan 4, 2022
08a4aaf
Improve docs and comments for width prop
aaronrobertshaw Feb 18, 2022
45b2fd9
Target BackdropUI instead of div for removing border
aaronrobertshaw Feb 18, 2022
3c072f3
Add RTL styles
aaronrobertshaw Feb 18, 2022
a6be837
Switch BorderControlStylePicker to use inner Flex component
aaronrobertshaw Feb 18, 2022
95a74a7
Refactor label styles
aaronrobertshaw Feb 18, 2022
a7ecb60
Add cx to useMemo deps
aaronrobertshaw Feb 18, 2022
a3fd0e0
Use StyledField to target slider margin removal
aaronrobertshaw Feb 18, 2022
f6cbe7f
Fix type ignoring for color components
aaronrobertshaw Feb 18, 2022
8d1c5a1
Move color indicator wrapper styles to dynamic class
aaronrobertshaw Feb 18, 2022
51574d6
Use React.ForwardRef<any> for typing
aaronrobertshaw Feb 18, 2022
3e23b82
Use Root to target UnitControl wrapper
aaronrobertshaw Feb 18, 2022
757da54
Add default to docs for shouldSanitizeBorder
aaronrobertshaw Feb 18, 2022
c1f7f53
Add default to type docs for enableStyle
aaronrobertshaw Feb 18, 2022
81bfad0
Update width type to CSSProperties['width']
aaronrobertshaw Feb 18, 2022
cf87f11
Add default for enableStyle to dropdown js docs
aaronrobertshaw Feb 18, 2022
0b79b77
Remove extraneous width style
aaronrobertshaw Feb 18, 2022
57d87ef
Fix unit and value parsing after changes to UnitControl utils
aaronrobertshaw Mar 15, 2022
202800c
Make inner unit control fill available height
aaronrobertshaw Mar 15, 2022
dfe7470
Add tooltip for border style options
aaronrobertshaw Mar 16, 2022
9be938d
Improve typing for colors array
aaronrobertshaw Mar 16, 2022
1782b43
Improve aria labels for color and style popover toggle button
aaronrobertshaw Mar 16, 2022
b17da1a
Comment explaining color indicator styling choice
aaronrobertshaw Mar 16, 2022
b8da8d4
Only show border on indicator when style has been selected
aaronrobertshaw Mar 18, 2022
9829605
Fix RTL handling and style naming
aaronrobertshaw Mar 22, 2022
32e0120
Allow color and style picker to use flyout positioning
aaronrobertshaw Mar 22, 2022
4f538d6
Add multi origin colors to storybook example
aaronrobertshaw Mar 22, 2022
345b49a
Make dropdown header optional via new prop
aaronrobertshaw Mar 22, 2022
be99ab1
Update unit tests for optional color/style dropdown header
aaronrobertshaw Mar 22, 2022
02562bb
Use more concise CSS rule to remove whitespace
aaronrobertshaw Mar 23, 2022
535cd0d
Fix tooltips within color/style dropdown
aaronrobertshaw Mar 23, 2022
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
Make dropdown header optional via new prop
  • Loading branch information
aaronrobertshaw committed Mar 22, 2022
commit 345b49a0c940524c26a6d3166e04900acefc0e24
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const BorderControlDropdown = (
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
showDropdownHeader,
enableStyle = true,
...otherProps
} = useBorderControlDropdown( props );
Expand Down Expand Up @@ -186,15 +187,17 @@ const BorderControlDropdown = (
const renderContent = ( { onClose }: PopoverProps ) => (
<>
<VStack className={ popoverControlsClassName } spacing={ 6 }>
<HStack>
<StyledLabel>{ __( 'Border color' ) }</StyledLabel>
<Button
isSmall
label={ __( 'Close border color' ) }
icon={ closeSmall }
onClick={ onClose }
/>
</HStack>
{ showDropdownHeader ? (
<HStack>
<StyledLabel>{ __( 'Border color' ) }</StyledLabel>
<Button
isSmall
label={ __( 'Close border color' ) }
icon={ closeSmall }
onClick={ onClose }
/>
</HStack>
) : undefined }
<ColorPalette
className={ popoverContentClassName }
value={ color }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ new border value.
- Required: No
- Default: true

### `showDropdownHeader`: `boolean`

Whether or not to render a header for the border color and style picker
dropdown. The header includes a label for the color picker and a close button.

- Required: No

### `value`: `Object`

An object representing a border or `undefined`. Used to set the current border
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const BorderControl = (
onWidthChange,
placeholder,
previousStyleSelection,
showDropdownHeader,
sliderClassName,
value: border,
widthControlClassName,
Expand Down Expand Up @@ -71,6 +72,7 @@ const BorderControl = (
enableStyle={ enableStyle }
onChange={ onBorderChange }
previousStyleSelection={ previousStyleSelection }
showDropdownHeader={ showDropdownHeader }
__experimentalHasMultipleOrigins={
__experimentalHasMultipleOrigins
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/border-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Default.args = {
enableStyle: true,
isCompact: true,
shouldSanitizeBorder: true,
showDropdownHeader: false,
width: '110px',
withSlider: true,
__experimentalIsRenderedInSidebar: false,
Expand Down
30 changes: 21 additions & 9 deletions packages/components/src/border-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export type BorderControlProps = ColorProps &
*/
enableStyle?: boolean;
/**
* This flags the `BorderControl` to render with a more compact appearance.
* It restricts the width of the control and prevents it from expanding to
* take up additional space.
* This flags the `BorderControl` to render with a more compact
* appearance. It restricts the width of the control and prevents it
* from expanding to take up additional space.
*/
isCompact?: boolean;
/**
Expand All @@ -81,16 +81,22 @@ export type BorderControlProps = ColorProps &
*/
onChange: ( value?: Border ) => void;
/**
* If opted into, sanitizing the border means that if no width or color have
* been selected, the border style is also cleared and `undefined`
* If opted into, sanitizing the border means that if no width or color
* have been selected, the border style is also cleared and `undefined`
* is returned as the new border value.
*
* @default true
*/
shouldSanitizeBorder?: boolean;
/**
* An object representing a border or `undefined`. Used to set the current
* border configuration for this component.
* Whether or not to show the header for the border color and style
* picker dropdown. The header includes a label for the color picker
* and a close button.
*/
showDropdownHeader?: boolean;
/**
* An object representing a border or `undefined`. Used to set the
* current border configuration for this component.
*/
value?: Border;
/**
Expand All @@ -99,8 +105,8 @@ export type BorderControlProps = ColorProps &
*/
width?: CSSProperties[ 'width' ];
/**
* Flags whether this `BorderControl` should also render a `RangeControl`
* for additional control over a border's width.
* Flags whether this `BorderControl` should also render a
* `RangeControl` for additional control over a border's width.
*/
withSlider?: boolean;
};
Expand Down Expand Up @@ -128,6 +134,12 @@ export type DropdownProps = ColorProps & {
* to a non-zero value.
*/
previousStyleSelection?: string;
/**
* Whether or not to render a header for the border color and style picker
* dropdown. The header includes a label for the color picker and a
* close button.
*/
showDropdownHeader?: boolean;
};

export type StylePickerProps = LabelProps & {
Expand Down