Skip to content

Commit fa565ed

Browse files
committed
Be able to highlight day
1 parent 2b8fe07 commit fa565ed

6 files changed

Lines changed: 26 additions & 0 deletions

File tree

css/CalendarMonth.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
}
5252
}
5353

54+
.CalendarMonth__day--highlighted-calendar {
55+
background: $react-dates-color-highlighted;
56+
color: $react-dates-color-gray;
57+
cursor: default;
58+
59+
&:active {
60+
background: $react-dates-color-secondary;
61+
}
62+
}
63+
5464
.CalendarMonth__day--outside {
5565
border: 0;
5666
cursor: default;

css/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ $react-dates-color-gray: #565a5c !default;
1616
$react-dates-color-gray-dark: darken($react-dates-color-gray, 10.5%) !default;
1717
$react-dates-color-gray-light: lighten($react-dates-color-gray, 17.8%) !default; // #82888a
1818
$react-dates-color-gray-lighter: lighten($react-dates-color-gray, 45%) !default; // #cacccd
19+
$react-dates-color-highlighted: #ffe8bc !default;
1920

2021
$react-dates-color-border: #dbdbdb !default;
2122
$react-dates-color-border-light: #dce0e0 !default;

src/components/DateRangePicker.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const defaultProps = {
3333
focusedInput: null,
3434
minimumNights: 1,
3535
isDayBlocked: () => false,
36+
isDayHighlighted: () => false,
3637
isOutsideRange: day => !isInclusivelyAfterDay(day, moment()),
3738
enableOutsideDays: false,
3839
numberOfMonths: 2,
@@ -162,6 +163,7 @@ export default class DateRangePicker extends React.Component {
162163
renderDayPicker() {
163164
const {
164165
isDayBlocked,
166+
isDayHighlighted,
165167
isOutsideRange,
166168
numberOfMonths,
167169
orientation,
@@ -217,6 +219,7 @@ export default class DateRangePicker extends React.Component {
217219
navNext={navNext}
218220
minimumNights={minimumNights}
219221
isOutsideRange={isOutsideRange}
222+
isDayHighlighted={isDayHighlighted}
220223
isDayBlocked={isDayBlocked}
221224
keepOpenOnDateSelect={keepOpenOnDateSelect}
222225
/>

src/components/DayPickerRangeController.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const propTypes = {
3232
minimumNights: PropTypes.number,
3333
isOutsideRange: PropTypes.func,
3434
isDayBlocked: PropTypes.func,
35+
isDayHighlighted: PropTypes.func,
3536

3637
// DayPicker props
3738
enableOutsideDays: PropTypes.bool,
@@ -70,6 +71,7 @@ const defaultProps = {
7071
minimumNights: 1,
7172
isOutsideRange() {},
7273
isDayBlocked() {},
74+
isDayHighlighted() {},
7375

7476
// DayPicker props
7577
enableOutsideDays: false,
@@ -226,6 +228,7 @@ export default class DayPickerRangeController extends React.Component {
226228
render() {
227229
const {
228230
isDayBlocked,
231+
isDayHighlighted,
229232
isOutsideRange,
230233
numberOfMonths,
231234
orientation,
@@ -246,6 +249,7 @@ export default class DayPickerRangeController extends React.Component {
246249
'blocked-calendar': day => isDayBlocked(day),
247250
'blocked-out-of-range': day => isOutsideRange(day),
248251
'blocked-minimum-nights': day => this.doesNotMeetMinimumNights(day),
252+
'highlighted-calendar': day => isDayHighlighted(day),
249253
valid: day => !this.isBlocked(day),
250254
// before anything has been set or after both are set
251255
hovered: day => this.isHovered(day),

src/components/SingleDatePicker.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const defaultProps = {
4343
onFocusChange() {},
4444

4545
isDayBlocked: () => false,
46+
isDayHighlighted: () => false,
4647
disabledDays: [],
4748
isOutsideRange: day => !isInclusivelyAfterDay(day, moment()),
4849
enableOutsideDays: false,
@@ -237,6 +238,7 @@ export default class SingleDatePicker extends React.Component {
237238
renderDayPicker() {
238239
const {
239240
isDayBlocked,
241+
isDayHighlighted,
240242
isOutsideRange,
241243
enableOutsideDays,
242244
numberOfMonths,
@@ -257,6 +259,7 @@ export default class SingleDatePicker extends React.Component {
257259
blocked: day => this.isBlocked(day),
258260
'blocked-calendar': day => isDayBlocked(day),
259261
'blocked-out-of-range': day => isOutsideRange(day),
262+
'highlighted-calendar': day => isDayHighlighted(day),
260263
valid: day => !this.isBlocked(day),
261264
hovered: day => this.isHovered(day),
262265
selected: day => this.isSelected(day),

stories/DateRangePicker.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ storiesOf('DateRangePicker', module)
218218
isDayBlocked={day1 => datesList.some(day2 => isSameDay(day1, day2))}
219219
/>
220220
))
221+
.addWithInfo('with some highlighted dates', () => (
222+
<DateRangePickerWrapper
223+
isDayHighlighted={day1 => datesList.some(day2 => isSameDay(day1, day2))}
224+
/>
225+
))
221226
.addWithInfo('with month specified on open', () => (
222227
<DateRangePickerWrapper
223228
initialVisibleMonth={() => moment('04 2017', 'MM YYYY')}

0 commit comments

Comments
 (0)