File size: 2,064 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
import { Card } from '@automattic/components';
import { Fragment, Component } from 'react';
import DateRange from '../index.js';
/*
* Date Range Demo
*/
class DateRangeExample extends Component {
withCustomTrigger() {
// Note: you must ensure you pass the `ref` prop down to the element
const customTrigger = ( props ) => {
return (
<button ref={ props.buttonRef } onClick={ props.onTriggerClick }>
I am a custom Trigger element
</button>
);
};
return <DateRange renderTrigger={ customTrigger } />;
}
withCustomInputs() {
// Note: you must ensure you pass the `ref` prop down to the element
const customInputs = ( props ) => {
return (
<div>
<p>
You selected { props.startDateValue } - { props.endDateValue }
</p>
</div>
);
};
return <DateRange renderInputs={ customInputs } />;
}
render() {
const now = new Date();
return (
<Fragment>
<h3>Defaults</h3>
<Card>
<DateRange />
</Card>
<h3>Compact</h3>
<Card>
<DateRange isCompact />
</Card>
<h3>Select only past dates</h3>
<Card>
<DateRange lastSelectableDate={ now } />
</Card>
<h3>Select only future dates</h3>
<Card>
<DateRange firstSelectableDate={ now } />
</Card>
<h3>Custom Trigger Component</h3>
<Card>{ this.withCustomTrigger() }</Card>
<h3>Custom Inputs Component</h3>
<Card>{ this.withCustomInputs() }</Card>
<h3>With Shortcuts Menu Displayed</h3>
<Card>
<DateRange displayShortcuts />
</Card>
<h3>With Arrow Navigation Enabled</h3>
<Card>
<DateRange useArrowNavigation />
</Card>
<h3>With Overlay Enabled</h3>
<Card>
<DateRange
useArrowNavigation
displayShortcuts
overlay={ <div>🔒 Please upgrade to use the date range picker.</div> }
/>
</Card>
<h3>With Custom Title</h3>
<Card>
<DateRange customTitle="Custom Title" />
</Card>
</Fragment>
);
}
}
DateRangeExample.displayName = 'DateRange';
export default DateRangeExample;
|