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

[DatePicker] Improve the RTL support #5155

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions src/DatePicker/CalendarToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class CalendarToolbar extends Component {
prevMonth: true,
};

static contextTypes = {
muiTheme: PropTypes.object.isRequired,
};

state = {
transitionDirection: 'up',
};
Expand All @@ -56,11 +52,15 @@ class CalendarToolbar extends Component {
}

handleTouchTapPrevMonth = () => {
if (this.props.onMonthChange && this.props.prevMonth) this.props.onMonthChange(-1);
if (this.props.onMonthChange) {
this.props.onMonthChange(-1);
}
};

handleTouchTapNextMonth = () => {
if (this.props.onMonthChange && this.props.nextMonth) this.props.onMonthChange(1);
if (this.props.onMonthChange) {
this.props.onMonthChange(1);
}
};

render() {
Expand All @@ -71,28 +71,27 @@ class CalendarToolbar extends Component {
year: 'numeric',
}).format(displayDate);

const nextButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronLeft /> : <NavigationChevronRight />;
const prevButtonIcon = this.context.muiTheme.isRtl ? <NavigationChevronRight /> : <NavigationChevronLeft />;

return (
<div style={styles.root}>
<IconButton
disabled={!this.props.prevMonth}
onTouchTap={this.handleTouchTapPrevMonth}
>
{prevButtonIcon}
<NavigationChevronLeft />
</IconButton>
<SlideInTransitionGroup
direction={this.state.transitionDirection}
style={styles.titleDiv}
>
<div key={dateTimeFormatted} style={styles.titleText}>{dateTimeFormatted}</div>
<div key={dateTimeFormatted} style={styles.titleText}>
{dateTimeFormatted}
</div>
</SlideInTransitionGroup>
<IconButton
disabled={!this.props.nextMonth}
onTouchTap={this.handleTouchTapNextMonth}
>
{nextButtonIcon}
<NavigationChevronRight />
</IconButton>
</div>
);
Expand Down