In this episode, we're working on displaying the number of available slots for each day directly on our booking calendar. To make room for the slot count, we start off by making each of the date squares on the calendar bigger using some custom CSS with EasePick. We walk through how to override the default variables and get our styles imported.
Next, we get a little hands-on with JavaScript to update the calendar view. We hook into EasePick's setup process and listen for view events, making sure to only target the elements that represent actual days in the calendar (and not, for example, footers or headers). We then go about creating or updating a small span element for each day, initializing it so it can show available slots.
Once we've got our new element showing up in the calendar days, we filter our logic so it only appears for days with actual availability—so we're not showing unnecessary info. We pull the available slot count from our data and display it, also going the extra mile by using the pluralize
package to make sure the label reads properly (for example, '1 slot' vs '2 slots').
By the end of the episode, our calendar now clearly displays how many booking slots are free for each day, making things way more user-friendly for anyone looking to book a time.