WickyNilliams / cally

Small, feature-rich calendar components
https://wicky.nillia.ms/cally/
MIT License
1.06k stars 12 forks source link

Multiple values for CalendarDate #26

Closed CubaJas closed 1 month ago

CubaJas commented 2 months ago

Great idea select multiple values for calendar date component.

WickyNilliams commented 2 months ago

you mean a new component like <calendar-multi> or something?

CubaJas commented 2 months ago

you mean a new component like <calendar-multi> or something?

I think the prop value of the component can be string | string[] type and the new prop multiple for detect if someone wants pass array of dates. If multiple doesn't pass to the component and value has an array, component should work with the first item of array.

Like this:

<calendar-date
  value="arrayOfSelectedDays"
  multiple=""
  min="2024-01-01"
  max="2024-12-31"
  locale="en-GB"
>
WickyNilliams commented 2 months ago

I'll probably go for a new component tbh. They're different enough to warrant it, even if they share 90% of the code.

For context I started with range and single date being the same component, but they diverged enough over time that i split into individual components. I imagine the same would happen here eg maybe there's a a prop for max number of dates selectable, toggle events for when a day is selected/deselected, and so on

WickyNilliams commented 2 months ago

That said, I like the idea! I'll do it

WickyNilliams commented 2 months ago

Got a little prototype working locally. Only around 50 lines, since most of the code is reused, apart from handling of arrays. Will probably get it published next week

https://github.com/WickyNilliams/cally/assets/1091390/5d615da5-3222-438d-bd0b-d926fcf6aea7

WickyNilliams commented 1 month ago

Just published v0.6.0 which includes the <calendar-multi> component https://wicky.nillia.ms/cally/components/calendar-multi/