Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 6f8e359

Browse files
committed
tidy up examples
1 parent df9d6a7 commit 6f8e359

File tree

2 files changed

+67
-61
lines changed

2 files changed

+67
-61
lines changed

demo/src/components/Main.js

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export default class Main extends Component {
9393
}
9494

9595
handleChange(which, payload) {
96+
console.log(which, payload);
9697
this.setState({
9798
[which]: payload,
9899
});
@@ -112,60 +113,38 @@ export default class Main extends Component {
112113
<main className={'Main'}>
113114
<h1 className={'Title'}>React-date-range</h1>
114115

115-
<Section title="Date Picker, Internationalization.">
116+
<Section title="Date Range Picker">
116117
<div>
117-
<select
118-
onChange={e => this.setState({ locale: e.target.value })}
119-
value={this.state.locale}>
120-
{localeOptions.map((option, i) => (
121-
<option value={option.value} key={i}>
122-
{option.label}
123-
</option>
124-
))}
125-
</select>
126118
<input
127119
type="text"
128120
readOnly
129-
value={formatDateDisplay(this.state.datePickerInternational)}
121+
value={formatDateDisplay(this.state.dateRangePicker.selection.startDate)}
130122
/>
131-
</div>
132-
<Calendar
133-
locale={rdrLocales[this.state.locale]}
134-
date={this.state.datePickerInternational}
135-
onChange={this.handleChange.bind(this, 'datePickerInternational')}
136-
months={2}
137-
/>
138-
</Section>
139-
140-
<Section title="Range Picker">
141-
<div>
142123
<input
143124
type="text"
144125
readOnly
145-
value={formatDateDisplay(this.state.dateRange.selection.startDate)}
126+
value={formatDateDisplay(this.state.dateRangePicker.selection.endDate)}
146127
/>
147-
<input
148-
type="text"
149-
readOnly
150-
value={formatDateDisplay(this.state.dateRange.selection.endDate, 'Continuous')}
128+
</div>
129+
<div>
130+
<DateRangePicker
131+
onChange={this.handleRangeChange.bind(this, 'dateRangePicker')}
132+
showMonthArrow={false}
133+
showSelectionPreview={true}
134+
moveRangeOnFirstSelection={false}
135+
className={'PreviewArea'}
136+
ranges={[
137+
{
138+
startDate: this.state.dateRangePicker.selection.startDate,
139+
endDate: this.state.dateRangePicker.selection.endDate,
140+
key: 'selection',
141+
},
142+
]}
151143
/>
152144
</div>
153-
154-
<DateRange
155-
onChange={this.handleRangeChange.bind(this, 'dateRange')}
156-
months={2}
157-
moveRangeOnFirstSelection={false}
158-
ranges={[
159-
{
160-
startDate: this.state.dateRange.selection.startDate,
161-
endDate: this.state.dateRange.selection.endDate,
162-
key: 'selection',
163-
},
164-
]}
165-
/>
166145
</Section>
167146

168-
<Section title="Multi Range Picker - Compare">
147+
<Section title="Date Range Picker - Multiple Range">
169148
<div>
170149
<label className={'label'}>Selection Start:</label>
171150
<input
@@ -193,15 +172,13 @@ export default class Main extends Component {
193172
value={formatDateDisplay(this.state.compareRanges.compare.endDate, 'Continuous')}
194173
/>
195174
</div>
196-
197175
<DateRangePicker
198176
onChange={this.handleRangeChange.bind(this, 'compareRanges')}
199177
ranges={[
200178
{
201179
startDate: this.state.compareRanges.selection.startDate,
202180
endDate: this.state.compareRanges.selection.endDate,
203181
key: 'selection',
204-
// autoFocus: false,
205182
},
206183
{
207184
startDate: this.state.compareRanges.compare.startDate,
@@ -210,37 +187,61 @@ export default class Main extends Component {
210187
color: '#3ecf8e',
211188
},
212189
]}
190+
className={'PreviewArea'}
213191
/>
214192
</Section>
215193

216-
<Section title="Range Picker (Predefined Ranges)">
194+
<Section title="Date Picker - Internationalization">
217195
<div>
196+
<select
197+
onChange={e => this.setState({ locale: e.target.value })}
198+
value={this.state.locale}>
199+
{localeOptions.map((option, i) => (
200+
<option value={option.value} key={i}>
201+
{option.label}
202+
</option>
203+
))}
204+
</select>
218205
<input
219206
type="text"
220207
readOnly
221-
value={formatDateDisplay(this.state.dateRangePicker.selection.startDate)}
208+
value={formatDateDisplay(this.state.datePickerInternational)}
222209
/>
210+
</div>
211+
<Calendar
212+
locale={rdrLocales[this.state.locale]}
213+
date={this.state.datePickerInternational}
214+
onChange={this.handleChange.bind(this, 'datePickerInternational')}
215+
className={'PreviewArea'}
216+
/>
217+
</Section>
218+
219+
<Section title="Range Picker">
220+
<div>
223221
<input
224222
type="text"
225223
readOnly
226-
value={formatDateDisplay(this.state.dateRangePicker.selection.endDate)}
224+
value={formatDateDisplay(this.state.dateRange.selection.startDate)}
227225
/>
228-
</div>
229-
<div>
230-
<DateRangePicker
231-
onChange={this.handleRangeChange.bind(this, 'dateRangePicker')}
232-
showMonthArrow={false}
233-
showSelectionPreview={true}
234-
moveRangeOnFirstSelection={true}
235-
ranges={[
236-
{
237-
startDate: this.state.dateRangePicker.selection.startDate,
238-
endDate: this.state.dateRangePicker.selection.endDate,
239-
key: 'selection',
240-
},
241-
]}
226+
<input
227+
type="text"
228+
readOnly
229+
value={formatDateDisplay(this.state.dateRange.selection.endDate, 'Continuous')}
242230
/>
243231
</div>
232+
233+
<DateRange
234+
onChange={this.handleRangeChange.bind(this, 'dateRange')}
235+
moveRangeOnFirstSelection={false}
236+
ranges={[
237+
{
238+
startDate: this.state.dateRange.selection.startDate,
239+
endDate: this.state.dateRange.selection.endDate,
240+
key: 'selection',
241+
},
242+
]}
243+
className={'PreviewArea'}
244+
/>
244245
</Section>
245246
</main>
246247
);

demo/src/styles/main.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818

1919
.Section ~ .Section {
20-
margin-top: 24px;
20+
margin-top: 60px;
2121
}
2222

2323
.Demo-description {
@@ -56,6 +56,7 @@
5656
.Demo-description h2 {
5757
font-weight: 400;
5858
font-size: 1.4rem;
59+
text-align: center;
5960
}
6061

6162
.Demo{
@@ -69,3 +70,7 @@
6970
width: 296px;
7071
margin: 0 auto;
7172
}
73+
74+
.PreviewArea{
75+
box-shadow: 1px 1px 81px rgba(41, 60, 74, 0.18);
76+
}

0 commit comments

Comments
 (0)