Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.9 KB
Raw Blame
import type { Meta, StoryObj } from '@storybook/react'

import { dayjs } from 'lib/dayjs'

import { LemonCalendar, LemonCalendarProps } from './LemonCalendar'

type Story = StoryObj<LemonCalendarProps>
const meta: Meta<LemonCalendarProps> = {
    title: 'Lemon UI/Lemon Calendar/Lemon Calendar',
    component: LemonCalendar as any,
    args: {
        onDateClick: (date: dayjs.Dayjs) => {
            // eslint-disable-next-line no-console
            console.log(`Clicked: ${date}`)
        },
    },
    parameters: {
        mockDate: '2023-01-26',
    },
    tags: ['autodocs'],
}
export default meta

export const Default: Story = { args: {} }

export const MultipleMonths: Story = { args: { months: 3 } }

export const RangeSelection: Story = {
    args: {
        getDateState: ({ date }) => ({
            isStart: date.date() === 10,
            isEnd: date.date() === 20,
            isBetween: date.date() > 10 && date.date() < 20,
        }),
    },
}

export const SingleSelection: Story = {
    args: {
        getDateState: ({ date }) => ({
            selected: date.date() === 15,
            disabledReason: date.date() > 20 ? 'Cannot select dates after the 20th' : undefined,
        }),
    },
}

export const MondayFirst: Story = { args: { weekStartDay: 1 } }

export const TuesdayFirst: Story = { args: { weekStartDay: 2 } }

export const WednesdayFirst: Story = { args: { weekStartDay: 3 } }

export const ThursdayFirst: Story = { args: { weekStartDay: 4 } }

export const FridayFirst: Story = { args: { weekStartDay: 5 } }

export const SaturdayFirst: Story = { args: { weekStartDay: 6 } }

export const SundayFirst: Story = { args: { weekStartDay: 0 } }

export const Hour: Story = { args: { granularity: 'hour' } }

export const Minute: Story = { args: { granularity: 'minute' } }

export const Minute24Hour: Story = { args: { granularity: 'minute', use24HourFormat: true } }