Skip to content
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
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ Insert an SVG icon.

- **Name:** [core/icon](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-media/core-block-icon/)
- **Category:** [media](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-media/)
- **Supports:** align (center, left, right), anchor, ariaLabel, color (background, text), dimensions (width), interactivity (clientNavigation), spacing (margin, padding), ~~html~~
- **Supports:** align (center, left, right), anchor, ariaLabel, color (background, text), dimensions (width), interactivity (clientNavigation), shadow, spacing (margin, padding), ~~html~~
- **Attributes:** flipHorizontal, flipVertical, icon, rotation

## Image
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
- [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color): `true`
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
- `clientNavigation`: `true`
- [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow): `true`
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
- `padding`: `true`
- `margin`: `true`
Expand All @@ -43,6 +44,7 @@ _Defined via the [`selectors`](https://developer.wordpress.org/block-editor/refe

- **root**: `.wp-block-icon svg`
- **css**: `.wp-block-icon`
- **shadow**: `.wp-block-icon svg`
- **spacing**:
- margin: `.wp-block-icon`

Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/icon/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
"interactivity": {
"clientNavigation": true
},
"shadow": {
"__experimentalSkipSerialization": true
},
"__experimentalBorder": {
"color": true,
"radius": true,
Expand Down Expand Up @@ -75,6 +78,7 @@
"selectors": {
"root": ".wp-block-icon svg",
"css": ".wp-block-icon",
"shadow": ".wp-block-icon svg",
"spacing": {
"margin": ".wp-block-icon"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/icon/edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
useBlockEditingMode,
__experimentalUseColorProps as useColorProps,
__experimentalUseBorderProps as useBorderProps,
__experimentalGetShadowClassesAndStyles as useShadowProps,
__experimentalGetSpacingClassesAndStyles as useSpacingProps,
getDimensionsClassesAndStyles as useDimensionsProps,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -111,6 +112,7 @@ export function Edit( { attributes, setAttributes, isSelected, context } ) {
},
} );
const borderProps = useBorderProps( attributes );
const shadowProps = useShadowProps( attributes );
const dimensionsProps = useDimensionsProps( attributes );

const selectedIcon = useSelect(
Expand Down Expand Up @@ -282,6 +284,7 @@ export function Edit( { attributes, setAttributes, isSelected, context } ) {
style: {
...colorProps.style,
...borderProps.style,
...shadowProps.style,
...spacingProps.style,
...dimensionsProps.style,
...rotationStyle,
Expand All @@ -298,6 +301,7 @@ export function Edit( { attributes, setAttributes, isSelected, context } ) {
) }
style={ {
...borderProps.style,
...shadowProps.style,
...spacingProps.style,
...dimensionsProps.style,
...rotationStyle,
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/icon/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ function render_block_core_icon( $attributes ) {
);
}

// Shadow.
$shadow_styles = $attributes['style']['shadow'] ?? null;

// Spacing (Padding).
$spacing_styles = array();
if ( isset( $attributes['style']['spacing']['padding'] ) ) {
Expand All @@ -83,6 +86,7 @@ function render_block_core_icon( $attributes ) {
array(
'color' => $color_styles,
'border' => $border_styles,
'shadow' => $shadow_styles,
'spacing' => $spacing_styles,
'dimensions' => $dimensions_styles,
),
Expand Down
Loading