-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Add border block support for color, width, and style #31366
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
23b36e4
Add border color, style and width support to image block
aaronrobertshaw 3214b95
Pass image border props to image cropper
aaronrobertshaw 0761a4e
Provide baseline border styles for improved visual feedback
aaronrobertshaw 7221041
Remove unneeded style now block support applied to img
aaronrobertshaw 1b92e84
Adjust caption styles for images in a gallery
aaronrobertshaw de4b702
Fix typo
aaronrobertshaw a738de9
Remove unneeded fallback border styles
aaronrobertshaw 35143eb
Try improving application of custom border styles
aaronrobertshaw 0f519b9
Remove unneeded resizablebox style
aaronrobertshaw 678d024
Tweak application of border-box sizing
aaronrobertshaw ddb227f
Add deprecation for moving border radius and new classname
aaronrobertshaw c888bf5
Remove border radius from align wrapper deprecation fixture
aaronrobertshaw 105edd2
Limit the damage done by theme.json and global styles borders
aaronrobertshaw bf70f60
Add img to Elements API and leverage for image block
aaronrobertshaw 6195058
Add img element to api constants
aaronrobertshaw c145112
Disable border UI in Global Styles when skipping serialization of sup…
aaronrobertshaw ba1daad
Revert "Disable border UI in Global Styles when skipping serializatio…
aaronrobertshaw 386c479
Revert "Add img to Elements API and leverage for image block"
aaronrobertshaw 1b0d8c0
Update image block to leverage feature level selectors for border styles
aaronrobertshaw c189f98
Fix rebase issue after revert of img element
aaronrobertshaw 24f4d0e
Override clearing of img borders in wp-admin by core
aaronrobertshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
RichText, | ||
useBlockProps, | ||
__experimentalGetElementClassName, | ||
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, | ||
} from '@wordpress/block-editor'; | ||
|
||
export default function save( { attributes } ) { | ||
|
@@ -31,18 +32,26 @@ export default function save( { attributes } ) { | |
} = attributes; | ||
|
||
const newRel = isEmpty( rel ) ? undefined : rel; | ||
const borderProps = getBorderClassesAndStyles( attributes ); | ||
|
||
const classes = classnames( { | ||
[ `align${ align }` ]: align, | ||
[ `size-${ sizeSlug }` ]: sizeSlug, | ||
'is-resized': width || height, | ||
'has-custom-border': | ||
!! borderProps.className || ! isEmpty( borderProps.style ), | ||
Comment on lines
+41
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new |
||
} ); | ||
|
||
const imageClasses = classnames( borderProps.className, { | ||
[ `wp-image-${ id }` ]: !! id, | ||
} ); | ||
|
||
const image = ( | ||
<img | ||
src={ url } | ||
alt={ alt } | ||
className={ id ? `wp-image-${ id }` : null } | ||
className={ imageClasses || undefined } | ||
style={ borderProps.style } | ||
width={ width } | ||
height={ height } | ||
title={ title } | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍺