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

DateTime: Create TimeInput component and integrate into TimePicker #60613

Merged
merged 29 commits into from
Jul 1, 2024

Conversation

bogiii
Copy link
Contributor

@bogiii bogiii commented Apr 9, 2024

What?

  • Introduces a simple TimeInput component
  • Integrates the TimeInput into TimePicker component

Why?

Before these changes, there was no option to use the simple time input component.

Before After
Screenshot 2024-04-11 at 12 11 18 Screenshot 2024-04-11 at 12 11 29

How?

Here are more details: #52734

Testing Instructions

  • Go to TimeInput component: http://localhost:50240/?path=/docs/components-timeinput--docs
  • Play with applying different combination of arguments

--

  • Go to TimePicker component: http://localhost:50240/?path=/docs/components-timepicker--docs
  • Check if everything work on same way as before this changes

Unit tests: Good old unit tests found a bug, which is resolved. ✅

Testing Instructions for Keyboard

Screenshots or screencast

Screen Capture on 2024-04-11 at 12-42-03


✍️ Dev Note

TimePicker: Time input can be used in isolation

The time input of the TimePicker component can now be used in isolation as <TimePicker.TimeInput />. In this case, the value will be passed as an object in 24-hour format ({ hours: number, minutes: number }).

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 9, 2024
Copy link

github-actions bot commented Apr 9, 2024

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @bogiii! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@bogiii bogiii changed the title DateTime: Add TimeInput component WIP: DateTime: Add TimeInput component Apr 9, 2024
@bogiii bogiii changed the title WIP: DateTime: Add TimeInput component DateTime: Create TimeInput component and integrate into TimePicker Apr 11, 2024
@bogiii bogiii marked this pull request as ready for review April 11, 2024 21:31
@bogiii bogiii requested a review from ajitbohra as a code owner April 11, 2024 21:31
Copy link

github-actions bot commented Apr 11, 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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @bogiii.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: bogiii.

Co-authored-by: mirka <0mirka00@git.wordpress.org>

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

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Thank you for your patience here! Nice refactor, and thank you for adding tests. I did a first-pass review and wrote some comments.

Have you looked into the e2e failures? They seem relevant.

@bogiii
Copy link
Contributor Author

bogiii commented May 29, 2024

Have you looked into the e2e failures? They seem relevant

Hmmm, it's strange. I've run the tests locally multiple times and passed without any problem.
Also, I've checked the testing flow manually, and it looks fine. 🤔

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Thank you for the follow up!

There are a few more details that need to be sorted out before shipping this publicly, but since this PR is big and has been running long, I'd like to merge this now as a WIP component so @WordPress/gutenberg-components and others (like for #61163) can iterate on it.

I went ahead and pushed two big tweaks, which I'd like you to review in case I'm missing something:

  • Simplify minutesProps passing (58b60be) — The idea here is to pass on all props, not just step, adhering to the "open/closed" pattern.
  • Simplify controlled/uncontrolled logic (fbf1458) — My intent here is twofold. First, to cut down on some useEffect usage that seemed avoidable. Second, to use the useControlledValue hook to simplify the handling of controlled/uncontrolled usage modes. Here, we add a defaultValue prop for the uncontrolled pattern.

Everything else looks good, so I'm ready to merge if you're ok with my changes. Let me know if you find any issues!

Co-authored-by: Lena Morita <lena@jaguchi.com>
@bogiii
Copy link
Contributor Author

bogiii commented Jul 1, 2024

Hey @mirka,

Thanks for the help. I reviewed your changes/suggestions and all looks good!

I'm happy to see it merge. 👍

@mirka
Copy link
Member

mirka commented Jul 1, 2024

Thank you for the great work and collaboration here, @bogiii 🚀

I'll push through the remaining pieces to make this publicly available.

Planned tasks before public ship

@mirka mirka merged commit 67d7413 into WordPress:trunk Jul 1, 2024
59 checks passed
Copy link

github-actions bot commented Jul 1, 2024

Congratulations on your first merged pull request, @bogiii! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions bot added this to the Gutenberg 18.8 milestone Jul 1, 2024
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
…ordPress#60613)

* Move reducer util func to the upper level of utils

* Move from12hTo24h util func to the upper level of utils

* Extract validation logic into separate function

* Add from24hTo12h util method

* Create initial version of TimeInput component

* Support two way data binding of the hours and minutes props

* Add pad start zero to the hours and minutes values

* Add TimeInput story

* Fix two way binding edge cases and optimize onChange triggers

* Remove unnecesarry Fieldset wrapper and label

* Add TimeInput change args type

* Integrate TimeInput into TimePicker component

* Fix edge case of handling day period

* Get proper hours format from the time picker component

With a new TimeInput component, the hours value is in 24 hours format.

* Add TimeInput unit tests

* Update default story to reflect the component defaults

* Simplify passing callback function

* Test: update element selectors

* Add todo comment

* Null-ing storybook value props

* Replace minutesStep with minutesProps prop

* Update time-input component entry props

* Don't trigger onChange event if the entry value is updated

* Simplify minutesProps passing

* Simplify controlled/uncontrolled logic

* Set to WIP status

* Add changelog

* Update test description

Co-authored-by: Lena Morita <lena@jaguchi.com>

---------

Unlinked contributors: bogiii.

Co-authored-by: mirka <0mirka00@git.wordpress.org>
lipemat added a commit to lipemat/types-js-boilerplate that referenced this pull request Aug 21, 2024
@fabiankaegy fabiankaegy added the Needs Dev Note Requires a developer note for a major WordPress release cycle label Oct 1, 2024
@fabiankaegy fabiankaegy mentioned this pull request Oct 1, 2024
97 tasks
@mirka mirka added has dev note when dev note is done (for upcoming WordPress release) and removed Needs Dev Note Requires a developer note for a major WordPress release cycle labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository has dev note when dev note is done (for upcoming WordPress release) [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants