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

AlignmentMatrixControl: Promote to stable #60913

Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DOWN } from '@wordpress/keycodes';
import {
ToolbarButton,
Dropdown,
__experimentalAlignmentMatrixControl as AlignmentMatrixControl,
AlignmentMatrixControl,
} from '@wordpress/components';

const noop = () => {};
Expand Down
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Deprecate `replace` from the options accepted by `useNavigator().goTo()` ([#64675](https://github.com/WordPress/gutenberg/pull/64675)).
- Soft deprecate `size` prop on `AlignmentMatrixControl.Icon` ([#64827](https://github.com/WordPress/gutenberg/pull/64827)).
- `__experimentalAlignmentMatrixControl` can now be imported as a stable `AlignmentMatrixControl` ([#60913](https://github.com/WordPress/gutenberg/pull/60913)).

### Enhancements

Expand All @@ -24,6 +25,7 @@
- `UnitControl`: Update unit select styles ([#64712](https://github.com/WordPress/gutenberg/pull/64712)).
- `InputControl`: Add variants to prefix/suffix wrappers ([#64824](https://github.com/WordPress/gutenberg/pull/64824)).
- `Navigator`: remove location history, simplify internal logic ([#64675](https://github.com/WordPress/gutenberg/pull/64675)).
- `AlignmentMatrixControl`: Promote to stable ([#60913](https://github.com/WordPress/gutenberg/pull/60913)).
- Tighten gap between the main control and the prefix/suffix slot for the following components ([#64908](https://github.com/WordPress/gutenberg/pull/64908)).
- `InputControl`
- `NumberControl`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# AlignmentMatrixControl

<div class="callout callout-alert">
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
</div>

AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.

## Usage

```jsx
import { useState } from 'react';
import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
import { AlignmentMatrixControl } from '@wordpress/components';

const Example = () => {
const [ alignment, setAlignment ] = useState( 'center center' );
Expand Down
61 changes: 38 additions & 23 deletions packages/components/src/alignment-matrix-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,7 @@ import { GRID, getItemId, getItemValue } from './utils';
import type { WordPressComponentProps } from '../context';
import type { AlignmentMatrixControlProps } from './types';

/**
*
* AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.
*
* ```jsx
* import { __experimentalAlignmentMatrixControl as AlignmentMatrixControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const Example = () => {
* const [ alignment, setAlignment ] = useState( 'center center' );
*
* return (
* <AlignmentMatrixControl
* value={ alignment }
* onChange={ setAlignment }
* />
* );
* };
* ```
*/
export function AlignmentMatrixControl( {
function UnforwardedAlignmentMatrixControl( {
className,
id,
label = __( 'Alignment Matrix Control' ),
Expand All @@ -52,7 +32,7 @@ export function AlignmentMatrixControl( {
...props
}: WordPressComponentProps< AlignmentMatrixControlProps, 'div', false > ) {
const baseId = useInstanceId(
AlignmentMatrixControl,
UnforwardedAlignmentMatrixControl,
'alignment-matrix-control',
id
);
Expand Down Expand Up @@ -100,6 +80,41 @@ export function AlignmentMatrixControl( {
);
}

AlignmentMatrixControl.Icon = AlignmentMatrixControlIcon;
/**
* AlignmentMatrixControl components enable adjustments to horizontal and vertical alignments for UI.
*
* ```jsx
* import { AlignmentMatrixControl } from '@wordpress/components';
* import { useState } from '@wordpress/element';
*
* const Example = () => {
* const [ alignment, setAlignment ] = useState( 'center center' );
*
* return (
* <AlignmentMatrixControl
* value={ alignment }
* onChange={ setAlignment }
* />
* );
* };
* ```
*/
export const AlignmentMatrixControl = Object.assign(
UnforwardedAlignmentMatrixControl,
{
/**
* Render an alignment matrix as an icon.
*
* ```jsx
* import { AlignmentMatrixControl } from '@wordpress/components';
*
* <Icon icon={<AlignmentMatrixControl.Icon value="top left" />} />
* ```
*/
Icon: Object.assign( AlignmentMatrixControlIcon, {
displayName: 'AlignmentMatrixControl.Icon',
} ),
Comment on lines +114 to +116
Copy link
Member

Choose a reason for hiding this comment

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

👍

}
);

export default AlignmentMatrixControl;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { HStack } from '../../h-stack';
import type { AlignmentMatrixControlProps } from '../types';

const meta: Meta< typeof AlignmentMatrixControl > = {
title: 'Components (Experimental)/AlignmentMatrixControl',
title: 'Components/AlignmentMatrixControl',
component: AlignmentMatrixControl,
subcomponents: {
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170
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 @@ -12,7 +12,11 @@ export {
} from '@wordpress/primitives';

// Components.
export { default as __experimentalAlignmentMatrixControl } from './alignment-matrix-control';
export {
/** @deprecated Import `AlignmentMatrixControl` instead. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan on adding a deprecation warning in a follow-up once all instances are migrated, or are we keeping it "soft deprecated" for now?

Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking we can decide on a per-component basis, using reasoning from #61099. Maybe we'll want to do a more aggressive cleanup in the future, but I don't think it's a pressing need for the moment. I'm anticipating most of these to be passive deprecations.

default as __experimentalAlignmentMatrixControl,
default as AlignmentMatrixControl,
} from './alignment-matrix-control';
export {
default as Animate,
getAnimateClassName as __unstableGetAnimateClassName,
Expand Down
5 changes: 3 additions & 2 deletions storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script>
( function redirectIfStoryMoved() {
const PREVIOUSLY_EXPERIMENTAL_COMPONENTS = [
'navigation',
'alignmentmatrixcontrol',
'customselectcontrol-v2',
'theme',
'navigation',
'progressbar',
'theme',
Comment on lines +4 to +8
Copy link
Member

Choose a reason for hiding this comment

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

Sorted alphabetically

];
const REDIRECTS = [
{
Expand Down
Loading