-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RNMobile] Add featured image settings to the Latest Posts block #39257
[RNMobile] Add featured image settings to the Latest Posts block #39257
Conversation
With this commit a 'display featured image' toggle is added to the Latest Post block's settings. This has been added to a new 'Featured image settings' panel.
Size Change: +5 B (0%) Total Size: 1.23 MB
ℹ️ View Unchanged
|
The new 'link to featured image' toggle that's added with this commit will only be visible when the 'displayFeaturedImage' toggle is set to true.
With this commit, the 'BlockAlignmentControl' component is used to add alignment settings under the Latest Post block's featured image settings/section.
Prior to this commit, the BlockAlignmentControl component was only set up to display as a toolbar button on native. With this commit, a "isBottomSheetControl" prop is introduced to enable the component to be styled in a way that's appropriate within BottomSheets.
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.
@SiobhyB thanks for adding the featured image settings to the latest posts block, great work 🎊 .
I tested locally and the changes work as expected, however, I'm wondering whether to use the dropdown for displaying the alignment options. My concern comes from the fact that for other settings like colors, this is done within a subscreen instead of displaying another bottom sheet over the main one. The approach you followed is ok from my side, but in order to keep consistency with the rest of elements within block settings, we might consider that option, wdyt?
I understand that the change I'm suggesting implies applying several changes to the PR, so please don't take it as a mandatory change but just as a suggestion. I'll be more than happy to discuss the best approach and if eventually, we consider continuing with this PR I'll be more than happy to approve it. I'd like also to have a second opinion from another reviewer regarding using a subscreen vs bottom sheet, @jhnstn what's your opinion?
@fluiddot, thank you for your review! I think you're right. I was pretty focused on re-using the Edited to add: I've gone ahead to refactor using the |
As per the following feedback, this commit reverts the implementation of BlockAlignmentControl in the Latest Posts block: #39257 (review)
Makes sense to me, I think the implementation was right but my main concern was about consistency.
Great ⭐, thanks @SiobhyB for updating the PR 🙇 ! I like the idea of using the |
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.
I performed another test on Android and iOS and the changes worked as expected ✅. I only added a comment regarding where to place the BLOCK_ALIGNMENTS_CONTROLS
constant, apart from that the PR looks great to me 🎊 .
<BottomSheetSelectControl | ||
label={ __( 'Image alignment' ) } | ||
options={ BLOCK_ALIGNMENTS_CONTROLS } | ||
onChange={ this.onSetFeaturedImageAlign } | ||
value={ featuredImageAlign } | ||
/> |
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.
In the future, it would be great if BlockAlignmentControl
renders this component (i.e. BottomSheetSelectControl
) underneath, this way we won't need to set up the options and we could use it here.
I was checking the previous commits where you introduced isBottomSheetControl
prop in BlockAlignmentUI
, and I was wondering if we could follow that approach for this. But, I noticed that it most likely imply a big refactor because we would need to implement the native version of the Block Alignment Toolbar component to provide here the BottomSheetSelectControl
component.
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.
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.
Great, thank you very much @SiobhyB for tackling this 🙇.
I'd like to clarify that with my previous comment I didn't want to imply that we had to do the refactor in this PR, but I'm happy to see you sorted it out 😊. I'll try to take a look as soon as possible at the latest changes.
export const BLOCK_ALIGNMENTS_CONTROLS = [ | ||
{ value: undefined, label: __( 'None' ), icon: alignNone }, | ||
{ value: 'left', label: __( 'Align left' ), icon: positionLeft }, | ||
{ | ||
value: 'center', | ||
label: __( 'Align center' ), | ||
icon: positionCenter, | ||
}, | ||
{ value: 'right', label: __( 'Align right' ), icon: positionRight }, | ||
]; |
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.
Not sure if we should expose a native-only constant in the constants file, if it's going to be used only in the edit.native.js
file I might consider defining the constant there, wdyt?
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.
The changes to this shared constants file have been removed following the recent refactor. 👍
@SiobhyB I also noticed that the PR checks look frozen, maybe updating with |
With this commit, the 'BottomSheetSelectControl' component is replaced to make use of 'BlockAlignmentControl'. Any code that relies on 'BottomSheetSelectControl' is also removed.
As more native-specific changes are going to be added to 'ui.js', a native version is created with this commit.
Prior to this commit, the BlockAlignmentControl component was only set up to display as a toolbar button on native. With this commit, a "isBottomSheetControl" prop is introduced to enable the use of the "BottomSheetSelectControl", so that the alignment control can be used within BottomSheets.
Following the separation of native-specific code to its own file, this commit further refines some unnecessary code that was left behind in the (now) web-only file. Specifically, the logic surrounding the 'isCollapsed' prop previously included a check for whether 'isToolbar' is true. Now that there's a native-specific file, 'isCollapsed' will only ever be passed when 'isToolbar' is true. So, the extra check is redundant.
As 'popoverProps' and 'toggleProps' are only passed/used when the toolbar component is used, this commit moves them from the 'commonProps' variable.
@fluiddot, thank you for your suggestions! I've gone ahead with a refactor, so that |
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.
LGTM 🎊 ! Awesome work @SiobhyB 🏅 !
I performed different tests on both native and web platforms and the changes work as expected.
Tested on Samsung Galaxy S20 FE 5G (Android 11) and Simulator iPhone 13 (iOS 15.4).
Thanks so much @fluiddot! 🙇♀️ |
Fixes wordpress-mobile/gutenberg-mobile#4034
Partially fixes #29815
Related PRs
gutenberg-mobile:
[RNMobile] Add featured image settings to the Latest Posts block wordpress-mobile/gutenberg-mobile#4674Description
This PR adds featured image settings to the native Latest Posts block. This is a step towards bringing the available block settings on the native side in alignment with the web. If a user selects the new
Display featured image
toggle, the following two options for customizing the featured image's appearance will be unveiled:Note, the option to specify the featured image's size/dimensions will be addressed separately to this PR. This is because these options are a bit more complex and may warrant some updates to the image block's settings.
Please refer to the
Types of changes
section below for an overview of the code changes.Testing Instructions
Testing changes in the app
Prerequisite: A WordPress site with more than one published blog post, with a featured image assigned to at least one of the posts.
Testing for any web regressions
As these PR introduces some code changes to the web's alignment controls, there is a chance for unintentional regressions. We should therefore test that the alignment controls continue to work as expected while checked out with this branch on the web. Places where the controls appear include within the settings for the Image and Latest Posts blocks.
Screenshots
Video
featured.settings.mov
Types of changes
New feature (non-breaking change which adds functionality), with the following high-level overview of the code:
Featured image settings
section has been added to the Latest Posts settings, following the same code pattern used for other sections.Display featured image
toggle, the following two options for customizing the featured image's appearance will be unveiled:BlockAlignmentControl
component to implement the alignment options, which required the following changes:BLOCK_ALIGNMENTS_CONTROLS
.BlockAlignmentControl
enable theBottomSheetSelectControl
component to be rendered when theisBottomSheetControl
prop is set totrue
. This was a desired change, as it'll make it easier to add alignment options within a block's bottom sheet settings (rather than only the toolbar) in the future.BottomSheetSelectControl
was updated to allow icons to be displayed for each option in the subsheet, enabling the use of the alignment icons. It's likely that the use of icons will be a future use case for other developers using this component, too.Checklist:
*.native.js
files for terms that need renaming or removal).