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

Add a rounded corners block style to the Image and Gallery blocks #16949

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 5 additions & 1 deletion packages/block-library/src/gallery/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -25,6 +25,10 @@ export const settings = {
supports: {
align: true,
},
styles: [
{ name: 'default', label: _x( 'Default', 'block style' ), isDefault: true },
{ name: 'rounded-corners', label: _x( 'Rounded Corners', 'block style' ) },
],
transforms,
edit,
save,
Expand Down
13 changes: 13 additions & 0 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,17 @@
justify-content: center;
}
}

// Rounded corners block style
&.is-style-rounded-corners {

img {
border-radius: $grid-size;
}

figcaption {
border-bottom-right-radius: $grid-size;
border-bottom-left-radius: $grid-size;
}
}
}
6 changes: 5 additions & 1 deletion packages/block-library/src/image/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -25,6 +25,10 @@ export const settings = {
'img', // "img" is not translated as it is intended to reflect the HTML <img> tag.
__( 'photo' ),
],
styles: [
{ name: 'default', label: _x( 'Default', 'block style' ), isDefault: true },
{ name: 'rounded-corners', label: _x( 'Rounded Corners', 'block style' ) },
],
transforms,
getEditWrapperProps( attributes ) {
const { align, width } = attributes;
Expand Down
5 changes: 5 additions & 0 deletions packages/block-library/src/image/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@
margin-left: auto;
margin-right: auto;
}

// Rounded corners block style
&.is-style-rounded-corners img {
border-radius: $grid-size;
}
}