Skip to content
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

Merged
merged 6 commits into from
Jul 31, 2024
Merged

Conversation

mirka
Copy link
Member

@mirka mirka commented Jul 4, 2024

Follow-up to #60613
Closes #52734

What?

Expose TimeInput as a subcomponent of TimePicker. It can now be used (publicly) as TimePicker.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 of TimePicker.TimeInput.

  • TimePicker.TimeInput should show a JSDoc in IntelliSense:

    IntelliSense for TimePicker.TimeInput

Screenshots or screencast

TimePicker.TimeInput in Storybook

cc @bogiii

@mirka mirka added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Jul 4, 2024
@mirka mirka self-assigned this Jul 4, 2024
@mirka mirka requested a review from ajitbohra as a code owner July 4, 2024 19:22
Copy link

github-actions bot commented Jul 4, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: bogiii <bogdannikolic@git.wordpress.org>
Co-authored-by: Tropicalista <tropicalista@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@mirka mirka changed the title TimeInput: Make subcomponent of TimePicker Jul 4, 2024
@mirka mirka requested a review from a team July 4, 2024 19:24
Copy link
Member

@tyxla tyxla left a 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 } />;
Copy link
Member

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
Copy link
Member Author

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
Copy link
Member

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 } />;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing I spotted in the latest Chrome - there is a subtle visual difference between the colon of the TimePicker and in the solo TimeInput:

TimePicker:
Screenshot 2024-07-05 at 13 35 33

TimeInput:
Screenshot 2024-07-05 at 13 35 39

You'll spot that for the TimeInput in isolation, the colon appears a bit bigger.

Copy link
Member Author

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' } );
Copy link
Member

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?

Copy link
Member Author

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.

@mirka mirka requested a review from tyxla July 5, 2024 17:50
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tests well 👍

One thing I've spotted: the order of components in Storybook is still a bit off:

Screenshot 2024-07-08 at 14 09 35

Could be fixed in a follow-up.

@ciampo
Copy link
Contributor

ciampo commented Jul 8, 2024

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?

@mirka
Copy link
Member Author

mirka commented Jul 8, 2024

the order of components in Storybook is still a bit off

@tyxla Is your expectation that these be alphabetical and not grouped together?

@mirka
Copy link
Member Author

mirka commented Jul 8, 2024

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?

@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 👍

@tyxla
Copy link
Member

tyxla commented Jul 8, 2024

the order of components in Storybook is still a bit off

@tyxla Is your expectation that these be alphabetical and not grouped together?

Can be either alphabetical or grouped together, but right now they're none of that, and that was unexpected.

@ciampo
Copy link
Contributor

ciampo commented Jul 8, 2024

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?

@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 👍

There it is #63242

@mirka
Copy link
Member Author

mirka commented Jul 31, 2024

I'm going to merge now since we've agreed on export conventions (#63242).

@mirka mirka merged commit f0874ac into trunk Jul 31, 2024
61 checks passed
@mirka mirka deleted the time-input-namespace branch July 31, 2024 19:34
@github-actions github-actions bot added this to the Gutenberg 19.0 milestone Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
3 participants