File size: 2,442 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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# Calendar Button
This component is used to display a calendar button. When it pressed, it shows a Popover with a calendar inside.
## Usage
```jsx
import CalendarButton from 'calypso/blocks/calendar-button';
function render() {
return <CalendarButton />;
}
```
## Props
### `children`
<table>
<tr><td>Type</td><td>Element</td></tr>
<tr><td>Required</td><td>No</td></tr>
</table>
### `icon`
<table>
<tr><td>Type</td><td>String</td></tr>
<tr><td>Required</td><td>No</td></tr>
<tr><td>Default</td><td>calendar</td></tr>
</table>
If the component doesn't have children elements then an icon (Gridicon) will be rendered inside of this one.
### `popoverPosition`
<table>
<tr><td>Type</td><td>String</td></tr>
<tr><td>Required</td><td>No</td></tr>
<tr><td>Default</td><td>bottom</td></tr>
</table>
It defines the position of the Popover once it shows. This value is propagated to the `<Popover />` instance through of the `position` property.
### `type`
<table>
<tr><td>Type</td><td>String</td></tr>
<tr><td>Required</td><td>Yes</td></tr>
<tr><td>Default</td><td>button</td></tr>
</table>
This property defines to this component as a `button`. You shouldn't change this it.
### Props propagated to the `<Popover />`
- `autoPosition`
- `closeOnEsc`
- `events`
- `ignoreContext`
- `isVisible`
- `selectedDay`
- `showDelay`
- `siteId`
- `onClose`
- `onDateChange`
- `onMonthChange`
- `onShow`
### Props propagated to the `<CalendarPopover />`
- `selectedDay`: the date which will be shown initially
- `siteId`: Passing siteId the calendar will try to get values related with time zone.
- `onDateChange`: Function to be executed when the user selects a date.
## Examples
### As much simple as possible
```jsx
import CalendarButton from 'calypso/blocks/calendar-button';
function render() {
const tomorrow = new Date( new Date().getTime() + 24 * 60 * 60 * 1000 );
return <CalendarButton selectedDay={ tomorrow } onDateChange={ this.setDate } />;
}
```
### Custom calendar icon
```jsx
import CalendarButton from 'calypso/blocks/calendar-button';
function render() {
return <CalendarButton icon="thumbs-up" />;
}
```
### Render using children property
```jsx
import CalendarButton from 'calypso/blocks/calendar-button';
function render() {
return (
<CalendarButton onDateChange={ this.setDate }>
<a class="custom-content" href="https://wordpress.com">
Open Me!
</a>
</CalendarButton>
);
}
```
|