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/datepicker #644

Merged
merged 42 commits into from
Apr 12, 2018
Merged

Feature/datepicker #644

merged 42 commits into from
Apr 12, 2018

Conversation

snide
Copy link
Contributor

@snide snide commented Apr 10, 2018

Summary

Adds a Datepicker to EUI based on react-datepicker. The SCSS layer has been heavily modified while still keeping the original selectors (with some minor wrapper additions when needed). It works within our form system / validation controls. It removes some unneeded features from react-datepicker by spitting out warnings if certain props are used.

Status

This is mostly working, but needs some documentation and code cleanup.

  • Date works, time works, date time works
  • Two input date ranges work
  • Inline abilities should work for the way we need them in Caroline's mocks
  • Dark mode works
  • The features listed from the doc examples in the todo below should all be working / styled correctly, they just need docs.
  • The features we don't plan on using from react-datepicker (like withPortal) should properly spit out errors and be excluded from use

TODO

  • Remove uneeded SCSS on features we will not be using.
  • Clean up variables / mixins / raw values in SCSS. It's still pretty messy from the port
  • Build an "inputWrap" version of date ranges
  • Adjust for mobile
  • Figure out why props aren't appearing correctly in docs
  • Make documentation examples for:
    • Usual form row / disabled / validation / loading states
    • locale
    • showTimeSelect
    • showTimeSelectOnly
    • timeFormat
    • dateFormat
    • injectTimes
    • minDate
    • maxDate
    • minTime
    • maxTime
    • openToDate
    • shadow
    • excludeDates
    • various className forcing
  • Props that still need to be mirrored
    • onChangeRaw
    • customInput
    • filterDates
    • utcOffset

image

@snide
Copy link
Contributor Author

snide commented Apr 11, 2018

@nreese @cchaos OK. I think this thing is mostly done and ready for review. I'm gonna push on doing the range wrapper stuff in a different PR since it'll likely require another component, but the ranges as is work good as separated items.

@cchaos feel free to make any visual changes directly to the PR if you want to clean up any styling

The props documentation is busted, need to dig in an figure out what's going on there.

@snide snide changed the title Feature/datepicker - WIP Feature/datepicker Apr 11, 2018
@nreese
Copy link
Contributor

nreese commented Apr 12, 2018

I am unable to cleaning run yarn run build on this branch. Without being able to run a build, I can not try out the datepicker in kibana.

screen shot 2018-04-11 at 6 35 11 pm

@snide
Copy link
Contributor Author

snide commented Apr 12, 2018

@nreese Fixed. Took me longer than I'd care to admit to find the problem. Basically I was trying to replicate a css selector bug in react-datepicker, but the sass compiler (weirdly only in the build step) didn't like it. I made the selector a different way (that is still pretty silly) but works.

I need to submit a fix to them upstream.

@nreese
Copy link
Contributor

nreese commented Apr 12, 2018

is it possible to have the inline date picker still show the input?

@cchaos
Copy link
Contributor

cchaos commented Apr 12, 2018

  1. Maybe on your monitor it's hard to see, but I've blown it up a bit. Take a look at the right arrow. This is the hover state:

screen shot 2018-04-12 at 15 56 08 pm

@snide
Copy link
Contributor Author

snide commented Apr 12, 2018

is it possible to have the inline date picker still show the input?

I think you'd achieve that by passing the datepicker state to a separate EuiText component. There's no way to natively do that with this library.

@snide
Copy link
Contributor Author

snide commented Apr 12, 2018

OK. Styley stuff @cchaos mentioned should all be fixed. Gonna leave the classname stuff for now.

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

looking great

package.json Outdated
@@ -42,6 +42,7 @@
"prop-types": "^15.6.0",
"react-ace": "^5.5.0",
"react-color": "^2.13.8",
"react-datepicker": "v1.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

1.4.1 was released a few days ago. Might as well start out up date.

} from '../error_boundary';

export class EuiDatePicker extends Component {
constructor(props) {
Copy link
Contributor

Choose a reason for hiding this comment

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

constructor can be removed. state.startDate is never used and handleChange is also never used

this.handleChange = this.handleChange.bind(this);
}

handleChange(date) {
Copy link
Contributor

Choose a reason for hiding this comment

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

handleChange can be removed. It is never used

// There is no reason to launch the datepicker in its own modal. Can always build these ourselves
this.props.withPortal
) {
datePickerOrError = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of overriding datePickerOrError, why not just return error components? Maybe move if statement ahead of date picker definition so code reads like this

if (using unused props) {
return (<div>RTFM</div>)
}

return (
  <span className={classes}>
    <EuiFormControlLayout>
      <EuiValidatableControl>
        <DatePicker/>
      </EuiValidatableControl>
    </EuiFormControlLayout>
  </span>
)

@nreese
Copy link
Contributor

nreese commented Apr 12, 2018

@snide I figured out why props is failing in docs. shouldCloseOnSelect is given a default value but is not defined as a prop. Looks like it needs to be added EuiDatePicker.propTypes definition. Same with shadow

@snide
Copy link
Contributor Author

snide commented Apr 12, 2018

@nreese yessss.... feels good man

image

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Whew! I don't see anything in the code that really sticks out. I would consider commenting about the commented out code either as to why we're not using it and/or why we're keeping it in but commented.

The passed icon needs to come from our list of svg icons. Can be flipped {
// eslint-disable-next-line react/no-unescaped-entities
} to the other side by passing <EuiCode>iconSide="right"</EuiCode>.
</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like duplicate description text from the Icon section



// We use SVG URIs for the navigation arrows. There is one for light and dark.
@mixin datePicker__arrow {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this specific to the datepicker or should we make it a general caret + direction mixin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's specific. Normally we have control over the dom and would use an EuiButtonIcon. I'm injecting this into their dom. I don't think we'd ever want to do something like this. I'll make the comment more clear.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I know that we have some svg uri stuff in /global_styling/mixins/_icons.scss so I wasn't sure if we wanted to plop this in there too.

.react-datepicker-popper {
@include euiBottomShadowMedium;

border: 1px solid $euiBorderColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use $euiBorderThin here?

Copy link
Contributor

Choose a reason for hiding this comment

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

And there's other instances throughout that could be changed as well.

background: $euiColorLightestShade;
}

// If the shadow is on, and it is inline, we need to put the shadow on the datepciker
Copy link
Contributor

Choose a reason for hiding this comment

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

datepicker typo

box-shadow:
0 0px 12px -1px rgba($euiShadowColor, .2),
0 0px 4px -1px rgba($euiShadowColor, .2),
0 0px 2px 0 rgba($euiShadowColor, .2) !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make a shadow mixin for this, I can see reuse.

@cchaos
Copy link
Contributor

cchaos commented Apr 12, 2018

Ha... sorry, the left arrow still has the circle in a border issue.

screen shot 2018-04-12 at 19 11 59 pm

@cchaos
Copy link
Contributor

cchaos commented Apr 12, 2018

And I still see the custom class stuff in the docs. But other than that. I think it's good to merge!

Congrats!

@snide snide merged commit 143f89c into elastic:master Apr 12, 2018
@snide snide deleted the feature/datepicker branch April 12, 2018 23:36
@snide
Copy link
Contributor Author

snide commented Apr 12, 2018

Thanks for the review y'all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants