patternfly-yew / patternfly-yew

PatternFly components for Yew
https://patternfly-yew.github.io/patternfly-yew-quickstart/
Apache License 2.0
159 stars 30 forks source link

Add Calendar #74

Closed rick-gnous closed 1 year ago

rick-gnous commented 1 year ago

I'm trying to implement CalendarMonth. I must implement more things, like range, fix bugs and I would like to implement DatePicker with it. Actually, you can use it with a callback to get the new date and a default date.

I prefer to open this pull request early to get reviews and avoid mistakes. I'll try to continue the development next week if I've time.

I've also written a basic example for patternfly-yew-quickstart.

ctron commented 1 year ago

That's awesome. Just that you know, there's no need to "do it all". And if you think the API needs some more stabilization, we can always mark this as experimental like the tree (with a feature flag).

rick-gnous commented 1 year ago

I have a strange bug : when I change the month with buttons or by selecting a new date, the Select's initial_selection isn't updated. Else, I think it's good for this part, I'll start to add Date Selector.

I think it'll be better if we add it as experimental, yes. I would like to avoid Select as it's deprecated but I don't take the time to check the others alternatives.

ctron commented 1 year ago

Yea, the Select component is something to replace for PF5.

Most likely the initial_selection is updated. However, as it's the "initial" selection, the component will not update it's internal state based on that.

I think Select needs to be re-implemented based on hooks and a more exterior state management (e.g. using use_state_eq).

I don't want to promise anything, but maybe I can take a look at this at the end of the week.

One more thing I noticed (and I can also swap this out later). I know we had the pattern of Callback::from a lot. However, use_callback makes more sense, as it keeps a stable instance, and reduces changes/redraws.

rick-gnous commented 1 year ago

I've changed some Callback::from with use_callback. I'm working on DatePicker now.

Thank you for yours explanations ! If you can't take a look, I'll try to check it next week.

ctron commented 1 year ago

If you can't take a look, I'll try to check it next week.

I don't want to promise anything. Whoever gets there first :wink:

ctron commented 1 year ago

@rick-gnous I just played with it. This is great!

I went ahead and created a new SimpleSelect component, based on the new, more modular, menu framework. I think this should be what you need. It's pushed to main and there is an example in the quickstart project.

Maybe I find some time this week to migrate your calendar to it.

rick-gnous commented 1 year ago

awesome, thank you ! I'll change my calendar for it. I'll also continue DatePicker !

ctron commented 1 year ago

Btw, it would be great if you could also push a (draft or not) PR for the quickstart … I had to "invent" one myself. Which also is fine. But if you already did the work, I wouldn't want to waste your effort.

rick-gnous commented 1 year ago

And I think we're good ! (btw https://github.com/patternfly-yew/patternfly-yew-quickstart/pull/32)