-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display index updates to most currently modified date within range array
header click events work correctly now based upon multidate and withRange
- Loading branch information
akaidc2
committed
Nov 17, 2017
1 parent
c104d28
commit 8f02af9
Showing
5 changed files
with
75 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import {withImmutableProps} from '../utils'; | ||
import defaultSelectionRenderer from './defaultSelectionRenderer'; | ||
import styles from './Header.scss'; | ||
import Slider from './Slider'; | ||
|
||
export default withImmutableProps(({renderSelection}) => ({ | ||
renderSelection: (values, props) => { | ||
if (!values.length || !values[0].start && !values[0].end) { | ||
return null; | ||
} | ||
|
||
const dates = values.sort(function (a, b) { | ||
return a.start > b.start; | ||
}); | ||
const index = props.displayIndex; | ||
|
||
const dateFormat = props.locale && props.locale.headerFormat || 'MMM Do'; | ||
|
||
const dateElements = values.map((value, idx) => { | ||
if (value.start === value.end) { | ||
return defaultSelectionRenderer(value.start, {...props, key: value.start+idx}); | ||
} else { | ||
return ( | ||
<div key={value.start+idx} className={styles.range} style={{color: props.theme.headerColor}}> | ||
{defaultSelectionRenderer(value.start, {...props, dateFormat, idx, key: 'start', shouldAnimate: false})} | ||
{defaultSelectionRenderer(value.end, {...props, dateFormat, idx, key: 'end', shouldAnimate: false})} | ||
</div> | ||
); | ||
} | ||
}); | ||
return ( | ||
<Slider | ||
index={index !== -1 ? index : dates.length - 1} | ||
onChange={chIndex => | ||
props.setDisplayIndex(chIndex, () => | ||
setTimeout(() => props.scrollToDate(dates[chIndex].start, 0, true), 50) | ||
) | ||
} | ||
> | ||
{dateElements} | ||
</Slider> | ||
); | ||
}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters