-
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] - Gallery Block: Columns Control #20231
Conversation
…mobile (StepperControl) variants
One thing I like about this is that it makes it clear that it will be painful to use a native- or web-exclusive component. I would like that to be as painful as possible to discourage the practice, because I would prefer there to be few (ideally zero) differences in the component set we offer between web and mobile. Related to aforementioned design decision, statements like "stepper is better than a range when fewer options exist" do not seem to me as exclusive to one or the other of mobile or web, so I'm still not entirely convinced this should be a native-only component. |
@@ -384,7 +382,6 @@ class GalleryEdit extends Component { | |||
{ images.length > 1 && ( | |||
<ColumnsControl | |||
label={ __( 'Columns' ) } | |||
{ ...MOBILE_CONTROL_PROPS } |
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 problem with this sort of spread is that it makes it unclear to me now in this moment of refactoring whether we can remove the MOBILE_CONTROL_PROPS
object or any of its properties. I see that it is spread into other components, but I have no idea what (or if any) of the properties are being used in those components.
I would have preferred that each prop were individually listed, even if that is more verbose, to make it clearer what is needed and where.
Or better yet, and to the same point as #20231 (comment), we aim to avoid any differences in the component API, so that we don't need to do this at all.
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.
Hi @aduth 👋
This current implementation with the MOBILE_CONTROL_PROPS
object (as well as the even uglier MOBILE_CONTROL_PROPS_SEPARATOR_NONE
object introduced here) is admittedly a pretty hacky workaround. This in part arises from differences in how controls are displayed on web and native (on native, PanelBody
is in the bottomsheet).
There are at least two areas of technical debt that prompt this awkwardness:
- Native implementations of various control components have different default
separatorType
s. - The responsibility of rendering (or not) the separator currently belongs to the
Cell
component, from which all mobile control components are composed.
Proposed solutions:
Due to 1., we must "manually" specify the separator types to ensure consistency in a group of controls (not ideal). Instead, the controls should have a common default separatorType
obviating the need for this hack. Due to 2., the responsibility of handling fence-post issues for the separators is left to the parent components. It might make more sense to shift this responsibility to the native implementation of PanelBody
, or if not there, a container component to abstract it away and avoid fence-post logic "leaking" into the parent views.
In the current implementation, these spreadables were extracted to the top per this discussion: #18265 (comment), however, you raise an interesting point about the "painfulness" signalling. Having each prop verbosely listed (with appropriate comments included) could serve to amplify the existence of the underlying technical debt (which is currently signaled only by the code comment).
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.
Yeah, I don't exactly understand how this needs to behave in mobile with showing in the bottom card, but it does not seem to me that this separator ought to be a concern of the *Control
components, which are otherwise labeled input controls agnostic to where they occur in the page. If it's a consequence of how these are rendered within PanelBody
, then I would agree this should be managed by PanelBody
(either by styling, or perhaps in its render behavior in inspecting/iterating its props.children
).
I agree with this, and it may be a good candidate for code sharing too. Though, I think perhaps some name changes to a shared common component might be useful, since IIRC, "stepper" can mean a different thing on web (actually on Android as well): a task-driven, or "checkout page" kind of UX. |
I think conceptually Also, I think it's worth revisiting what I think there's room for |
@aduth I am very interested in hearing more about the unmet expectation here. Do you mean mobile team should've implemented the web equivalent of Stepper as well? Or we should have avoided to add the native only Stepper in the first place? |
@pinarol For me, it's a bit of both of what you mention. We should want to avoid adding components which target only one or the other of web or native. And if we do implement one, to at least have some interoperability in place to minimally support the component in both environments. I really like this bit from @koke's comment:
Originally, I had been thinking that maybe But to @koke's point, the underlying interface of a component doesn't need to be so prescriptive about the specific UI it creates. If the purpose of In other words, would it be reasonable to eliminate |
Yes, I think it would be reasonable for the cases we have currently. Not sure what future will bring but we can always iterate later. I have opened a tech debt issue to address this and added to our project board. We'll try to take care of this in the following ~2 sprints. Thanks! Same for the separatorType issue, we shouldn't delay it much. BTW, sharing the same component library has been in our radar for quite some time. We worked on “cross-platformitization” of components like: InspectorControls, ToggleControl, SelectControl, RangeControl, MediaPlaceholder, MediaUpload... ~6 months ago none of them shared the same props, also some of them behaved differently. We refactored them to unify props between platforms. We have been also working on x-platform primitive components so that we can define a common style system between web & mobile. |
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 other words, would it be reasonable to eliminate
StepperControl
and absorb the logic of rendering a step control into the existingRangeControl
?
I had the same objections when StepperControl
was proposed. In general branching code based on the UI aspects is problematic as it makes using components harder. You have to add another layer of indirection in the place where they are consumed. This PR fixes also an issue where StepperControl
was imported for web implementation but it was never exposed when using from npm.
@gziolo Could you point me to those objections? If there's anything that we ignored I'd love to do a retro about why it happened that way with the team. We always try to include web folks in such PRs, as far as I see Stepper control was merged with this PR and I see that you asked a question, and sorry if I mistranslated it but that doesn't seem like an objection to me. If there's something else please let us know. |
Yes, it looks like this comment and it doesn't look like strong "no" 😄 I don't want to block the work only because I have a different opinion on how to approach it. To be clear, I'm not against having dedicated components for mobile UI but we should always try to move the web implementation in the direction that helps components to be cross-platform by keeping higher-level API that makes it easier to consume code. |
Gutenberg Mobile
PR -> wordpress-mobile/gutenberg-mobile#1905Description
Due to this PR #19947 a warning started to show up due to a missing import for web.
I'm proposing to add a
ColumnsControl
component with its ownWeb
andMobile
variant.The
Web
variant will have theRangeControl
and theMobile
will have theStepperControl
.Having two different components (Slider / Stepper) was a design decision to improve the UX on mobile.
Any other solution for this case is more than welcome =)
How has this been tested?
Web:
Gallery
blockMobile:
Gallery
blockTypes of changes
Bug fix (Import Warning)
Checklist: