Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modifiers and expose styling opportunities for certain user states #1608

Merged

Conversation

krissalvador27
Copy link
Contributor

Added a few useful modifiers & classes that expose some neat states that tend to happen when using the Calendar. I needed these to style my Calendar with rounded edges for start and end date (similar to #1527). Also let me know if there are tests I should add :)

Enhancements

Added before-hovered-end class

  • Similar to after-hovered-start providing a visual cue to hover after the selected start date for an end date, this cues users to hover before the selected end date for a start date
    before-hovered-end
  • Exposing the class allows users to style that CalendayDay differently than a hovered-span. Example below has it styled with a border radius
    before-hovered-end

Added after-hovered-start class

Add no-selected-start-before-selected-end

  • This modifier is true when user has selected an end date but no start date
  • Exposing this class allows users to style that CalendarDay when hovering backwards from the selected end date.
  • WITHOUT the modifier and class
    no-selected-start-before-selected-end
  • WITH the modifier and class
    no-selected-start-before-selected-end

Add selected-start-no-selected-end and selected-end-no-selected-start

  • This modifier is true when user has selected a start date/end date but no end date/start date
  • Exposing this class allows users to style CalendarDay where only one date is currently picked
  • WITHOUT the modifier and class I can only style selected start and end via CalendarDay__selected_end and CalendarDay__selected_end which needs to have a border radius when both are selected but should be a circle when waiting to be part of a selected date span
    selected-start-no-selected-end
  • WITH the modifier and class I can style selected start and end based on current user state (has both selected & has one but not the other selected). When both are selected then there is border radius for their respective sides, but when only one is selected show only a circle
    selected-start-no-selected-end

Other

  • Adds isPreviousDay helper

Conclusion

@coveralls
Copy link

coveralls commented Apr 5, 2019

Coverage Status

Coverage increased (+0.006%) to 84.964% when pulling 84946fe on krissalvador27:add-after-hovered-start-class into 2bf76ad on airbnb:master.

@krissalvador27
Copy link
Contributor Author

@ljharb will add tests for the modifiers but just wanted to get your initial thoughts on these modifiers. they're super helpful for our designs and believe they could provide value to others as well :)

@krissalvador27
Copy link
Contributor Author

@ljharb @majapw any initial thoughts on these modifiers? :)

@krissalvador27
Copy link
Contributor Author

Hey @ljharb @majapw. Following up on this and if there's anything I need to add/do to have this considered for merge?

Let me know 😄

@blooies
Copy link

blooies commented Oct 21, 2019

yes this would be very useful!

@ljharb ljharb added the semver-minor: new stuff Any feature or API addition. label Oct 21, 2019
@krissalvador27
Copy link
Contributor Author

Hey @majapw @ljharb! Added tests to increase developer confidence and document the added modifiers functionality. Let me know if there's anything I can do to help push this along. Would love to get this into react-dates so I can style the component in a way that fits Spotify's look and feel as well as allow other devs and designers to customize the datepicker to fit their needs. 😄

@krissalvador27
Copy link
Contributor Author

Hey @majapw @noratarano @nkinser, merged in master and fixed up a few more edge cases + added tests for them. It's quite a beefy PR so happy to jump on a video call to pair review on this if that would be easier! 😁

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks so much @krissalvador27

@majapw majapw merged commit b87beb4 into react-dates:master Nov 3, 2019
@majapw
Copy link
Collaborator

majapw commented Nov 3, 2019

Hi @krissalvador27 Any thought on why this one test may be failing on master? https://travis-ci.org/airbnb/react-dates/jobs/606807210?utm_medium=notification&utm_source=github_status

Don't want to publish until that's settled:

1) DayPickerRangeController #componentWillReceiveProps modifiers no-selected-start-before-selected-end start date has changed, previous start date is [secure]y, start and end date is truthy calls deleteModifier with `no-selected-start-before-selected-end` if day is before selected end date:
      AssertionError: expected 92 to equal 91
      + expected - actual
      -92
      +91
      
      at Context.equal (test/components/DayPickerRangeController_spec.jsx:1632:69)

@ljharb
Copy link
Member

ljharb commented Nov 3, 2019

Perhaps daylight savings time? The PR was merged after, the PR tests last ran before.

@krissalvador27
Copy link
Contributor Author

What an interesting bug 😄. @ljharb that definitely sounds possible, going to look into this now.

@krissalvador27
Copy link
Contributor Author

FYI have a fix for it here #1854 🔨

@PitBeast
Copy link

@ljharb
Copy link
Member

ljharb commented Feb 11, 2020

Please file a new issue for new issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor: new stuff Any feature or API addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants