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

Adding time picker component #654

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mikegiann01
Copy link
Contributor

Hello!Created a time picker component, working also on input_timerange component

Copy link
Collaborator

@iisakkirotko iisakkirotko left a comment

Choose a reason for hiding this comment

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

Hey @mikegiann01!

Great to see another PR from you. I had a couple of comments:

  • Could you include some tests for the component? You can take a look at https://github.com/widgetti/solara/blob/master/tests/unit/input_date_test.py for some guidance
  • I wonder if we should add an argument for using seconds in the picker? Do you think without it we already cover 99% of use cases, or that it would see some use? @maartenbreddels and @mariobuikhuizen feel free to weigh in as well.
  • I think we should also expose some of the restrictions on allowed inputs from Vuetify. At least allowed_minutes I could see people using, when they only want to allow picking in 15/30 minute intervals.

solara/lab/components/input_time.py Show resolved Hide resolved
solara/lab/components/input_time.py Outdated Show resolved Hide resolved
solara/lab/components/input_time.py Outdated Show resolved Hide resolved
@mikegiann01
Copy link
Contributor Author

should i create a new PR the tests?

@iisakkirotko
Copy link
Collaborator

No need, preferably add the tests to this PR.

Copy link
Collaborator

@iisakkirotko iisakkirotko left a comment

Choose a reason for hiding this comment

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

Only one comment on the tests. I also noticed that some of the previous comments I had were marked resolved but no changes were made to the code. Did you maybe forget to push some changes to the component itself?

Comment on lines +150 to +166
def test_input_time_on_open_value():
on_open_value = MagicMock()
on_value = MagicMock()
el = InputTime(value=now, label="label", on_value=on_value, on_open_value=on_open_value)
box, rc = solara.render(el, handle_error=False)
menu = rc.find(vw.Menu)
assert menu is not None

# Simulate opening the time picker
menu.widget.v_model = True
assert on_open_value.call_count == 1
assert on_open_value.call_args[0][0] is True

# Simulate closing the time picker
menu.widget.v_model = False
assert on_open_value.call_count == 2
assert on_open_value.call_args[0][0] is False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be tested by clicking on the input element, rather than by directly opening the menu?

@maartenbreddels maartenbreddels force-pushed the master branch 2 times, most recently from 86646f5 to df2fd66 Compare July 11, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants