Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified

Calendar Button

This component is used to display a calendar button. When it pressed, it shows a Popover with a calendar inside.

Usage

import CalendarButton from 'calypso/blocks/calendar-button';

function render() {
    return <CalendarButton />;
}

Props

children

TypeElement
RequiredNo

icon

TypeString
RequiredNo
Defaultcalendar

If the component doesn't have children elements then an icon (Gridicon) will be rendered inside of this one.

popoverPosition

TypeString
RequiredNo
Defaultbottom

It defines the position of the Popover once it shows. This value is propagated to the <Popover /> instance through of the position property.

type

TypeString
RequiredYes
Defaultbutton

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

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

import CalendarButton from 'calypso/blocks/calendar-button';

function render() {
    return <CalendarButton icon="thumbs-up" />;
}

Render using children property

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>
    );
}