-
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
Extract separator component out of nextpage block #14175
Conversation
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 component itself might make sense but I would prefer to double check whether changing the Next Page block is expected.
/cc @jasmussen @kjellr
<div className="wp-block-nextpage"> | ||
<span>{ __( 'Page break' ) }</span> | ||
</div> | ||
<Separator customText={ __( 'Page break' ) } /> |
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.
At this moment it might be considered as a breaking change to stop using wp-block-nextpage
class in here. I'm sure that themes already apply their customizations based on this class.
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.
Would it be fine to pass a className
prop to Separator
and have it render it that way, or do we want to ensure there's a wrapper div
around whatever the implementation for separator is?
Thanks for the ping @gziolo, can you clarify what you'd like input on? Is there a visual change? I don't have my Gutenberg Mobile set up properly so it's hard for me to test this. Are we discussing the visual separator block (maps to The last two, read more and nextpage should visually look mostly the same, which is a dashed separator. |
This PR was opened to explore whether we should introduce a new reusable/shared component which visually looks like |
Ah, gotcha. Yeah, if people use that (I know it's an existing WordPress feature), then makes total sense. As noted, I'd use the "read more" block as a guideline for how such a block should look 👍 👍 |
For context, this PR was done to explore how would we write a block in a cross-platform way, using the exact same code for web and native, and extracting all elements into components. What I imagined this On the native side, we've been using react-native-hr, so a similar component could make sense. |
After looking into this a bit more, the I think this |
@mapk @karmatosed, how do you feel about adding new I'm mostly interested whether it fits to the overall picture of how we want to drive WordPress components package. |
I asked for more insights from #design team on WordPress.org Slack (link requires registration at https://make.wordpress.org/chat/): |
This sounds right to me. Thanks for looking into this, @koke! If we can componentize things like this to allow for reusable code across platforms, that would be awesome!
I'm all for it. Do we need to add this to our list for documenting? Or should we wait for the final product first? |
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.
It looks like this component is ready to be tested and documented. Personally, I think that documentation is an important part of exposing new reusable components.
onKeyDown={ onKeyDown } | ||
/> | ||
); | ||
const label = ( editable ? editableLabel : staticLabel ); |
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.
editable
prop is redundant, you can assume that component is editable if onChange
or onKeyDown
prop were passed.
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'm having a hard time saying yes 😁 I think it makes sense in a way, since I can't think of a scenario where you'd want an editable field and not care about when it changes, but conceptually it seems like getting a bit too smart at changing what the component is based on these attributes.
What if the whole label (editable or not) was passed as a child component? We'd still need to create the cross-platform equivalent of TextInput and Text, but it also means that if there are no children passed, this can also be used for the HorizontalRule
component we were discussing in #14361
👋 @gziolo , what are the details you'd like to see documented? Is the README.md of the toogle-control component a good example perhaps? What else besides a README you think would be desirable to add perhaps? Sorry if there are documentation guidelines already in place that I have missed. |
https://github.com/WordPress/gutenberg/tree/master/packages/components/src/form-toggle - |
@koke what's blocking this PR from being finished? Is it still valid? |
It needs more work with testing and documentation, but I haven't found the time to focus on this one. Since this is not even targeting master and I would need to rebase the changes anyway, I'm happy to close this one if you want until I'm ready to work on it again |
It’s fine to leave it as is. I wanted to ensure it’s still actionable 👍 |
This is a proof of concept, do not merge. Also note that this is targeting the gutenberg-mobile develop branch
This PR extracts the horizontal separator into a separate component, effectively making the
nextpage
block cross-platform (running the same code for web and mobile).I think
Separator
would need more work and a better name before merging: we have a similar thing in themore
andseparator
blocks, so we would have to make sure the component covers all the right cases, and it's customizable enough.However I wanted to put up this PR as an example so we can start discussing if this looks like the right approach.