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

BorderBoxControl: Promote to stable #65586

Merged
merged 11 commits into from
Sep 25, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import {
__experimentalBorderBoxControl as BorderBoxControl,
BorderBoxControl,
__experimentalHasSplitBorders as hasSplitBorders,
__experimentalIsDefinedBorder as isDefinedBorder,
__experimentalToolsPanel as ToolsPanel,
Expand Down
8 changes: 8 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### Deprecations

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

### Enhancements

- `BorderBoxControl`: promote to stable ([#65586](https://github.com/WordPress/gutenberg/pull/65586)).

## 28.8.0 (2024-09-19)

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# BorderBoxControl

<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 users with the ability to configure a single "flat"
border or separate borders per side.
An input control for the color, style, and width of the border of a box. The
border can be customized as a whole, or individually for each side of the box.

## Development guidelines

Expand All @@ -28,7 +23,7 @@ show "Mixed" placeholder text.

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

const colors = [
Expand Down Expand Up @@ -76,35 +71,35 @@ 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

### `enableAlpha`: `boolean`

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

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

### `enableStyle`: `boolean`

This controls whether to support border style selections.

- 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

### `label`: `string`

Expand All @@ -113,7 +108,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 @@ -123,7 +118,7 @@ borders, or `undefined`.

_Note: The will be `undefined` if a user clears all borders._

- Required: Yes
- Required: Yes

### `popoverPlacement`: `string`

Expand All @@ -133,21 +128,21 @@ By default, popovers are displayed relative to the button that initiated the pop

The available base placements are 'top', 'right', 'bottom', 'left'. Each of these base placements has an alignment in the form -start and -end. For example, 'right-start', or 'bottom-end'. These allow you to align the tooltip to the edges of the button, rather than centering it.

- Required: No
- Required: No

### `popoverOffset`: `number`

The space between the popover and the control wrapper.

- Required: No
- Required: No

### `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`

Expand All @@ -158,6 +153,7 @@ properties or a "split" border which defines the previous properties but for
each side; `top`, `right`, `bottom`, and `left`.

Examples:

```js
const flatBorder = { color: '#72aee6', style: 'solid', width: '1px' };
const splitBorders = {
Expand All @@ -168,11 +164,11 @@ const splitBorders = {
};
```

- 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 @@ -147,22 +147,11 @@ const UnconnectedBorderBoxControl = (
};

/**
* The `BorderBoxControl` effectively has two view states. The first, a "linked"
* view, allows configuration of a flat border via a single `BorderControl`.
* The second, a "split" view, contains a `BorderControl` for each side
* as well as a visualizer for the currently selected borders. Each view also
* contains a button to toggle between the two.
*
* When switching from the "split" view to "linked", if the individual side
* borders are not consistent, the "linked" view will display any border
* properties selections that are consistent while showing a mixed state for
* those that aren't. For example, if all borders had the same color and style
* but different widths, then the border dropdown in the "linked" view's
* `BorderControl` would show that consistent color and style but the "linked"
* view's width input would show "Mixed" placeholder text.
aaronrobertshaw marked this conversation as resolved.
Show resolved Hide resolved
* An input control for the color, style, and width of the border of a box. The
* border can be customized as a whole, or individually for each side of the box.
*
* ```jsx
* import { __experimentalBorderBoxControl as BorderBoxControl } from '@wordpress/components';
* import { BorderBoxControl } from '@wordpress/components';
* import { __ } from '@wordpress/i18n';
*
* const colors = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Button from '../../button';
import { BorderBoxControl } from '../';

const meta: Meta< typeof BorderBoxControl > = {
title: 'Components (Experimental)/BorderBoxControl',
title: 'Components§/BorderBoxControl',
DaniGuardiola marked this conversation as resolved.
Show resolved Hide resolved
component: BorderBoxControl,
argTypes: {
onChange: { action: 'onChange' },
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export {
} from './autocomplete';
export { default as BaseControl, useBaseControlProps } from './base-control';
export {
/** @deprecated Import `BorderBoxControl` instead. */
BorderBoxControl as __experimentalBorderBoxControl,
BorderBoxControl,
hasSplitBorders as __experimentalHasSplitBorders,
isDefinedBorder as __experimentalIsDefinedBorder,
isEmptyBorder as __experimentalIsEmptyBorder,
Comment on lines 39 to 41
Copy link
Member

Choose a reason for hiding this comment

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

What about those experimental utils? They are part of the component's API, but they remain experimental. Should we stabilize them as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something I want to address in a follow-up. I already gave it a few iterations some time ago, and even paired on it with Marcelo over a donut chat which resulted in a draft PR I plan on reviving. There was some consensus about not exporting these from the component package, though the details remain to be discussed and iterated on.

I don't think it should block stabilization of this component though.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it should block stabilization of this component though.

Why, though, aren't those part of the component's public API? I'd expect it would be the other way around, and we'd figure these out first, especially if we plan not to export them from the components package / deprecate them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Related: #61135

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why, though, aren't those part of the component's public API? I'd expect it would be the other way around, and we'd figure these out first, especially if we plan not to export them from the components package / deprecate them.

I'm not strongly opposed that that, but to answer your question, my opinion is: no, they are not part of the component's API. I think these utils shouldn't have been exported here in the first place, and it's just an odd occurrence of misplaced utils. They're definitely related to the component, in that they apply to borders, but the component is its own thing.

So, the way I see it: stabilizing the component, moving the utilities somewhere else - these are separate tasks. Should they be tackled somewhat close to each other? I think so. Should one block the other? I think not.

That's just my 2 cents though. I'm good to go with another approach if someone feels more strongly about it.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. Let's keep the utils a separate problem and solve it as part of #61135 👍

Expand Down
1 change: 1 addition & 0 deletions storybook/manager-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
( function redirectIfStoryMoved() {
const PREVIOUSLY_EXPERIMENTAL_COMPONENTS = [
'alignmentmatrixcontrol',
'borderboxcontrol',
'boxcontrol',
'customselectcontrol-v2',
'dimensioncontrol',
Expand Down
Loading