-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: datepicker & calendar storybook controls (#106)
* chore: datepicker storybook controls * chore: added date range picker controls * chore: added range calendar & calendar controls * chore: added default value in date ranges * chore: removed console log
- Loading branch information
1 parent
7ed738e
commit 6579b8f
Showing
8 changed files
with
460 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { expanded: true }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
|
||
import { | ||
ChevronLeft, | ||
ChevronRight, | ||
DoubleChevronLeft, | ||
DoubleChevronRight, | ||
} from "./svg-icons"; | ||
|
||
import { | ||
Calendar, | ||
CalendarCell, | ||
CalendarGrid, | ||
CalendarHeader, | ||
CalendarButton, | ||
CalendarCellButton, | ||
CalendarWeekTitle, | ||
} from "../index"; | ||
import { | ||
useRangeCalendarState, | ||
RangeCalendarInitialState, | ||
} from "../RangeCalendarState"; | ||
|
||
const RangeCalendarComponent: React.FC<RangeCalendarInitialState> = props => { | ||
const state = useRangeCalendarState(props); | ||
|
||
return ( | ||
<Calendar {...state} className="calendar-range"> | ||
<div className="header"> | ||
<CalendarButton {...state} goto="previousYear" className="prev-year"> | ||
<DoubleChevronLeft /> | ||
</CalendarButton> | ||
<CalendarButton {...state} goto="previousMonth" className="prev-month"> | ||
<ChevronLeft /> | ||
</CalendarButton> | ||
<CalendarHeader {...state} /> | ||
<CalendarButton {...state} goto="nextMonth" className="next-month"> | ||
<ChevronRight /> | ||
</CalendarButton> | ||
<CalendarButton {...state} goto="nextYear" className="next-year"> | ||
<DoubleChevronRight /> | ||
</CalendarButton> | ||
</div> | ||
|
||
<CalendarGrid {...state} as="table" className="dates"> | ||
<thead> | ||
<tr> | ||
{state.weekDays.map((day, dayIndex) => { | ||
return ( | ||
<CalendarWeekTitle | ||
{...state} | ||
as="th" | ||
scope="col" | ||
key={dayIndex} | ||
dayIndex={dayIndex} | ||
> | ||
<abbr title={day.title}>{day.abbr}</abbr> | ||
</CalendarWeekTitle> | ||
); | ||
})} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{state.daysInMonth.map((week, weekIndex) => ( | ||
<tr key={weekIndex}> | ||
{week.map((day, dayIndex) => ( | ||
<CalendarCell {...state} as="td" key={dayIndex} date={day}> | ||
<CalendarCellButton {...state} date={day} /> | ||
</CalendarCell> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</CalendarGrid> | ||
</Calendar> | ||
); | ||
}; | ||
|
||
export default RangeCalendarComponent; |
Oops, something went wrong.