Skip to content

Commit

Permalink
Merge pull request #127 from gpbl/rtl
Browse files Browse the repository at this point in the history
Improve support for RTL (#125)
  • Loading branch information
gpbl committed Jan 26, 2016
2 parents 430b939 + 2dee981 commit 4a03d26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions examples/src/examples/Localized.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default class Localized extends React.Component {
</select>
</p>
<DayPicker
dir={ locale === "ar" ? "rtl" : "ltr" }
locale={ locale }
localeUtils={ MomentLocaleUtils }
modifiers={{ sunday: day => day.getDay() === 0 }} />
Expand Down
24 changes: 16 additions & 8 deletions src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,25 @@ export default class DayPicker extends Component {

renderNavBar() {
const baseClass = "DayPicker-NavButton DayPicker-NavButton";
const isRTL = this.props.dir === "rtl";

const leftButton = isRTL ? this.allowNextMonth() : this.allowPreviousMonth();
const rightButton = isRTL ? this.allowPreviousMonth() : this.allowNextMonth();
return (
<div className="DayPicker-NavBar">
{ this.allowPreviousMonth() && <span
key="prev"
className={ `${baseClass}--prev` }
onClick={ ::this.handlePrevMonthClick } />
{ leftButton &&
<span
key="left"
className={ `${baseClass}--prev` }
onClick={ isRTL ? ::this.handleNextMonthClick : ::this.handlePrevMonthClick }
/>
}
{ this.allowNextMonth() && <span
key="next"
className={ `${baseClass}--next` }
onClick={ ::this.handleNextMonthClick } />
{ rightButton &&
<span
key="right"
className={ `${baseClass}--next` }
onClick={ isRTL ? ::this.handlePrevMonthClick : ::this.handleNextMonthClick }
/>
}
</div>
);
Expand Down
6 changes: 0 additions & 6 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,3 @@
color: #FFF;
background-color: #4A90E2;
}

/* Locales */

.DayPicker--ar {
direction: rtl;
}

0 comments on commit 4a03d26

Please sign in to comment.