diff --git a/src/assets/sass/_shame.scss b/src/assets/sass/_shame.scss index 9387c11..c47f758 100644 --- a/src/assets/sass/_shame.scss +++ b/src/assets/sass/_shame.scss @@ -5,3 +5,29 @@ // Cleaning up the code in _shame.scss should be done at spare time. Find out whose code it is by // using: $ git blame _shame.scss // ========================================================================== + +div { + &.SingleDatePicker_picker { + z-index: 99; + } + & .DateInput_input { + border: 1px solid getColor('grey.20'); + border-radius: 2px; + padding: getSpacing('2x') getSpacing('3x'); + width: 100%; + font-size: getFontSize('body1'); + background-color: getColor('white.base'); + color: getColor('grey.80'); + font-weight: normal; + line-height: normal; + &::placeholder { + font-size: getFontSize('body1'); + color: getColor('grey.40'); + text-transform: capitalize; + font-weight: normal; + } + &:focus { + border: 1px solid getColor('tertiary-blue.60'); + } + } +} diff --git a/src/components/common/input/input.js b/src/components/common/input/input.js index 7e0c256..fe73955 100644 --- a/src/components/common/input/input.js +++ b/src/components/common/input/input.js @@ -1,6 +1,12 @@ import moment from 'moment'; import classnames from 'classnames'; import React, { Component } from 'react'; +import { SingleDatePicker } from 'react-dates'; + +import 'react-dates/initialize'; +import 'react-dates/lib/css/_datepicker.css'; + +import DropDown from 'components/common/dropDown'; class Input extends Component { constructor(props) { @@ -10,7 +16,6 @@ class Input extends Component { calendarFocused: false, }; } - onDateChange = (name, date) => { if (date && date._d) { const changedDate = new Date(date._d).toISOString(); @@ -22,6 +27,10 @@ class Input extends Component { } }; + onFocusChange = ({ focused }) => { + this.setState(() => ({ calendarFocused: focused })); + }; + render() { const { labelText, required, placeholder, error, disabled, type, id, name } = this.props; @@ -57,6 +66,43 @@ class Input extends Component { ); } + if (type && type === 'dropdown') { + inputView = ( + + this.props.onChange({ target: { name: name, value: selectedOption ? selectedOption.value : null } }) + } + /> + ); + } + + if (type && type === 'date') { + inputView = ( + this.onDateChange(id, date)} + focused={this.state.calendarFocused} + onFocusChange={this.onFocusChange} + numberOfMonths={1} + isOutsideRange={() => false} + displayFormat={'MMM DD, YYYY'} + hideKeyboardShortcutsPanel + block + openDirection={'up'} + withPortal={true} + noBorder={true} + disabled={disabled} + /> + ); + } + return (