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

export CustomizableCalendarDay styles, add story #1095

Merged
merged 1 commit into from
Mar 29, 2018
Merged

export CustomizableCalendarDay styles, add story #1095

merged 1 commit into from
Mar 29, 2018

Conversation

a15n
Copy link

@a15n a15n commented Mar 28, 2018

Previously if you wanted to update a single CSS style from CustomizableCalendarDay you'd need to (1) make the singular change and (2) duplicate all of the original CSS.

With this change we can import the style definitions and update the single element using es6 spread operator or update.

// before
const newDefaultStyles = {
  color: 'blue', // what we want to change
  // what we need to keep the same
  border: `1px solid ${color.core.borderLight}`,
  background: color.background,
  hover: {
    background: color.core.borderLight,
    border: `1px double ${color.core.borderLight}`,
    color: 'inherit',
  },
}


// after
import CustomizableCalendarDay, { defaultStyles, selectedStyles } from '../src/components/CustomizableCalendarDay';

const newDefaultStyles = {
  ...defaultStyles,
  color: 'blue',
};

modifiers.has('selected-start') && selectedStartStyles,
modifiers.has('selected-end') && selectedEndStyles,
isOutsideRange && blockedOutOfRangeStyles,
getStyles(defaultStylesWithHover, isHovered),
Copy link
Author

Choose a reason for hiding this comment

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

couldn't think of a good intermediate name so I just execute everything inline

Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems reasonable to me

@coveralls
Copy link

coveralls commented Mar 28, 2018

Coverage Status

Coverage decreased (-0.05%) to 86.488% when pulling c28737d on a15n:as--export-CCD-styles into 7a03e4e on airbnb:master.

color: 'blue',
},
},
// or immutability-helper's update
Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure this library needs calling out in an example

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.

I think in your description, you probably meant

const newDefaultStyles = {
  ...defaultStyles,
  color: 'blue',
};

and not the other way around, right? :P

In any case, looks great to me!

modifiers.has('selected-start') && selectedStartStyles,
modifiers.has('selected-end') && selectedEndStyles,
isOutsideRange && blockedOutOfRangeStyles,
getStyles(defaultStylesWithHover, isHovered),
Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems reasonable to me

@a15n
Copy link
Author

a15n commented Mar 29, 2018

Thanks for the review. Ready to merge

@majapw majapw merged commit a56599a into react-dates:master Mar 29, 2018
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

4 participants