311-data icon indicating copy to clipboard operation
311-data copied to clipboard

DEV - Update Datepicker: Start Date, End Date, Remove Chips

Open traycn opened this issue 2 years ago • 18 comments

Dependency

  • [x] #1891
  • [x] #1892

Overview

We need to update the DatePicker component to utilize two different fields for Start Date and End Date, as well as remove the pre-defined date chips. This will reduce user confusion around how to complete their date range selection.

Action Items

Before getting started...

  • [x] ⚠️ I acknowledge that we are not implementing the pre-selected date chips in the spec ⚠️
    • see Resource, Screenshot: Date Chips In Spec, Do Not Implement

Updating the date picker form fields and dropdowns...

  • [x] Modify the DateSelector component to replace the pre-selected date chips with the ReactDayPicker modal
    • [x] Remove the <DateRanges> component within SelectorBox.Collapse, replace with <ReactDayPicker>
    • [x] Remove the separator div
  • [x] Modify the DatePicker component to have two new fields, StartDate and EndDate
    • [x] Update the Calendar icon to use the new SVG (see references)
    • [x] Move the Calendar icon to the same form field as StartDate
    • [x] Modify renderSelectedDays() to populate these two fields, rather than populating the spans
      • [x] Extra Credit: write in a comment how you might write tests for this user flow
    • [x] Modify border styles on focus
      • [x] border size is 2px
      • [x] border color is SecondaryFocus
    • [x] Modify text color styles...
      • [x] White (#FFFFFF) when a date is provided (pls confirm w/ design)
      • [x] TextSecondaryLight when a date is not provided
  • [x] Modify ReactDayPicker...
    • [x] previous and next arrows should be PrimaryFocus from theme/colors.js
    • [x] Selected Start Day styles are modified...
      • [x] background color will be SecondaryFocus
      • [x] text color will be TextPrimaryDark
      • [x] border is removed
    • [x] Selected range (without start and end dates) styles are modified...
      • [x] background color will be PrimaryLight
    • [x] Selected End Day styles are modified...
      • [x] background color will be PrimaryLight
      • [x] border color is SecondaryFocus
      • [x] border size should be 1px
      • [x] text color should be TextSecondaryLight
    • [x] Extra Credit: find a way to standardize styles within this file, try to reduce usage of magic numbers, but without adding unnecessary indirection
  • [x] Ensure functionality matches the specification, document how you would test the interaction
    • [x] ReactDayPicker should highlight the StartDate/EndDate form field when selecting a new start date/end date (respectively)
    • [x] Clicking the StartDate/EndDate should open the ReactDayPicker dropdown
    • [x] The ReactDayPicker dropdown should close once both StartDate and EndDate have been selected
  • [ ] Optional: Consider refactoring components to use more sensible names and/or organization
    • [ ] Suggestion: combine DateSelector with DatePicker component, named DateSelectionForm
    • [ ] Suggestion: rename ReactDayPicker to DayPickerContainer
  • [ ] Extra Credit: make a ticket(s) to do the following...
    • [ ] ensure colors are being chosen from our theme file, everywhere in the app
    • [ ] consider adopting Tailwind CSS, or some other way of moving our theme data out of bundled JS files

Resources/Instructions

Calendar Icon SVG

<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.6667 3.16671H12V1.83337H10.6667V3.16671H5.33333V1.83337H4V3.16671H3.33333C2.59333 3.16671 2 3.76671 2 4.50004V13.8334C2 14.5667 2.59333 15.1667 3.33333 15.1667H12.6667C13.4 15.1667 14 14.5667 14 13.8334V4.50004C14 3.76671 13.4 3.16671 12.6667 3.16671ZM12.6667 13.8334H3.33333V6.50004H12.6667V13.8334ZM4.33333 9.16671C4.33333 8.24671 5.08 7.50004 6 7.50004C6.92 7.50004 7.66667 8.24671 7.66667 9.16671C7.66667 10.0867 6.92 10.8334 6 10.8334C5.08 10.8334 4.33333 10.0867 4.33333 9.16671Z" fill="#A8A8A8"/>
</svg>

Screenshot: Date Chips In Spec, Do Not Implement

⚠️ We are not adding the chips shown below. Please disregard area marked by the red box ⚠️

Image

Screenshot: Figma Section at a Glance

Date picker components with no parent components

Image

Date picker components within the Search and Filters modal

Image

Hand Off Materials

  • Figma Section Name: Search/Filter Modal #1600 - Final
    • Interactive Prototype Figma file
      • please refer to the 'Allison J' page and the wireframes under 'INTERACTIVE PROTOTYPE - 2.27.24'
    • Popover Message Figma file - refer to the 'Anna K' page and the 'Popover' section
  • Design issue for reference: https://github.com/hackforla/311-data/issues/1600
Screenshot before proposed changes

Screen Shot

Screenshot after proposed changes

Screen Shot

traycn avatar Nov 22 '24 02:11 traycn

Moving out of icebox now that last dependency is met:

  • https://github.com/hackforla/311-data/issues/1891

rayneng avatar May 10 '25 01:05 rayneng

We are holding off on this because these designs still have the pre-selected date chips, which I know for a fact we are removing as part of the blank map designs:

  • https://github.com/hackforla/311-data/issues/1944

rayneng avatar May 22 '25 06:05 rayneng

Almost done working on this ticket. I'm realizing that we do want the dropdown functionality, but now the dropdown will trigger as part of opening the day picker. The day picker will no longer popover as a dialog, but should take up dedicated space in the search and filters modal.

ETA tmo.

rayneng avatar Jul 21 '25 07:07 rayneng

This is ready to be picked up 👍

rayneng avatar Jul 22 '25 04:07 rayneng

  1. Progress: n/a
  2. Blockers: n/a
  3. Availability: Sat - Sun 6pm - 9pm
  4. ETA: 2025-09-05

melissaluc avatar Aug 21 '25 02:08 melissaluc

Unassigning since Melissa is working on

  • https://github.com/hackforla/311-data/issues/2013

rayneng avatar Aug 28 '25 01:08 rayneng

Per meeting on 9/24/2025, will merge into main once complete.

DrAcula27 avatar Sep 25 '25 02:09 DrAcula27

ETA: 8 October 2025 Availability: weekday afternoons - evenings

DrAcula27 avatar Sep 25 '25 02:09 DrAcula27

Update

  • So far, I have managed to get a good start on this ticket. No questions as of yet, but I have checked off the boxes for what I have done.
  • Blockers: job interview prep, study prep.
  • Availability: weekdays after 5pm pacific time.
  • New ETA for issue completion: 22 October 2025 (since I have to study now as well)

DrAcula27 avatar Oct 09 '25 00:10 DrAcula27

Blockers: need help figuring out where the dang dropdown arrow comes from :)

DrAcula27 avatar Oct 16 '25 00:10 DrAcula27

Update: figured out where the dropdown arrow comes from and got it hidden. Blocker: with the arrow hidden, now the calendar no longer wants to show.

DrAcula27 avatar Oct 22 '25 23:10 DrAcula27

Extra Credit: write in a comment how you might write tests for this user flow

Modify the DatePicker component to have two new fields, StartDate and EndDate

  • Since we are not allowing the user to type in a start date or an end date, I would write unit tests for these scenarios:
      1. user choosing first a start date and then an end date by clicking on the start date field, then selecting a range of dates in the calendar popup (the ReactDayPicker component).
      1. user leaving start date alone and just picking a new end date by clicking on the end date field, then choosing a new end date that is after the start date.
      1. if the user clicks the end date field, but chooses a date prior to the current selected start date, make that the new start date and allow the user to choose a new end date.
      1. if the user has chosen a start date that is not the current month, when the user clicks the start date field to update the start date, the calendar popup should pop up on the current selected date's month, not the current month. The same goes for the end date field.
      1. clicking outside the calendar popup closes the popup.
  • I would write an integration test for:
      1. when the user opens the calendar popup, the popup should push the rest of the modal down, not just cover it.

DrAcula27 avatar Oct 29 '25 21:10 DrAcula27

For the DatePicker component style changes:

  • Modify text color styles...
    • White (#FFFFFF) when a date is provided (pls confirm w/ design)
      • I left this as the default (#ececec) because that is what is called out in src/theme/colors.js as textSecondaryLight and I felt it was the most appropriate color choice.
    • TextSecondaryLight when a date is not provided
      • I used textSecondaryDark when a date is not provided here, as it matched better with the Figma files and attached screenshots.

DrAcula27 avatar Oct 29 '25 23:10 DrAcula27

For this bit: previous and next arrows should be PrimaryFocus from theme/colors.js:

  • changing the colors was challenging because the provided arrows from React's DayPicker component (what we were using) are actually images.
    • to avoid writing my own DayPicker component, I used CSS filters to change the color. I actually found a tool that someone made where you input a target color as a hex code, and it outputs what filters to use. https://codepen.io/sosuke/pen/Pjoqqp

DrAcula27 avatar Oct 30 '25 00:10 DrAcula27

Screenshots of Final Product

Collapsed Date Picker

Image

Expanded Date Picker with Focused Start Date Field

Image

Expanded Date Picker with Focused End Date Field

Image

DrAcula27 avatar Oct 30 '25 03:10 DrAcula27

Danielle demoed latest version of datepicker updates. My review notes:

  • [ ] after selecting a StartDate, I noticed that the End Date form field was not highlighted. This would lead to confusion on whether the user needs to click on the End Date form field in order to proceed
  • [ ] instead, selecting the StartDate should then focus the End Date form field, so that it is clear that the user should select an EndDate

rayneng avatar Oct 30 '25 03:10 rayneng

Danielle demoed latest version of datepicker updates. My review notes:

  • [x] after selecting a StartDate, I noticed that the End Date form field was not highlighted. This would lead to confusion on whether the user needs to click on the End Date form field in order to proceed
  • [x] instead, selecting the StartDate should then focus the End Date form field, so that it is clear that the user should select an EndDate
Screenshot of focusing EndDate

Image

rayneng avatar Oct 30 '25 03:10 rayneng

@ryanfchase I've got this functionality added, thanks for the review! PR is here: #2060

DrAcula27 avatar Oct 30 '25 17:10 DrAcula27