From 4d89f23111adebab6ad4529e8f7625dfec62e470 Mon Sep 17 00:00:00 2001 From: "bemonta@sandia.gov" Date: Tue, 26 Feb 2019 06:43:58 -0700 Subject: [PATCH 1/2] Allow for custom labels --- example/src/App.js | 1 + lib/src/DateRangePicker.js | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/example/src/App.js b/example/src/App.js index 1e435fd..4591e29 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -26,6 +26,7 @@ class App extends Component { toDate={this.state.toDate} onChange={this._handleDateRangeChange} closeDialogOnSelection={false} + label={"Custom Label"} /> ); diff --git a/lib/src/DateRangePicker.js b/lib/src/DateRangePicker.js index cc6583c..9574bdf 100644 --- a/lib/src/DateRangePicker.js +++ b/lib/src/DateRangePicker.js @@ -16,7 +16,7 @@ const Wrapper = styled.div` const itemToString = dateFormat => ({ fromDate, toDate } = {}) => `${fromDate ? `From: ${format(fromDate, dateFormat)}${toDate ? ' ' : ''}` : ''}${ - toDate ? `To: ${format(toDate, dateFormat)}` : '' + toDate ? `To: ${format(toDate, dateFormat)}` : '' }`; function stateReducer(state, changes) { @@ -90,7 +90,7 @@ class DateRangePicker extends PureComponent { clearDateRange = () => this.props.onChange({ fromDate: null, toDate: null }); render() { - const { fromDate, toDate, dateFormat } = this.props; + const { fromDate, toDate, dateFormat, label } = this.props; return ( Date: Tue, 26 Feb 2019 06:51:09 -0700 Subject: [PATCH 2/2] Actually, allow for no label at all --- lib/src/DateRangePicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/DateRangePicker.js b/lib/src/DateRangePicker.js index 9574bdf..b665f8c 100644 --- a/lib/src/DateRangePicker.js +++ b/lib/src/DateRangePicker.js @@ -104,7 +104,7 @@ class DateRangePicker extends PureComponent { id="date-range" label={label ? label : - "Date range"} + ""} InputLabelProps={getLabelProps({ shrink: downshiftProps.isOpen || !!fromDate || !!toDate })}