Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BorderControl: Promote to stable #65475

Merged
merged 24 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5b256ce
Export without experimental prefix
DaniGuardiola Sep 19, 2024
4332ff0
Update README
DaniGuardiola Sep 19, 2024
bf96c1c
Move Storybook stories and add redirect
DaniGuardiola Sep 19, 2024
bc7ba3a
Add changelog entries
DaniGuardiola Sep 19, 2024
a59fca9
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Sep 23, 2024
a88e769
Fix changelog.
DaniGuardiola Sep 23, 2024
256b9c4
Fix changelog (for real?)
DaniGuardiola Sep 23, 2024
a2ff408
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Sep 24, 2024
5672df5
Fix changelog
DaniGuardiola Sep 24, 2024
a2830eb
Apply feedback.
DaniGuardiola Sep 24, 2024
36e0822
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Sep 24, 2024
b5ec38f
Fix changelog
DaniGuardiola Sep 24, 2024
32a932e
Remove alpha story.
DaniGuardiola Sep 24, 2024
8eff905
README fix.
DaniGuardiola Sep 24, 2024
b043c79
Fix default in README
DaniGuardiola Sep 24, 2024
3ee9576
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Sep 27, 2024
6826228
Fix changelog
DaniGuardiola Sep 27, 2024
d357efd
Remove `showDropdownHeader` prop and the header itself.
DaniGuardiola Sep 27, 2024
c3b5386
Added `showDropdownHeader` as deprecated.
DaniGuardiola Sep 28, 2024
d13b763
Remove deprecation warning
DaniGuardiola Oct 1, 2024
9bd1c5a
Add ignores to jsdocs.
DaniGuardiola Oct 1, 2024
3956f3a
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Oct 1, 2024
c358e96
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Oct 1, 2024
8bebe21
Merge branch 'trunk' of https://github.com/WordPress/gutenberg into s…
DaniGuardiola Oct 1, 2024
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
5 changes: 2 additions & 3 deletions packages/components/CHANGELOG.md
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flagging that this PR seems to have removed unintentionally some CHANGELOG entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oof, bad automatic merge, let me put up a quick PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@

- `ToolsPanel`: atomic one-step state update when (un)registering panels ([#65564](https://github.com/WordPress/gutenberg/pull/65564)).
- `Navigator`: fix `isInitial` logic ([#65527](https://github.com/WordPress/gutenberg/pull/65527)).
- `ToggleGroupControl`: Fix arrow key navigation in RTL ([#65735](https://github.com/WordPress/gutenberg/pull/65735)).

### Deprecations

- `__experimentalBorderControl` can now be imported as a stable `BorderControl` ([#65475](https://github.com/WordPress/gutenberg/pull/65475)).
- `__experimentalBorderBoxControl` can now be imported as a stable `BorderBoxControl` ([#65586](https://github.com/WordPress/gutenberg/pull/65586)).

### Enhancements

- `Tabs`: handle horizontal overflow and large tab lists gracefully ([#64371](https://github.com/WordPress/gutenberg/pull/64371)).
- `BorderControl`: promote to stable ([#65475](https://github.com/WordPress/gutenberg/pull/65475)).
- `BorderBoxControl`: promote to stable ([#65586](https://github.com/WordPress/gutenberg/pull/65586)).
- `MenuGroup`: Simplify the MenuGroup styles within dropdown menus. ([#65561](https://github.com/WordPress/gutenberg/pull/65561)).
- `DatePicker`: Use compact button size. ([#65653](https://github.com/WordPress/gutenberg/pull/65653)).
- `Navigator`: add support for exit animation ([#64777](https://github.com/WordPress/gutenberg/pull/64777)).
- `Guide`: Update finish button to use the new default size ([#65680](https://github.com/WordPress/gutenberg/pull/65680)).
- `BorderControl`: Use `__next40pxDefaultSize` prop for Reset button ([#65682](https://github.com/WordPress/gutenberg/pull/65682)).
- `Navigator`: stabilize APIs ([#64613](https://github.com/WordPress/gutenberg/pull/64613)).

## 28.8.0 (2024-09-19)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type { CSSProperties } from 'react';
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -17,12 +16,10 @@ import Button from '../../button';
import ColorIndicator from '../../color-indicator';
import ColorPalette from '../../color-palette';
import Dropdown from '../../dropdown';
import { HStack } from '../../h-stack';
import { VStack } from '../../v-stack';
import type { WordPressComponentProps } from '../../context';
import { contextConnect } from '../../context';
import { useBorderControlDropdown } from './hook';
import { StyledLabel } from '../../base-control/styles/base-control-styles';
import DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';

import type { ColorObject } from '../../color-palette/types';
Expand Down Expand Up @@ -149,7 +146,6 @@ const BorderControlDropdown = (
popoverContentClassName,
popoverControlsClassName,
resetButtonClassName,
showDropdownHeader,
size,
__unstablePopoverProps,
...otherProps
Expand Down Expand Up @@ -197,17 +193,6 @@ const BorderControlDropdown = (
<>
<DropdownContentWrapper paddingSize="medium">
<VStack className={ popoverControlsClassName } spacing={ 6 }>
{ showDropdownHeader ? (
<HStack>
<StyledLabel>{ __( 'Border color' ) }</StyledLabel>
<Button
size="small"
label={ __( 'Close border color' ) }
icon={ closeSmall }
onClick={ onClose }
/>
</HStack>
) : undefined }
<ColorPalette
className={ popoverContentClassName }
value={ color }
Expand Down
62 changes: 26 additions & 36 deletions packages/components/src/border-control/border-control/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# BorderControl
# BorderControl

<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>
<br />
This component provides control over a border's color, style, and width.
An input control for a border's color, style, and width.

## Development guidelines

Expand All @@ -21,7 +17,7 @@ a "shape" abstraction.

```jsx
import { useState } from 'react';
import { __experimentalBorderControl as BorderControl } from '@wordpress/components';
import { BorderControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const colors = [
Expand Down Expand Up @@ -58,49 +54,49 @@ colors are organized by multiple origins.

Each color may be an object containing a `name` and `color` value.

- Required: No
- Default: `[]`
- Required: No
- Default: `[]`

### `disableCustomColors`: `boolean`

This toggles the ability to choose custom colors.

- Required: No
- Required: No

### `disableUnits`: `boolean`

This controls whether unit selection should be disabled.

- Required: No
- Required: No

### `enableAlpha`: `boolean`

This controls whether the alpha channel will be offered when selecting
custom colors.

- Required: No
- Default: `false`
- Required: No
- Default: `true`

### `enableStyle`: `boolean`

This controls whether to support border style selection.

- Required: No
- Default: `true`
- Required: No
- Default: `true`

### `hideLabelFromVision`: `boolean`

Provides control over whether the label will only be visible to screen readers.

- Required: No
- Required: No

### `isCompact`: `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.

- Required: No
- Required: No

### `label`: `string`

Expand All @@ -109,7 +105,7 @@ If provided, a label will be generated using this as the content.
_Whether it is visible only to screen readers is controlled via
`hideLabelFromVision`._

- Required: No
- Required: No

### `onChange`: `( value?: Object ) => void`

Expand All @@ -118,38 +114,32 @@ that selects or clears, border color, style, or width.

_Note: the value may be `undefined` if a user clears all border properties._

- Required: Yes
- Required: Yes

### `shouldSanitizeBorder`: `boolean`

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.

- 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
- Required: No
- Default: `true`

### `size`: `string`

Size of the control.

- Required: No
- Default: `default`
- Allowed values: `default`, `__unstable-large`
- Required: No
- Default: `default`
- Allowed values: `default`, `__unstable-large`

### `value`: `Object`

An object representing a border or `undefined`. Used to set the current border
configuration for this component.

Example:

```js
{
color: '#72aee6',
Expand All @@ -158,25 +148,25 @@ Example:
}
```

- Required: No
- Required: No

### `width`: `CSSProperties[ 'width' ]`

Controls the visual width of the `BorderControl`. It has no effect if the
`isCompact` prop is set to `true`.

- Required: No
- Required: No

### `withSlider`: `boolean`

Flags whether this `BorderControl` should also render a `RangeControl` for
additional control over a border's width.

- Required: No
- Required: No

### `__next40pxDefaultSize`: `boolean`

Start opting into the larger default height that will become the default size in a future version.

- Required: No
- Default: `false`
- Required: No
- Default: `false`
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const UnconnectedBorderControl = (
previousStyleSelection={
previousStyleSelection
}
showDropdownHeader={ showDropdownHeader }
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
Expand Down Expand Up @@ -141,7 +140,7 @@ const UnconnectedBorderControl = (
* a "shape" abstraction.
*
* ```jsx
* import { __experimentalBorderControl as BorderControl } from '@wordpress/components';
* import { BorderControl } from '@wordpress/components';
* import { __ } from '@wordpress/i18n';
*
* const colors = [
Expand Down
14 changes: 4 additions & 10 deletions packages/components/src/border-control/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BorderControl } from '..';
import type { Border } from '../types';

const meta: Meta< typeof BorderControl > = {
title: 'Components (Experimental)/BorderControl',
title: 'Components/BorderControl',
DaniGuardiola marked this conversation as resolved.
Show resolved Hide resolved
component: BorderControl,
argTypes: {
onChange: {
Expand Down Expand Up @@ -93,6 +93,9 @@ export const Default = Template.bind( {} );
Default.args = {
colors,
label: 'Border',
enableAlpha: true,
enableStyle: true,
shouldSanitizeBorder: true,
};

/**
Expand Down Expand Up @@ -133,12 +136,3 @@ WithMultipleOrigins.args = {
...Default.args,
colors: multipleOriginColors,
};

/**
* Allow the alpha channel to be edited on each color.
*/
export const WithAlphaEnabled = Template.bind( {} );
WithAlphaEnabled.args = {
...Default.args,
enableAlpha: true,
};
17 changes: 2 additions & 15 deletions packages/components/src/border-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,6 @@ describe( 'BorderControl', () => {
expect( resetButton ).toBeInTheDocument();
} );

it( 'should render color and style popover header', async () => {
const user = userEvent.setup();
const props = createProps( { showDropdownHeader: true } );
render( <BorderControl { ...props } /> );
await openPopover( user );

const headerLabel = screen.getByText( 'Border color' );
const closeButton = getButton( 'Close border color' );

expect( headerLabel ).toBeInTheDocument();
expect( closeButton ).toBeInTheDocument();
} );

it( 'should not render style options when opted out of', async () => {
const user = userEvent.setup();
const props = createProps( { enableStyle: false } );
Expand Down Expand Up @@ -346,10 +333,10 @@ describe( 'BorderControl', () => {

it( 'should take no action when color and style popover is closed', async () => {
const user = userEvent.setup();
const props = createProps( { showDropdownHeader: true } );
const props = createProps();
render( <BorderControl { ...props } /> );
await openPopover( user );
await user.click( getButton( 'Close border color' ) );
await user.keyboard( 'Escape' );

expect( props.onChange ).not.toHaveBeenCalled();
} );
Expand Down
19 changes: 12 additions & 7 deletions packages/components/src/border-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ export type Border = {

export type ColorProps = Pick<
ColorPaletteProps,
'colors' | 'enableAlpha' | '__experimentalIsRenderedInSidebar'
'colors' | '__experimentalIsRenderedInSidebar'
> & {
/**
* This toggles the ability to choose custom colors.
*/
disableCustomColors?: boolean;
/**
* This controls whether the alpha channel will be offered when selecting
* custom colors.
*
* @default true
*/
enableAlpha?: boolean;
};

export type LabelProps = {
Expand Down Expand Up @@ -78,9 +85,8 @@ export type BorderControlProps = ColorProps &
*/
shouldSanitizeBorder?: boolean;
/**
* 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.
* @deprecated This prop no longer has any effect.
DaniGuardiola marked this conversation as resolved.
Show resolved Hide resolved
* @ignore
*/
showDropdownHeader?: boolean;
/**
Expand Down Expand Up @@ -139,9 +145,8 @@ export type DropdownProps = ColorProps &
*/
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.
* @deprecated This prop no longer has any effect.
* @ignore
*/
showDropdownHeader?: boolean;
};
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export {
isDefinedBorder as __experimentalIsDefinedBorder,
isEmptyBorder as __experimentalIsEmptyBorder,
} from './border-box-control';
export { BorderControl as __experimentalBorderControl } from './border-control';
export {
/** @deprecated Import `BorderControl` instead. */
BorderControl as __experimentalBorderControl,
DaniGuardiola marked this conversation as resolved.
Show resolved Hide resolved
BorderControl,
} from './border-control';
export {
/** @deprecated Import `BoxControl` instead. */
default as __experimentalBoxControl,
Expand Down
1 change: 1 addition & 0 deletions storybook/manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const PREVIOUSLY_EXPERIMENTAL_COMPONENTS = [
'alignmentmatrixcontrol',
'borderboxcontrol',
'bordercontrol',
'boxcontrol',
'customselectcontrol-v2',
'dimensioncontrol',
Expand Down
Loading