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

Image Block: Add border radius support #27667

Merged
merged 2 commits into from
Jan 25, 2021
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
1 change: 1 addition & 0 deletions docs/designers-developers/developers/themes/theme-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ h4 {
| Context | Radius |
| --- | --- |
| Group | Yes |
| Image | Yes |

#### Color Properties

Expand Down
5 changes: 4 additions & 1 deletion packages/block-library/src/image/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
}
},
"supports": {
"anchor": true
"anchor": true,
"__experimentalBorder": {
"radius": true
}
},
"editorStyle": "wp-block-image-editor",
"style": "wp-block-image"
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/image/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ figure.wp-block-image:not(.wp-block) {
margin-top: -9px;
margin-left: -9px;
}

&:not(.is-style-rounded) > div {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be serialized to the inner element (img) in the edit function by using __experimentalSkipSerialization? Adding JS/CSS/etc. to a block so it can use some block supports is a smell that we need to do something differently.

This is now relevant for this PR, in which we're making the block selector to target the inner img. See https://github.com/WordPress/gutenberg/pull/34073/files#r688580510

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it can be serialized to the img element now. This wasn't possible when this PR was done as the __experimentalSkipSerialization option didn't exist yet.

There is actually already a PR that moves the border radius support styles to the inner image element as part of adopting border color and width support for the image block. #31366

I can sort out the style mentioned here as part of that.

border-radius: inherit;
}
}

// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
max-width: 100%;
}

&:not(.is-style-rounded) img {
border-radius: inherit;
}

&.aligncenter {
text-align: center;
}
Expand Down