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

Add verticalSpacing prop #883

Merged
merged 1 commit into from
Dec 5, 2017
Merged

Add verticalSpacing prop #883

merged 1 commit into from
Dec 5, 2017

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Dec 4, 2017

This prop allows for greater customization of the space in between the picker and the inputs. Additionally, if that value is less than the height of the fang then we hide the fang. To accomplish this, I ended up revamping the fang so that it would use an svg instead of pseudo-selectors. The reasoning for this is that because I had to dynamically position the fang relative to the inputs (based on a prop), I had to leverage inline styles to do so. Unfortunately, the ::before and ::after selectors don't allow for that.

I also renamed caret to fang everywhere... which is like ¯\_(ツ)_/¯ but consistency?

This does not, however, solve #538... so maybe expanding the prop to allow for em values as well would be useful. However, this would maybe make the fang show/hide logic a bit more complicated (and have to be manual???). What are your thoughts? Maybe that belongs in a follow-up PR?

to: @airbnb/webinfra @ljharb @noratarano @ethanresnick @gabergg @erin-doyle

lencioni
lencioni previously approved these changes Dec 4, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 86.671% when pulling 09b71d7 on maja-add-vertical-spacing-prop into d0e03d5 on master.

@ljharb ljharb added the semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. label Dec 5, 2017
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.

It might be better to keep the name showCaret, just so as to avoid the breaking change and get this out?

@@ -338,6 +343,10 @@ class DateRangePicker extends React.Component {
<CloseButton {...css(styles.DateRangePicker_closeButton_svg)} />
);

const inputHeight = parseInt(reactDates.font.input.lineHeight, 10)
Copy link
Member

Choose a reason for hiding this comment

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

this logic is duplicated; can it be shared?

} = this.props;
const { dayPickerContainerStyles, isDayPickerFocused, showKeyboardShortcuts } = this.state;

const onOutsideClick = (!withFullScreenPortal && withPortal) ? this.onClearFocus : undefined;
const closeIcon = customCloseIcon || (<CloseButton />);

const inputHeight = parseInt(reactDates.font.input.lineHeight, 10)
Copy link
Member

Choose a reason for hiding this comment

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

this logic is duplicated; can it be shared?

const withCaret = showCaret && focused;
const withFang = showFang && focused;

const inputHeight = parseInt(font.input.lineHeight, 10)
Copy link
Member

Choose a reason for hiding this comment

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

this logic is triplicated, can it be shared?

@@ -196,6 +215,31 @@ class DateInput extends React.Component {
aria-describedby={screenReaderMessage && screenReaderMessageId}
/>

{withFang &&
Copy link
Member

Choose a reason for hiding this comment

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

please surround multiline jsx with parens

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 86.707% when pulling 8a558c9 on maja-add-vertical-spacing-prop into d0e03d5 on master.

@ljharb ljharb added semver-minor: new stuff Any feature or API addition. and removed semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. labels Dec 5, 2017
@majapw majapw merged commit e92deb3 into master Dec 5, 2017
@majapw majapw deleted the maja-add-vertical-spacing-prop branch December 5, 2017 22:28
@kashifshamaz21
Copy link

@majapw I'm trying to use verticalSpacing prop in DateRangePicker.jsx, but for some reason I'm seeing that the prop's value is being received as 0 inside the render function of DateRangePicker.

<DateRangePicker
          displayFormat="DD/MM/YYYY"
          startDate={this.props.startDate} // momentPropTypes.momentObj or null,
          startDateId="startDate" // PropTypes.string.isRequired,
          endDate={this.props.endDate} // momentPropTypes.momentObj or null,
          endDateId="endDate" // PropTypes.string.isRequired,
          onDatesChange={this.props.dateRangeUpdated}
          focusedInput={this.props.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
          onFocusChange={this.props.onFocusChange} // PropTypes.func.isRequired,
          hideKeyboardShortcutsPanel={true}
          isOutsideRange={this.isOutsideRange.bind(this)}
          verticalSpacing={10}
        />

Any pointers on what could be causing this issue? I looked at the code in DateRangePicker.jsx related to verticalSpacing, and i didn't find anything obvious which could lead to above behaviour.

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.

5 participants