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

Feature / RTL Support #454

Merged
merged 2 commits into from
May 2, 2017
Merged

Feature / RTL Support #454

merged 2 commits into from
May 2, 2017

Conversation

sag1v
Copy link
Contributor

@sag1v sag1v commented Apr 18, 2017

I've added support for RTL languages.
The consumer should supply a prop isRTL : bool.
I've also added example stories to see it in action (on both horizontal and vertical mode ).
I haven't created tests for it yet as i'm not that familiar with those kind of tests, it will be nice to get help with those tests if you think is needed.

@ljharb ljharb mentioned this pull request Apr 18, 2017
@@ -56,6 +56,12 @@
}
}

.DayPicker__week-header--rtl {
ul{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space before {

@@ -42,10 +42,20 @@
left: 22px;
}

.DayPickerNavigation__prev--rtl{ // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before {

.DayPickerNavigation__next {
right: 22px;
}

.DayPickerNavigation__next--rtl{ // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before {

@@ -42,10 +42,20 @@
left: 22px;
}

.DayPickerNavigation__prev--rtl{ // sag1v rtl
left: auto;
right:22px
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after :; missing a semicolon

.DayPickerNavigation__next {
right: 22px;
}

.DayPickerNavigation__next--rtl{ // sag1v rtl
right: auto;
left:22px
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space after :; missing a semicolon

@@ -195,14 +196,17 @@ export default class DateRangePicker extends React.Component {
withPortal,
withFullScreenPortal,
anchorDirection,
isRTL // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a trailing comma

@@ -86,6 +86,7 @@ const defaultProps = {
displayFormat: () => moment.localeData().longDateFormat('L'),
monthFormat: 'MMMM YYYY',
phrases: DateRangePickerPhrases,
isRTL:false, // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space after :

const dayPickerClassName = cx('DateRangePicker__picker', {
'DateRangePicker__picker--direction-left': anchorDirection === ANCHOR_LEFT,
'DateRangePicker__picker--direction-right': anchorDirection === ANCHOR_RIGHT,
'DateRangePicker__picker--horizontal': orientation === HORIZONTAL_ORIENTATION,
'DateRangePicker__picker--vertical': orientation === VERTICAL_ORIENTATION,
'DateRangePicker__picker--portal': withPortal || withFullScreenPortal,
'DateRangePicker__picker--full-screen-portal': withFullScreenPortal,
'DateRangePicker__picker--rtl' : isRTL, // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not have a space before :

@@ -621,7 +631,7 @@ export default class DayPicker extends React.Component {

return (
<div
className="DayPicker__week-header"
className={cx("DayPicker__week-header", { "DayPicker__week-header--rtl": isRTL })} // sag1v rtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these double quotes need to be single quotes when in a JS context (previously it was in a jsx context, which requires double)

return ( // sag1v rtl
<div className={navClassNames}>
{!isVerticalScrollable && !isRTL ? prevButton() : nextButton()}
{!isRTL ? nextButton() : prevButton()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of making these functions that are only executed conditionally, let's use the typical jsx pattern if isRTL && nextButtonElements etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but they render in different order

@ljharb
Copy link
Member

ljharb commented Apr 18, 2017

I'm not sure why tests aren't running, but if you rebase latest master and force push i expect them to run.

@ljharb ljharb added the semver-minor: new stuff Any feature or API addition. label Apr 18, 2017
@sag1v
Copy link
Contributor Author

sag1v commented Apr 18, 2017

I'm not sure why tests aren't running, but if you rebase latest master and force push i expect them to run.

@ljharb
I've tried pull (rebase) (i'm working with vs code) and it undo all my latest changes so i had to do a git reset --hard ORIG_HEAD to get it back. as i said, it's my first time using git-hub so I'll need some guidance with this one. :)

@ljharb
Copy link
Member

ljharb commented Apr 18, 2017

@sag1v assuming origin is the remote for your fork, and source is the remove for react-dates, you'd do git checkout feature/RTL-support && git fetch source && git rebase source/master and when that was completed and conflicts resolved, git push origin -f

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb
when i run it i'm getting this:

Your branch is up-to-date with 'origin/feature/RTL-support'.
Already on 'feature/RTL-support'
fatal: 'source' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

obviously source is not the correct name. is there a way to know what is the correct name?
i've tried git remote show origin and got this:

* remote origin
  Fetch URL: https://github.com/sag1v/react-dates.git
  Push  URL: https://github.com/sag1v/react-dates.git
  HEAD branch: master
  Remote branches:
    feature/RTL-support            tracked
    gh-pages                       tracked
    implement-with-styles          tracked
    maja-a11y-work                 tracked
    maja-add-calendarday-size-prop tracked
    maja-fix-tweaks-to-a11y-pr     tracked
    master                         tracked
  Local branches configured for 'git pull':
    feature/RTL-support merges with remote feature/RTL-support
    master              merges with remote master
  Local refs configured for 'git push':
    feature/RTL-support pushes to feature/RTL-support (up to date)
    master              pushes to master              (up to date)

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

@sag1v you need to add one - i think the command is git remote add source https://github.com/airbnb/react-dates.git?

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb ok, after adding the source and running the command again i get this:

Your branch is up-to-date with 'origin/feature/RTL-support'.
Already on 'feature/RTL-support'
From https://github.com/airbnb/react-dates
 * [new branch]      gh-pages              -> source/gh-pages
 * [new branch]      implement-with-styles -> source/implement-with-styles
 * [new branch]      maja-a11y-work        -> source/maja-a11y-work
 * [new branch]      maja-add-calendarday-size-prop -> source/maja-add-calendarday-size-prop
 * [new branch]      maja-prototype-perf-idea -> source/maja-prototype-perf-idea
 * [new branch]      master                -> source/master
First, rewinding head to replay your work on top of it...
Applying: rtl support
.git/rebase-apply/patch:9: trailing whitespace.
.DateRangePicker__picker--rtl{
.git/rebase-apply/patch:167: trailing whitespace.

warning: 2 lines add whitespace errors.
error: failed to open 'src/components/DateRangePicker.jsx': Permission denied
Using index info to reconstruct a base tree...
M       examples/DateRangePickerWrapper.jsx
M       examples/DayPickerRangeControllerWrapper.jsx
M       examples/SingleDatePickerWrapper.jsx
M       src/components/DateRangePicker.jsx
M       src/components/DateRangePickerInput.jsx
M       src/components/DateRangePickerInputController.jsx
M       src/components/DayPicker.jsx
M       src/components/DayPickerNavigation.jsx
M       src/components/DayPickerRangeController.jsx
M       src/shapes/DateRangePickerShape.js
Falling back to patching base and 3-way merge...
Auto-merging src/shapes/DateRangePickerShape.js
Auto-merging src/components/DayPickerRangeController.jsx
CONFLICT (content): Merge conflict in src/components/DayPickerRangeController.jsx
Auto-merging src/components/DayPickerNavigation.jsx
Auto-merging src/components/DayPicker.jsx
Auto-merging src/components/DateRangePickerInputController.jsx
Auto-merging src/components/DateRangePickerInput.jsx
Auto-merging src/components/DateRangePicker.jsx
CONFLICT (content): Merge conflict in src/components/DateRangePicker.jsx
Patch failed at 0001 rtl support
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

error: Failed to merge in the changes.

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

I'm not sure about the "permission denied", but that means there's conflicts, and you'll need to manually resolve them.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb i think i resolved them but it still showing that there are conflicts here

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb does it look ok now?

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

There's still a merge commit on the end; you'll want to avoid clicking "update branch" on the github UI because it means you need another rebase.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb seems that i cant merge nore push because i need to merge. Im on a loop lol 😂

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

You need to fetch from source, rebase locally onto source/master, and then force push. No merging or your local master involved.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb can you please provide a set of commands to do what you suggested?

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

#454 (comment) has them.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb tried it and getting this (i dont know why the difference all of a sudden):

Your branch and 'origin/feature/RTL-support' have diverged,
and have 13 and 19 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
Already on 'feature/RTL-support'
Current branch feature/RTL-support is up to date.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

@ljharb i think i managed to resolve all conflicts. now when i run the commands you mentioned i get this:

Your branch is up-to-date with 'origin/feature/RTL-support'.
Already on 'feature/RTL-support'
Current branch feature/RTL-support is up to date.

and i executed this as well:
git merge origin/master

@sag1v
Copy link
Contributor Author

sag1v commented Apr 19, 2017

hmm tests failing again

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.004%) to 83.957% when pulling 38c7672 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.4%) to 83.581% when pulling 5931c00 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@ljharb
Copy link
Member

ljharb commented Apr 19, 2017

@sag1v the idea is that you never ever ever run git merge, ever - that's the mistake.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better! A few more comments, plus it'll need extensive tests.

@@ -37,6 +37,7 @@ const MONTH_PADDING = 23;
const DAY_PICKER_PADDING = 9;
const PREV_TRANSITION = 'prev';
const NEXT_TRANSITION = 'next';
const RTL_TRANSLATION_VALUE = -295;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this number come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i was sure i changed that magic number. anyway it should get the negative size of getCalendarMonthWidth().

@@ -80,7 +84,7 @@ export const defaultProps = {
numberOfMonths: 2,
orientation: HORIZONTAL_ORIENTATION,
withPortal: false,
onOutsideClick() {},
onOutsideClick() { },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert the addition of a space inside the body of these empty methods, throughout the file

{navPrevIcon}
</button>
)}
const prevButton = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i still don't think these should be functions; they should be conditionally rendered inline instead.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an excessive amount of extra whitespace added in this diff; i've tried to comment on all of them, but please in general ensure that there is never more than one blank line in a row, and that blank lines aren't added arbitrarily.

@@ -22,6 +22,10 @@ const propTypes = {
'focused',
'onFocusChange',
]),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldn't be two empty lines next to each other; let's collapse this to one

@@ -77,6 +80,10 @@ const defaultProps = {
displayFormat: () => moment.localeData().longDateFormat('L'),
monthFormat: 'MMMM YYYY',
phrases: DateRangePickerPhrases,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldn't be two empty lines next to each other; let's collapse this to one


isRTL: false,


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldn't be any empty lines inside curly braces; please remove these two

@@ -65,6 +69,10 @@ const defaultProps = {
displayFormat: () => moment.localeData().longDateFormat('L'),
monthFormat: 'MMMM YYYY',
phrases: SingleDatePickerPhrases,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line should be removed; properties in object literals aren't padded by blank lines.

@@ -88,6 +88,9 @@ const defaultProps = {
displayFormat: () => moment.localeData().longDateFormat('L'),
monthFormat: 'MMMM YYYY',
phrases: DateRangePickerPhrases,

isRTL: false,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

@@ -25,6 +25,9 @@ const propTypes = {
'focusedInput',
'onFocusChange',
]),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line



isRTL: false,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line



isRTL: PropTypes.bool,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

@@ -77,6 +81,9 @@ const defaultProps = {

// internationalization
monthFormat: 'MMMM YYYY',

isRTL: false,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line



isRTL: PropTypes.bool,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line

const convertedTranslationValueRTL = (this.dayPickerWidth + this.state.translationValueRTL);
let translationValue = this.props.isRTL ? convertedTranslationValueRTL : -this.dayPickerWidth;

if(this.isVertical()){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always a space after if, always a space between ) and {.

let translationValue = this.props.isRTL ? convertedTranslationValueRTL : -this.dayPickerWidth;

if(this.isVertical()){
translationValue = this.getMonthHeightByIndex(1) * -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a semicolon

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.6%) to 83.333% when pulling 1293a92 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.6%) to 83.333% when pulling 83e7e85 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.6%) to 83.333% when pulling 4a15100 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@coveralls
Copy link

coveralls commented Apr 19, 2017

Coverage Status

Coverage decreased (-0.6%) to 83.333% when pulling 4a15100 on sag1v:feature/RTL-support into 3815516 on airbnb:master.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 24, 2017

@majapw Hi, any idea when will it be merged to the master? we want to do an npm update on react-dates in our project instead of using my version :)

@majapw
Copy link
Collaborator

majapw commented Apr 27, 2017

Taking a look at this today! :) Hope to get it merged asap.

@sag1v
Copy link
Contributor Author

sag1v commented Apr 27, 2017

Awesome news, Yippee ki-yay! :)

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a handful of changes I'd like to see before this is ready, but overall looking good.

if (e) e.preventDefault();

if (this.props.onPrevMonthClick) {
this.props.onPrevMonthClick(e);
}

const translationValue =
this.isVertical() ? this.getMonthHeightByIndex(0) : this.dayPickerWidth;
let translationValue = this.isVertical() ? this.getMonthHeightByIndex(0) : this.dayPickerWidth;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this and the conditional in onNextMonthClick match? I don't really care what pattern you use, but it'd be nice if they were the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the extra const in the onNextMonthClick?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More that this function does:

let translationValue = this.isVertical() ? this.getMonthHeightByIndex(0) : this.dayPickerWidth;
if (isRTL && this.isHorizontal()) {
  translationValue = translationValueRTL - this.dayPickerWidth;
}

and onNextMonthClick does

const convertedTranslationValueRTL = this.dayPickerWidth + this.state.translationValueRTL;
let translationValue = this.props.isRTL ? convertedTranslationValueRTL : -this.dayPickerWidth;

if (this.isVertical()) {
  translationValue = -this.getMonthHeightByIndex(1);
}

These two sets of ternaries/conditionals do pretty much the exact same thing, but look totally different. They should look the same. You could accomplish this by changing onNextMonthClick to have:

let translationValue = this.isVertical() ? -this.getMonthHeightByIndex(1) : -this.dayPickerWidth;
if (isRTL && this.isHorizontal()) {
  translationValue =  this.dayPickerWidth + this.state.translationValueRTL;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah remember i had to change it because of the "maximum line length of 100" lint rule. it exceeds it by 2 chars.
The difference between this and the other block from onPrevMonthClick is the - chars on this line:
let translationValue = this.isVertical() ? -this.getMonthHeightByIndex(1) : -this.dayPickerWidth;
should i disable this rule for this line only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know what forget the rule disabling. i'll just add a new line (i've seen you guys doing it before i think, so i guess that's legit by you)

@@ -17,6 +17,7 @@ const propTypes = {
autoFocusEndDate: PropTypes.bool,
initialStartDate: momentPropTypes.momentObj,
initialEndDate: momentPropTypes.momentObj,
isRTL: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to go here since it probably should be added to DateRangePickerShape

@@ -15,6 +15,7 @@ const propTypes = {
// example props for the demo
autoFocus: PropTypes.bool,
initialDate: momentPropTypes.momentObj,
isRTL: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. This should be a part of SingleDatePickerShape so you don't need to add it explicitly to the wrapper proptypes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you removed the defaultProp instead of the propType declaration in this file by accident!

@@ -43,6 +43,8 @@ const propTypes = forbidExtraProps({
// i18n
monthFormat: PropTypes.string,
phrases: PropTypes.shape(getPhrasePropTypes(CalendarDayPhrases)),

isRTL: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This never gets used?

@@ -516,7 +535,7 @@ export default class DayPicker extends React.Component {
this.setState({
currentMonth: newMonth,
monthTransition: null,
translationValue: 0,
translationValue: (this.props.isRTL && this.isHorizontal()) ? translationValueRTL : 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that this should be non-zero here even if it is RTL since this is after the transition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when it's 0 on RTL the transition to the right is super fast and the transition to the left is cluttering a bit (not smooth)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ... surprising. Let me look into that.

@@ -66,4 +66,6 @@ export default {
displayFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
monthFormat: PropTypes.string,
phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerPhrases)),

isRTL: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add this prop to SingleDatePickerShape as well.

@@ -30,6 +30,11 @@ describe('DateRangePicker', () => {
expect(wrapper.find('.DateRangePicker__picker')).to.have.length(1);
});

it('renders .DateRangePicker__picker--rtl class', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for SingleDatePicker as well?

@sag1v
Copy link
Contributor Author

sag1v commented May 1, 2017

@majapw what about adding the isRTL flag to the documentation readme?

@majapw
Copy link
Collaborator

majapw commented May 1, 2017

We probably want that as well! (adding it to the README I mean)

@sag1v
Copy link
Contributor Author

sag1v commented May 1, 2017

We probably want that as well! (adding it to the README I mean)

@majapw on what section? i was thinking maybe under this section
// calendar presentation and interaction related props

@sag1v
Copy link
Contributor Author

sag1v commented May 1, 2017

@majapw i think i'm done

@ljharb
Copy link
Member

ljharb commented May 1, 2017

@sag1v it'll need another rebase whenever you can too :-)

@sag1v
Copy link
Contributor Author

sag1v commented May 2, 2017

@ljharb @majapw i did, should be fine now (no conflicts)

@coveralls
Copy link

coveralls commented May 2, 2017

Coverage Status

Coverage decreased (-0.4%) to 83.527% when pulling 747fc4e on sag1v:feature/RTL-support into 767bebc on airbnb:master.

@@ -12,6 +12,10 @@
top: $react-dates-spacing-vertical-picker;
}

.SingleDatePicker__picker--rtl{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after the class name

@@ -4,7 +4,9 @@
background-color: $react-dates-color-white;
border: 1px solid $react-dates-color-border;
}

.SingleDatePickerInput--rtl{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after the class name


.SingleDatePickerInput--rtl{
direction: rtl;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line between the class declarations?

@@ -15,6 +15,7 @@ const propTypes = {
// example props for the demo
autoFocus: PropTypes.bool,
initialDate: momentPropTypes.momentObj,
isRTL: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you removed the defaultProp instead of the propType declaration in this file by accident!

@@ -63,6 +64,7 @@ const defaultProps = {
// i18n
monthFormat: 'MMMM YYYY', // english locale
phrases: CalendarDayPhrases,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary line additions. We can probs checkout the master CalendarMonth version to avoid this

@@ -46,6 +46,7 @@ const propTypes = forbidExtraProps({
// i18n
monthFormat: PropTypes.string,
phrases: PropTypes.shape(getPhrasePropTypes(CalendarDayPhrases)),

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Let's check out master's CalendarMonthGrid to avoid this diff

@@ -516,7 +535,7 @@ export default class DayPicker extends React.Component {
this.setState({
currentMonth: newMonth,
monthTransition: null,
translationValue: 0,
translationValue: (this.props.isRTL && this.isHorizontal()) ? translationValueRTL : 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ... surprising. Let me look into that.

@majapw
Copy link
Collaborator

majapw commented May 2, 2017

Hi @sag1v, this is looking close to ready to go! I'm going to check out the branch and play around with it a bit. Can you squash down your commits into 1?

@sag1v
Copy link
Contributor Author

sag1v commented May 2, 2017

@majapw sure, how do i do that?

@majapw
Copy link
Collaborator

majapw commented May 2, 2017

I've helped to address some of my comments! This is pretty much ready to go right now so maybe @ljharb can take a look?

I was also thinking that part of the reason we have to do some weird calculations in the DayPicker (instead of just negative the current translationValues) is that we're still orienting the CalendarMonthGrid along the left instead of the right. If we fix that, the logic in the DayPicker might be a bit cleaner. I'm going to explore that option and see if it's possible... but in general, I plan to get this PR and #449 merged in today (I want to get it in ahead of #450 (comment) since that's a breaking change).

@coveralls
Copy link

coveralls commented May 2, 2017

Coverage Status

Coverage decreased (-0.5%) to 83.492% when pulling 528f74b on sag1v:feature/RTL-support into 767bebc on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented May 2, 2017

Oh also @sag1v, sorry I just aggressively squashed for you... but in the future you can do:
git rebase -i parent_commit_sha and squash everything but the first commit. In my case, I ended up running git rebase -i HEAD~40 because you had 40 commits. :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 83.492% when pulling 528f74b on sag1v:feature/RTL-support into 767bebc on airbnb:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 83.492% when pulling 528f74b on sag1v:feature/RTL-support into 767bebc on airbnb:master.

this.hasSetInitialVisibleMonth = !props.hidden;
this.state = {
currentMonth,
monthTransition: null,
translationValue: 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@@ -60,6 +60,7 @@ const defaultProps = {
renderCalendarInfo: null,
hideKeyboardShortcutsPanel: false,
daySize: DAY_SIZE,
isRTL: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's the propType for this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in SingleDatePickerShape

@@ -52,6 +53,8 @@ const propTypes = forbidExtraProps({

// i18n
phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerInputPhrases)),

isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Wait why wouldn't it?

@@ -58,6 +58,8 @@ const propTypes = forbidExtraProps({

// i18n
phrases: PropTypes.shape(getPhrasePropTypes(DateRangePickerInputPhrases)),

isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Input needs the isRTL prop to select the correct direction of decorative arrow.

@@ -50,6 +50,7 @@ const propTypes = forbidExtraProps({
renderCalendarInfo: PropTypes.func,
hideKeyboardShortcutsPanel: PropTypes.bool,
daySize: nonNegativeInteger,
isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

@@ -27,6 +27,8 @@ const propTypes = forbidExtraProps({

// internationalization
phrases: PropTypes.shape(getPhrasePropTypes(DayPickerNavigationPhrases)),

isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

@@ -66,6 +66,8 @@ const propTypes = forbidExtraProps({
// i18n
monthFormat: PropTypes.string,
phrases: PropTypes.shape(getPhrasePropTypes(DayPickerPhrases)),

isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

@@ -22,7 +22,7 @@ const propTypes = forbidExtraProps({
showCaret: PropTypes.bool,
showClearDate: PropTypes.bool,
customCloseIcon: PropTypes.node,

isRTL: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this still belong here?

@majapw majapw merged commit 61acbcf into react-dates:master May 2, 2017
@sag1v
Copy link
Contributor Author

sag1v commented May 2, 2017

Hey i got a happy e-mail about merging and stuff. :)
@ljharb @majapw this was fun and thanks for your help!
when can i update react-dates from npm and get the new features?

@majapw
Copy link
Collaborator

majapw commented May 2, 2017

Thanks for your contribution @sag1v! :D Always great to work with other folks to make the library better. :) I'm doing a release of v10.2.0 right now, so it should be available in about 15 minutes :D

@majapw
Copy link
Collaborator

majapw commented May 2, 2017

All set! v10.2.0 has been released! :)

@sag1v
Copy link
Contributor Author

sag1v commented May 3, 2017

@ljharb @majapw As this is my first branch (and PR) on GitHub i hope you don't mind that i will keep it as a souvenir and wont delete it. lol

@ljharb
Copy link
Member

ljharb commented May 3, 2017

the branch is in your fork, not this repo, so go nuts! :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor: new stuff Any feature or API addition.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants