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 active date props to header #544

Merged
merged 7 commits into from
Nov 9, 2021

Conversation

kbwo
Copy link
Contributor

@kbwo kbwo commented Nov 5, 2021

At first, thank you for great library.
I want new feature to display date of blue style except today, so I added active date props to header on this PR.

Copy link
Owner

@acro5piano acro5piano left a comment

Choose a reason for hiding this comment

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

@kbwo Thank you for your pull request!

  1. Can you add this property to the api documentation ?
  2. isActiveDay and activeDate is confusing. Do you mean highlighting a specific date (Date) or a specific day (0..6) ?

@kbwo
Copy link
Contributor Author

kbwo commented Nov 6, 2021

@kbwo Thank you for your pull request!

  1. Can you add this property to the api documentation ?
  2. isActiveDay and activeDate is confusing. Do you mean highlighting a specific date (Date) or a specific day (0..6) ?
  1. OK. I'll commit to update docs.
  2. So sorry. I mean highlighting a specific date (Date). I'll also commit to rename the variable.

@kbwo
Copy link
Contributor Author

kbwo commented Nov 6, 2021

@acro5piano
I fixed it and update documentation.
Please check it.

@kbwo kbwo requested a review from acro5piano November 6, 2021 07:51
Copy link
Owner

@acro5piano acro5piano left a comment

Choose a reason for hiding this comment

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

This should be the last fix! Thanks for your patient

@@ -46,6 +48,7 @@ function _CalendarHeader<T>({
<View style={[u['z-10'], u['w-50'], borderColor]} />
{dateRange.map((date) => {
const _isToday = isToday(date)
const _isActiveDate = activeDate ? isActiveDate(date, activeDate) : _isToday
Copy link
Owner

Choose a reason for hiding this comment

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

There should be performance improvement: ​if activeDate is passed, _isToday will be calculated but not used.

So, the logic should be like this:

const shouldHighlight = activeDate ? date.isSame(activeDate, 'date') : isToday(date)return (

Also, please note that

  • The var name shouldHighlight is more clear
  • I think the function isActiveDate is a bit redundant, writing it inline must be simpler
  • isSame(.., 'date') is more clear than isSame(.., 'day') in this case

Sorry that I couldn't find it at the first time ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your review. I'll fix it!

@kbwo
Copy link
Contributor Author

kbwo commented Nov 8, 2021

@acro5piano fixed according to your review!

@kbwo kbwo requested a review from acro5piano November 8, 2021 14:45
@kbwo kbwo force-pushed the feature/add-active-date-props branch from 800cd46 to 301f97b Compare November 8, 2021 14:46
Comment on lines 49 to 52
{dateRange.map((date) => {
const _isToday = isToday(date)
const shouldHighlight = activeDate ? date.isSame(activeDate, 'date') : _isToday
return (
Copy link
Owner

Choose a reason for hiding this comment

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

To reduce unnecessary function call, please do

Suggested change
{dateRange.map((date) => {
const _isToday = isToday(date)
const shouldHighlight = activeDate ? date.isSame(activeDate, 'date') : _isToday
return (
{dateRange.map((date) => {
const shouldHighlight = activeDate ? date.isSame(activeDate, 'date') : isToday(date)
return (

@kbwo kbwo requested a review from acro5piano November 9, 2021 12:35
@acro5piano
Copy link
Owner

Thank you for your contribution!

@acro5piano acro5piano merged commit 5b2b5af into acro5piano:master Nov 9, 2021
@acro5piano
Copy link
Owner

Released on v2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants