Skip to content

Commit

Permalink
Use IconButton in Calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Nov 24, 2015
1 parent 404e2e4 commit 2e414e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
25 changes: 6 additions & 19 deletions components/date_picker/Calendar.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import CssTransitionGroup from 'react-addons-css-transition-group';
import { SlideLeft, SlideRight } from '../animations';
import FontIcon from '../font_icon';
import { IconButton } from '../button';
import Ripple from '../ripple';
import CalendarMonth from './CalendarMonth';
import time from '../utils/time';
Expand Down Expand Up @@ -50,19 +50,10 @@ class Calendar extends React.Component {
this.props.onChange(viewDate);
};

incrementViewMonth = () => {
this.refs.rippleRight.start(event);
changeViewMonth = (direction, step) => {
this.setState({
direction: 'right',
viewDate: time.addMonths(this.state.viewDate, 1)
});
};

decrementViewMonth = () => {
this.refs.rippleLeft.start(event);
this.setState({
direction: 'left',
viewDate: time.addMonths(this.state.viewDate, -1)
direction,
viewDate: time.addMonths(this.state.viewDate, step)
});
};

Expand Down Expand Up @@ -92,12 +83,8 @@ class Calendar extends React.Component {
const animation = this.state.direction === 'left' ? SlideLeft : SlideRight;
return (
<div data-react-toolbox='calendar'>
<FontIcon className={style.prev} value='chevron_left' onMouseDown={this.decrementViewMonth}>
<Ripple ref='rippleLeft' className={style.ripple} spread={1.2} centered />
</FontIcon>
<FontIcon className={style.next} value='chevron_right' onMouseDown={this.incrementViewMonth}>
<Ripple ref='rippleRight' className={style.ripple} spread={1.2} centered />
</FontIcon>
<IconButton className={style.prev} icon='chevron_left' onClick={this.changeViewMonth.bind(this, 'left', -1)} />
<IconButton className={style.next} icon='chevron_right' onClick={this.changeViewMonth.bind(this, 'right', 1)} />
<CssTransitionGroup transitionName={animation} transitionEnterTimeout={350} transitionLeaveTimeout={350}>
<CalendarMonth
key={this.state.viewDate.getMonth()}
Expand Down
9 changes: 3 additions & 6 deletions components/date_picker/style.calendar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
position: absolute;
top: 0;
z-index: $z-index-high;
width: $calendar-row-height;
height: $calendar-row-height;
font-size: $calendar-arrows-font-size;
line-height: $calendar-row-height;
color: $calendar-arrows-color;
text-align: center;
cursor: pointer;
opacity: .7;
height: 3.6 * $unit;
}
.prev {
left: 0;
Expand All @@ -30,7 +25,9 @@
}

.title {
display: inline-block;
font-weight: 500;
line-height: 3.6 * $unit;
}

.years {
Expand Down

0 comments on commit 2e414e9

Please sign in to comment.