-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Datepicker] Redesign datepicker as per material spec #3739
Changes from 1 commit
5eca457
fd8ea3c
aa56a0f
d6c7528
8be285c
d76b8a9
857897d
7ebe267
ff15089
3b13929
4bc7aa2
7797867
b6903fe
e44d5e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import CalendarToolbar from './CalendarToolbar'; | |
import DateDisplay from './DateDisplay'; | ||
import SlideInTransitionGroup from '../internal/SlideIn'; | ||
import ClearFix from '../internal/ClearFix'; | ||
import deprecated from '../utils/deprecatedPropType'; | ||
|
||
import { | ||
addDays, | ||
|
@@ -26,9 +27,7 @@ import { | |
|
||
const daysArray = [...Array(7)]; | ||
|
||
|
||
class Calendar extends React.Component { | ||
|
||
class Calendar extends Component { | ||
static propTypes = { | ||
DateTimeFormat: PropTypes.func.isRequired, | ||
autoOk: PropTypes.bool, | ||
|
@@ -47,7 +46,7 @@ class Calendar extends React.Component { | |
open: PropTypes.bool, | ||
shouldDisableDate: PropTypes.func, | ||
showActionButtons: PropTypes.bool, | ||
wordings: PropTypes.object, | ||
wordings: deprecated(PropTypes.object, 'Instead, use `cancelLabel` and `okLabel`.'), | ||
}; | ||
|
||
static defaultProps = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. |
||
|
@@ -69,7 +68,6 @@ class Calendar extends React.Component { | |
selectedDate: undefined, | ||
transitionDirection: 'left', | ||
transitionEnter: true, | ||
open: true, | ||
}; | ||
|
||
componentWillMount() { | ||
|
@@ -256,22 +254,21 @@ class Calendar extends React.Component { | |
flexDirection: 'column', | ||
}, | ||
calendarContainer: { | ||
alignContent: 'space-between', | ||
display: 'flex', | ||
alignContent: 'space-between', | ||
justifyContent: 'space-between', | ||
flexDirection: 'column', | ||
fontSize: 12, | ||
fontWeight: 400, | ||
height: 'auto', | ||
justifyContent: 'space-between', | ||
padding: '0px 8px 0px 8px', | ||
padding: '0px 8px', | ||
transition: transitions.easeOut(), | ||
width: isLandscape ? 294 : 'auto', | ||
}, | ||
yearContainer: { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
flexDirection: 'column', | ||
height: 272, | ||
justifyContent: 'space-between', | ||
marginTop: 10, | ||
overflow: 'hidden', | ||
width: 310, | ||
|
@@ -285,9 +282,9 @@ class Calendar extends React.Component { | |
weekTitle: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
fontWeight: '500', | ||
height: 20, | ||
justifyContent: 'space-between', | ||
lineHeight: '15px', | ||
opacity: '0.5', | ||
textAlign: 'center', | ||
|
@@ -358,7 +355,7 @@ class Calendar extends React.Component { | |
key={this.state.displayDate.toDateString()} | ||
minDate={this.props.minDate} | ||
maxDate={this.props.maxDate} | ||
onTouchTapDay={this.handleTouchTapDay} | ||
onDayTouchTap={this.handleTouchTapDay} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this changed? These were all consistently onTouchTapXXX... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed this because CalendarMonth had I thought the naming convention was changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mbrookes Fixed. |
||
ref="calendar" | ||
selectedDate={this.state.selectedDate} | ||
shouldDisableDate={this.props.shouldDisableDate} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import React from 'react'; | ||
import React, {Component, PropTypes} from 'react'; | ||
import FlatButton from '../FlatButton'; | ||
import deprecated from '../utils/deprecatedPropType'; | ||
|
||
class CalendarActionButton extends React.Component { | ||
class CalendarActionButton extends Component { | ||
static propTypes = { | ||
cancelLabel: React.PropTypes.node, | ||
okLabel: React.PropTypes.node, | ||
onTouchTapCancel: React.PropTypes.func, | ||
onTouchTapOk: React.PropTypes.func, | ||
wordings: React.PropTypes.object, | ||
cancelLabel: PropTypes.node, | ||
okLabel: PropTypes.node, | ||
onTouchTapCancel: PropTypes.func, | ||
onTouchTapOk: PropTypes.func, | ||
wordings: deprecated(PropTypes.object, 'Instead, use `cancelLabel` and `okLabel`.'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
}; | ||
|
||
render() { | ||
|
@@ -34,15 +35,13 @@ class CalendarActionButton extends React.Component { | |
return ( | ||
<div style={styles.root} > | ||
<FlatButton | ||
key={0} | ||
label={wordings ? wordings.cancel : cancelLabel} | ||
onTouchTap={this.props.onTouchTapCancel} | ||
primary={true} | ||
style={styles.flatButtons} | ||
/> | ||
<FlatButton | ||
disabled={this.refs.calendar !== undefined && this.refs.calendar.isSelectedDateDisabled()} | ||
key={1} | ||
label={wordings ? wordings.ok : okLabel} | ||
onTouchTap={this.props.onTouchTapOk} | ||
primary={true} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
import {isBetweenDates, isEqualDate, getWeekArray} from './dateUtils'; | ||
import DayButton from './DayButton'; | ||
import ClearFix from '../internal/ClearFix'; | ||
|
||
class CalendarMonth extends Component { | ||
static propTypes = { | ||
|
@@ -20,7 +19,7 @@ class CalendarMonth extends Component { | |
} | ||
|
||
handleTouchTapDay = (event, date) => { | ||
if (this.props.onTouchTapDay) this.props.onTouchTapDay(event, date); | ||
if (this.props.onDayTouchTap) this.props.onDayTouchTap(event, date); | ||
}; | ||
|
||
shouldDisableDate(day) { | ||
|
@@ -36,9 +35,9 @@ class CalendarMonth extends Component { | |
|
||
return weekArray.map((week, i) => { | ||
return ( | ||
<ClearFix key={i} style={this.styles.week}> | ||
<div key={i} style={this.styles.week}> | ||
{this.getDayElements(week, i)} | ||
</ClearFix> | ||
</div> | ||
); | ||
}, this); | ||
} | ||
|
@@ -69,22 +68,20 @@ class CalendarMonth extends Component { | |
root: { | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'flex-start', | ||
fontWeight: 400, | ||
height: 228, | ||
justifyContent: 'flex-start', | ||
lineHeight: 2, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need line-height if we're using flexbox? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
position: 'relative', | ||
textAlign: 'center', | ||
MozPaddingStart: 0, | ||
// backgroundColor: 'cyan', | ||
}, | ||
week: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
height: 34, | ||
justifyContent: 'space-around', | ||
height: 34, | ||
marginBottom: 2, | ||
// backgroundColor: 'yellow', | ||
}, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,27 +6,20 @@ import SlideInTransitionGroup from '../internal/SlideIn'; | |
|
||
const styles = { | ||
root: { | ||
position: 'relative', | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
backgroundColor: 'inherit', | ||
height: 48, | ||
}, | ||
title: { | ||
titleDiv: { | ||
fontSize: 14, | ||
fontWeight: '500', | ||
lineHeight: '20px', | ||
position: 'relative', | ||
textAlign: 'center', | ||
paddingTop: 12, | ||
width: '100%', | ||
}, | ||
button: { | ||
padding: 0, | ||
paddingTop: 12, | ||
margin: 0, | ||
titleText: { | ||
height: 'inherit', | ||
textAlign: 'center', | ||
paddingTop: 12, | ||
}, | ||
}; | ||
|
||
|
@@ -78,30 +71,28 @@ class CalendarToolbar extends Component { | |
year: 'numeric', | ||
}).format(displayDate); | ||
|
||
const nextButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronRight /> : <NavigationChevronLeft />; | ||
const prevButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronLeft /> : <NavigationChevronRight />; | ||
const nextButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronLeft /> : <NavigationChevronRight />; | ||
const prevButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronRight /> : <NavigationChevronLeft />; | ||
|
||
return ( | ||
<div style={styles.root}> | ||
<IconButton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
disabled={!this.props.prevMonth} | ||
onTouchTap={this.handleTouchTapPrevMonth} | ||
style={styles.button} | ||
> | ||
{nextButtonIcon} | ||
{prevButtonIcon} | ||
</IconButton> | ||
<SlideInTransitionGroup | ||
direction={this.state.transitionDirection} | ||
style={styles.title} | ||
style={styles.titleDiv} | ||
> | ||
<div key={dateTimeFormatted} style={{paddingTop: 13}}>{dateTimeFormatted}</div> | ||
<div key={dateTimeFormatted} style={styles.titleText}>{dateTimeFormatted}</div> | ||
</SlideInTransitionGroup> | ||
<IconButton | ||
disabled={!this.props.nextMonth} | ||
onTouchTap={this.handleTouchTapNextMonth} | ||
style={styles.button} | ||
> | ||
{prevButtonIcon} | ||
{nextButtonIcon} | ||
</IconButton> | ||
</div> | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ function getStyles(props, context, state) { | |
width: isLandscape ? 125 : 270, | ||
height: isLandscape ? 290 : 'auto', | ||
float: isLandscape ? 'left' : 'none', | ||
fontWeight: 'bolder', | ||
fontWeight: 700, | ||
display: 'inline-block', | ||
backgroundColor: datePicker.selectColor, | ||
borderTopLeftRadius: 2, | ||
|
@@ -121,6 +121,7 @@ class DateDisplay extends Component { | |
DateTimeFormat, | ||
locale, | ||
selectedDate, | ||
style, | ||
...other, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} = this.props; | ||
|
||
|
@@ -135,7 +136,7 @@ class DateDisplay extends Component { | |
}).format(selectedDate); | ||
|
||
return ( | ||
<div {...other} style={prepareStyles(styles.root)}> | ||
<div {...other} style={prepareStyles(styles.root, style)}> | ||
<SlideInTransitionGroup | ||
style={styles.year} | ||
direction={this.state.transitionDirection} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should only need the warning in DatePicker, otherwise the warning will fire multiple times as the value propagates down the component tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.