-
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
Mobile components are diverging too much #18018
Comments
cc @ItsJonQ, you may be interested in this. |
@mcsf Thanks for the heads up! @koke Awesome break down! And thank you for being so active with the discussions!
I would love to as well! As an experiment, maybe we can explore how we can refactor a single component, maybe The tricky thing is, (for me), I don't know of all the ways we'd want something like Since we're starting to leverage Storybook more for web UI, I think it'll be handy to set it up for React Native as well. I think I've chatted about React Native + Storybook briefly with @diegohaz. I think the concerns you've raised is great!! <3 |
I completely agree. Any current interface should be considered ephemeral from the perspective of declaring the functionality of a block. The
Having the mobile project running alongside is a great incentive to make sure the semantics are both general enough and meaningful enough, because we also don't want to create abstractions that end up being obscure.
|
#16384 (comment) bears similar stakes around the semantics—physicality debate. |
@mtias I think that would be the ideal API, but is not clear to me how that would work in a CSS-in-JS solution yet |
In // button.js
export const Button = styled.button`
color: green;
`;
// inspector-controls.js
import {Button} from './button.js';
export const InspectorControls = styled.div`
${Button} {
color: red;
}
`; Though I don't believe this functionality is supported by I think the preferred approach is to use composition - the // button.js
export const Button = styled.button`
color: green;
`;
// inspector-controls.js
import {Button} from './button.js';
export const InspectorControls = styled.div``;
export const InspectorControlsButton = styled(Button)`color: red;`; The semantics of a As a theoretical example, in // we want consistent sizing
<InspectorControls size="large">
<InspectorControls.Button>A</InspectorControls.Button>
<InspectorControls.Button>B</InspectorControls.Button>
</InspectorControls>
// instead of this
<InspectorControls>
<Button isSmall>A</Button>
<Button isLarge>B</Button>
</InspectorControls> There might be a bunch of other properties we might want to constrain on a button within |
That makes perfect sense to me, and it aligns with what I'm used to seeing in mobile. As long as Maybe I don't fully understand |
Yep apologies, that was an over-simplified example! Here's a an example where I've implemented the pattern in recently, using context to pass down shared props like |
@koke Just checking in to see whether this is still an issue for you in testing. |
@jordesign sorry, I haven't worked on gutenberg for the last few years, so I'm not sure if this is still an issue |
I have growing concerns about several issues with our native versions of some components that I've spotted over several PRs recently. I can list the details later, but there are two main ones: Cells and Panels.
Cells: not every control is one
@wordpress/components
is about creating a set of UI elements that you can reuse anywhere. So far, every*Control
element that we have implemented for native, uses a variant of Cell.I understand this is because our current use case is putting these in a
BottomSheet
, but there's nothing about aTextControl
that says it will be used in aBottomSheet
. For instance, the rss block uses aTextControl
within the edit interface. Or the contact forms in Jetpack.TextControl
is a particularly interesting example because it's not even what the control is supposed to be: the native variant is more of a Button than a text input. But we also haveSelectControl
(usesPickerCell
),ToggleControl
(usesSwitchCell
), andRangeControl
(which seems like it skipped adding a native variant of the existing control and used theRangeCell
directly #17282 #17896).We need to find a better way to implement these components so they work anywhere a developer might insert them. And then, figure out how to style them properly when used in a bottom sheet.
Panels, what are they?
The README for Panel has this to say:
However, we don’t collapse the settings sections in mobile. Maybe we’ll want to do that at some point in the future, when we have more settings available, but it seemed like a better UX to not do that.
But we still use
Panel
, even though it’s function is to provide a title and spacing so a group of cells looks like a “section. Then we wanted some buttons in the settings outside any group, so we ended up withPanelActions
in #17703, even though those don’t have anything to do with the original meaning ofPanel
.Semantics vs. Looks
I think both problems reflect the same issue. Gutenberg has created several abstractions that have worked generally well. But, understandably, many of those have ended up tied to how things would end up looking in the web. It didn’t make sense to add an extra level of abstraction if things were only meant to be displayed in one way, but now things are different.
I think we have several problems to solve:
InspectorControls
. AInspectorControlsGroup
would allow a better abstraction where the web can show collapsible panels and the apps can have regular sections without collapsing. If we needed aButton
, we could just add one outside any group, and it would display as expected.Button
inside aInspectorControlsGroup
and have it automatically get the right style (without needing anInspectorControlsButton
). This has been done before on the web via CSS, but if we are exploring styled components and cross-platform solutions, I would like to solve this as well.BottomSheet
is in the previous point. Being able to define howRangeControl
looks in aBottomSheet
might be enough, but we could need newer abstractions to make those work, and that’s OK/cc @WordPress/native-mobile
The text was updated successfully, but these errors were encountered: