Claude-skill-registry-data managing-date-selection
Implements the "Restart Logic" for date range selection in the Tourly search widget. Use when building or modifying the date picker, handling check-in/check-out dates, or implementing calendar interaction algorithms.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry-data
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry-data "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/managing-date-selection" ~/.claude/skills/majiayu000-claude-skill-registry-data-managing-date-selection && rm -rf "$T"
manifest:
data/managing-date-selection/SKILL.mdsource content
Smart Date Range Selection Logic (Tourly)
When to use this skill
- Implementing the date range selection in the search bar or booking forms.
- Modifying
or Shadcn Calendar behavior to match Tourly's custom "Restart Logic".react-day-picker - Handling edge cases where users select an earlier date than the current start date.
Workflow
- Initialize state for
,startDate
, andendDate
.isCalendarOpen - Implement the
algorithm following the Scenarios below.handleDateSelect - Apply visual styles to the input field and calendar cells based on the selection state.
- Ensure the popover only closes on a valid range completion.
The Smart Range Algorithm
Scenario A: Starting Fresh / Resetting
- Condition: No dates selected OR both dates selected and a new date is clicked.
- Action: Set
to selected,startDate
toendDate
. Keep popover OPEN.null
Scenario B: Valid Range Completion
- Condition:
exists,startDate
isendDate
, andnull
.selectedDate > startDate - Action: Set
to selected. CLOSE popover.endDate
Scenario C: Backwards Selection (Restart Logic)
- Condition:
exists,startDate
isendDate
, andnull
.selectedDate < startDate - Action: Set
to selected,startDate
toendDate
. Keep popover OPEN.null - Note: Do NOT swap dates. Treat this as a correction of the start date.
Visual Requirements
- Input Text: Use low-opacity/gray text (e.g.,
) to match placeholder style.text-muted-foreground - Calendar Header: Must display "Select Dates".
- Highlighting:
- Ends: Solid primary color circles.
- In-between: Light primary background (e.g.,
) for the range.bg-primary/20
Instructions
- Closing Rule: The popover MUST NOT close until Scenario B is met. Automatic closing on the first click is a failure.
- Library Integration: When using
, intercept thereact-day-picker
oronSelect
events to apply this custom logic manualy rather than using the default range mode.onDayClick