Skip to content

Commit

Permalink
chore(calendar): expose in story book with default story (#3710)
Browse files Browse the repository at this point in the history
* chore(calendar): expose in story book with default story

* fix: grammar

Co-authored-by: Aleksandr Shumilov <[email protected]>

* fix: add link to DatePicker

---------

Co-authored-by: Aleksandr Shumilov <[email protected]>
  • Loading branch information
OleksandrNechai and sashuk committed Jul 11, 2023
1 parent 47b0d54 commit 7ec7c1a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/picasso/src/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,35 @@ export type CalendarMonthsAmount = 1 | 2
export interface Props
extends BaseProps,
Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onBlur'> {
/** Callback invoked when date is selected */
onChange: (value: DateOrDateRangeType) => void
/** Callback invoked when calendar loses focus */
onBlur?: (event: React.FocusEvent<HTMLDivElement>) => void
/** Minimum date that can be selected */
minDate?: Date
/** Maximum date that can be selected */
maxDate?: Date
/** Whether to use range mode */
range?: boolean
/** Selected date or date range */
value?: DateOrDateRangeType
/** Active (visible) month of the calendar that is required for manual entering of a single date */
activeMonth?: Date
/** Custom root renderer */
renderRoot?: RenderRoot
/** Custom month header renderer */
renderMonthHeader?: RenderMonthHeader
/** Custom day renderer */
renderDay?: RenderDay
/** Intervals that should be indicated as disabled */
disabledIntervals?: CalendarDateRange[]
/** Intervals that should be indicated with orange dots */
indicatedIntervals?: CalendarDateRange[]
/** First day of the week */
weekStartsOn?: WeekStart
/** Whether to display footer */
hasFooter?: boolean
/** Number of months to display */
numberOfMonths?: CalendarMonthsAmount
}

Expand Down
11 changes: 11 additions & 0 deletions packages/picasso/src/Calendar/story/Default.example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { useState } from 'react'
import type { DateOrDateRangeType } from '@toptal/picasso'
import { Calendar } from '@toptal/picasso'

const DefaultExample = () => {
const [value, setValue] = useState<DateOrDateRangeType>(new Date())

return <Calendar value={value} onChange={setValue} />
}

export default DefaultExample
18 changes: 18 additions & 0 deletions packages/picasso/src/Calendar/story/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Calendar } from '../Calendar'
import PicassoBook from '~/.storybook/components/PicassoBook'

const page = PicassoBook.section('Components').createPage(
'Calendar',
`Container for displaying data in calendar form. See even more use cases in [DatePicker](/?path=/story/forms-datepicker--datepicker).
${PicassoBook.createSourceLink(__filename)}
`
)

page.createTabChapter('Props').addComponentDocs({
component: Calendar,
name: 'Calendar',
})

page.createChapter().addExample('Calendar/story/Default.example.tsx', 'Default')

0 comments on commit 7ec7c1a

Please sign in to comment.