-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Merged
Merged
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions
17
packages/block-library/src/gallery/columns-control/index.js
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { RangeControl } from '@wordpress/components'; | ||
|
||
const ColumnsControl = ( { label, value, onChange, min, max } ) => ( | ||
<RangeControl | ||
label={ label } | ||
max={ max } | ||
min={ min } | ||
onChange={ onChange } | ||
required | ||
value={ value } | ||
/> | ||
); | ||
|
||
export default ColumnsControl; |
17 changes: 17 additions & 0 deletions
17
packages/block-library/src/gallery/columns-control/index.native.js
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { StepperControl } from '@wordpress/components'; | ||
|
||
const ColumnsControl = ( { label, value, onChange, min, max } ) => ( | ||
<StepperControl | ||
label={ label } | ||
max={ max } | ||
min={ min } | ||
onChange={ onChange } | ||
separatorType="fullWidth" | ||
value={ value } | ||
/> | ||
); | ||
|
||
export default ColumnsControl; |
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
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.
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 uglierMOBILE_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:
separatorType
s.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 ofPanelBody
, 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 withinPanelBody
, then I would agree this should be managed byPanelBody
(either by styling, or perhaps in its render behavior in inspecting/iterating itsprops.children
).