- { stylesToRender.map( ( style ) => {
- const buttonText = style.label || style.name;
-
- return (
-
- );
- } ) }
-
styleItemHandler( null ) }
+ onMouseLeave={ () => hoverStyleHandler( null ) }
>
{
- const { getBlock } = select( blockEditorStore );
+ const { getBlock, getSettings } = select( blockEditorStore );
const block = getBlock( clientId );
if ( ! block ) {
return {};
}
+
const blockType = getBlockType( block.name );
const { getBlockStyles } = select( blocksStore );
+ const styles = getBlockStyles( block.name );
+
+ // Add theme.json styles for each block style if available.
+ const variations =
+ getSettings().__experimentalStyles?.blocks?.[ block.name ]
+ ?.variations ?? {};
+
+ if ( variations ) {
+ styles?.forEach( ( style, index ) => {
+ if ( variations[ style.name ] ) {
+ styles[ index ].styles = variations[ style.name ];
+ }
+ } );
+ }
return {
block,
blockType,
- styles: getBlockStyles( block.name ),
+ styles,
className: block.attributes.className || '',
};
};
diff --git a/packages/block-library/src/group/index.js b/packages/block-library/src/group/index.js
index 2d06f1a965c521..1ccfa4fa89c1aa 100644
--- a/packages/block-library/src/group/index.js
+++ b/packages/block-library/src/group/index.js
@@ -22,14 +22,6 @@ export { metadata, name };
export const settings = {
icon,
example: {
- attributes: {
- style: {
- color: {
- text: '#000000',
- background: '#ffffff',
- },
- },
- },
innerBlocks: [
{
name: 'core/paragraph',
diff --git a/packages/components/src/custom-select-control-v2/index.tsx b/packages/components/src/custom-select-control-v2/index.tsx
index 614f52105513f4..6bc38db3080bb3 100644
--- a/packages/components/src/custom-select-control-v2/index.tsx
+++ b/packages/components/src/custom-select-control-v2/index.tsx
@@ -19,6 +19,7 @@ import type {
CustomSelectContext as CustomSelectContextType,
} from './types';
import type { WordPressComponentProps } from '../context';
+import { VisuallyHidden } from '../visually-hidden';
export const CustomSelectContext =
createContext< CustomSelectContextType >( undefined );
@@ -45,11 +46,13 @@ function defaultRenderSelectedValue( value: CustomSelectProps[ 'value' ] ) {
export function CustomSelect( {
children,
defaultValue,
+ hideLabelFromVision = false,
label,
onChange,
size = 'default',
value,
renderSelectedValue = defaultRenderSelectedValue,
+ popoverProps,
...props
}: WordPressComponentProps< CustomSelectProps, 'button', false > ) {
const store = Ariakit.useSelectStore( {
@@ -59,12 +62,23 @@ export function CustomSelect( {
} );
const { value: currentValue } = store.useState();
+ const selectPopoverProps = {
+ gutter: 12,
+ sameWidth: true,
+ ...popoverProps,
+ store,
+ };
return (
<>
-
- { label }
-
+ { hideLabelFromVision && (
+ { label }
+ ) }
+ { ! hideLabelFromVision && (
+
+ { label }
+
+ ) }
-
+
{ children }
diff --git a/packages/components/src/custom-select-control-v2/styles.ts b/packages/components/src/custom-select-control-v2/styles.ts
index c04f6ac32e5ffb..43bd224bb2bb9d 100644
--- a/packages/components/src/custom-select-control-v2/styles.ts
+++ b/packages/components/src/custom-select-control-v2/styles.ts
@@ -63,6 +63,8 @@ export const CustomSelectPopover = styled( Ariakit.SelectPopover )`
border-radius: ${ space( 0.5 ) };
background: ${ COLORS.white };
border: 1px solid ${ COLORS.gray[ 900 ] };
+ /* Force the passed wrapper props z-index otherwise it's overridden. */
+ z-index: ${ ( props ) => props.wrapperProps?.style?.zIndex };
`;
export const CustomSelectItem = styled( Ariakit.SelectItem )`
diff --git a/packages/components/src/custom-select-control-v2/types.ts b/packages/components/src/custom-select-control-v2/types.ts
index 2aecc1d4746f5c..49a9105cf54f08 100644
--- a/packages/components/src/custom-select-control-v2/types.ts
+++ b/packages/components/src/custom-select-control-v2/types.ts
@@ -23,6 +23,12 @@ export type CustomSelectProps = {
* non-disabled item will be used.
*/
defaultValue?: string | string[];
+ /**
+ * If true, the label will only be visible to screen readers.
+ *
+ * @default false
+ */
+ hideLabelFromVision?: boolean;
/**
* Label for the control.
*/
@@ -31,6 +37,10 @@ export type CustomSelectProps = {
* A function that receives the new value of the input.
*/
onChange?: ( newValue: string | string[] ) => void;
+ /**
+ * Optional props passed to the Select Popover.
+ */
+ popoverProps?: Ariakit.SelectPopoverProps;
/**
* Can be used to render select UI with custom styled values.
*/
diff --git a/packages/components/src/private-apis.ts b/packages/components/src/private-apis.ts
index 6694c1d30bdce8..6eb019f0f7c3e8 100644
--- a/packages/components/src/private-apis.ts
+++ b/packages/components/src/private-apis.ts
@@ -14,6 +14,7 @@ import {
useCompositeStore as useCompositeStoreV2,
} from './composite/v2';
import { default as CustomSelectControl } from './custom-select-control';
+import { CustomSelect, CustomSelectItem } from './custom-select-control-v2';
import { positionToPlacement as __experimentalPopoverLegacyPositionToPlacement } from './popover/utils';
import { default as ProgressBar } from './progress-bar';
import { createPrivateSlotFill } from './slot-fill';
@@ -41,6 +42,8 @@ lock( privateApis, {
CompositeRowV2,
useCompositeStoreV2,
CustomSelectControl,
+ CustomSelect,
+ CustomSelectItem,
__experimentalPopoverLegacyPositionToPlacement,
createPrivateSlotFill,
ComponentsContext,
diff --git a/packages/editor/src/components/provider/use-block-editor-settings.js b/packages/editor/src/components/provider/use-block-editor-settings.js
index eddc295766f8ce..90f2e512fada66 100644
--- a/packages/editor/src/components/provider/use-block-editor-settings.js
+++ b/packages/editor/src/components/provider/use-block-editor-settings.js
@@ -25,6 +25,7 @@ const BLOCK_EDITOR_SETTINGS = [
'__experimentalBlockDirectory',
'__experimentalDiscussionSettings',
'__experimentalFeatures',
+ '__experimentalStyles',
'__experimentalGlobalStylesBaseStyles',
'__experimentalPreferredStyleVariations',
'__unstableGalleryWithImageBlocks',