cally icon indicating copy to clipboard operation
cally copied to clipboard

Multiple values for CalendarDate

Open CubaJas opened this issue 10 months ago • 5 comments

Great idea select multiple values for calendar date component.

CubaJas avatar Apr 18 '24 09:04 CubaJas

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

WickyNilliams avatar Apr 18 '24 12:04 WickyNilliams

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"
>

CubaJas avatar Apr 18 '24 12:04 CubaJas

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 avatar Apr 18 '24 14:04 WickyNilliams

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

WickyNilliams avatar Apr 18 '24 14:04 WickyNilliams

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 avatar Apr 18 '24 18:04 WickyNilliams

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

WickyNilliams avatar May 10 '24 14:05 WickyNilliams