-
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
TimeInput: Expose as subcomponent of TimePicker #63145
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Looking good overall.
Glad subcomponents
support won't be dropped anytime soon.
I've left a few questions, nothing critical.
@@ -49,3 +51,16 @@ const Template: StoryFn< typeof TimePicker > = ( { | |||
}; | |||
|
|||
export const Default: StoryFn< typeof TimePicker > = Template.bind( {} ); | |||
|
|||
const TimeInputTemplate: StoryFn< typeof TimePicker.TimeInput > = ( args ) => { | |||
return <TimePicker.TimeInput { ...args } />; |
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.
Felt a bit odd to me that the currentTime
doesn't seem to work for the TimeInput
story, while it does for the default TimePicker
one:
Screen.Recording.2024-07-05.at.13.32.06.mov
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.
You're right, I should've hidden the controls for that story (1bb3f2f).
@@ -16,6 +16,8 @@ import TimePicker from '../time'; | |||
const meta: Meta< typeof TimePicker > = { | |||
title: 'Components/TimePicker', | |||
component: TimePicker, | |||
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170 |
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.
👍
@@ -49,3 +51,16 @@ const Template: StoryFn< typeof TimePicker > = ( { | |||
}; | |||
|
|||
export const Default: StoryFn< typeof TimePicker > = Template.bind( {} ); | |||
|
|||
const TimeInputTemplate: StoryFn< typeof TimePicker.TimeInput > = ( args ) => { | |||
return <TimePicker.TimeInput { ...args } />; |
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.
Good catch 😳 Fixed in d94947d
* ``` | ||
*/ | ||
TimePicker.TimeInput = TimeInput; | ||
Object.assign( TimePicker.TimeInput, { displayName: 'TimePicker.TimeInput' } ); |
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.
We're now exposing TimePicker.TimeInput
as a public subcomponent, right? In that case, shouldn't we be documenting it in the README? This reminds me we also don't document TimePicker
and DatePicker
at this time - do you know if this is intentional?
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.
Correct. I'll be adding a readme in the next PR. I guess there is a bit of inconsistency for subcomponent readmes, but I think TimeInput warrants a separate readme because the props are distinct.
do you know if this is intentional?
It doesn't seem like an oversight, because the DateTimePicker readme does mention that DatePicker and TimePicker can be used individually.
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 was going to create an issue where we discuss which naming convention we want to adopt across the components package for "component families" / "compound components" / subcomponents, for better consistency (especially as we plan on having more compound components gong forward). Do you think it would be beneficial to agree on that naming convention before exposing a new component which may potentially require an export name change soon? |
@tyxla Is your expectation that these be alphabetical and not grouped together? |
@ciampo I didn't have any alternative namings for this in mind, but I'm curious what your proposals are. I can wait for your issue to be posted 👍 |
Can be either alphabetical or grouped together, but right now they're none of that, and that was unexpected. |
There it is #63242 |
# Conflicts: # packages/components/CHANGELOG.md
I'm going to merge now since we've agreed on export conventions (#63242). |
Follow-up to #60613
Closes #52734
What?
Expose
TimeInput
as a subcomponent ofTimePicker
. It can now be used (publicly) asTimePicker.TimeInput
.Why?
So we don't clutter the global namespace when exposing modular parts of a component.
Testing Instructions
The Storybook for
TimePicker
should be clear about the use ofTimePicker.TimeInput
.TimePicker.TimeInput
should show a JSDoc in IntelliSense:Screenshots or screencast
cc @bogiii