1
1
import type { Meta , StoryObj } from "@storybook/react" ;
2
- import { addDays , endOfMonth , subDays , startOfMonth } from "date-fns" ;
2
+ import { addDays , subDays } from "date-fns" ;
3
+ import { format } from "date-fns/fp/format" ;
3
4
4
5
import { paddingDecorator } from "@/developer/decorators" ;
5
- import { toDateId } from "@/helpers/dates" ;
6
+ import { toDateId , endOfMonth , startOfMonth } from "@/helpers/dates" ;
7
+ import { loggingHandler } from "@/developer/loggginHandler" ;
6
8
7
9
import { Calendar } from "./Calendar" ;
8
10
@@ -22,17 +24,11 @@ const CalendarMeta: Meta<typeof Calendar> = {
22
24
options : [ "monday" , "sunday" ] ,
23
25
} ,
24
26
onCalendarDayPress : { action : "onCalendarDayPress" } ,
25
- calendarDayFormat : { type : "string" } ,
26
- calendarMonthFormat : { type : "string" } ,
27
- calendarWeekDayFormat : { type : "string" } ,
28
27
} ,
29
28
30
29
args : {
31
30
calendarFirstDayOfWeek : "sunday" ,
32
31
calendarMonthId : toDateId ( startOfThisMonth ) ,
33
- calendarDayFormat : "d" ,
34
- calendarWeekDayFormat : "EEEEE" ,
35
- calendarMonthFormat : "MMMM yyyy" ,
36
32
} ,
37
33
decorators : [ paddingDecorator ] ,
38
34
} ;
@@ -50,9 +46,6 @@ export const KichenSink: StoryObj<typeof Calendar> = {
50
46
args : {
51
47
calendarFirstDayOfWeek : "sunday" ,
52
48
calendarMonthId : toDateId ( startOfThisMonth ) ,
53
- calendarDayFormat : "d" ,
54
- calendarWeekDayFormat : "EEEEE" ,
55
- calendarMonthFormat : "MMMM yyyy" ,
56
49
calendarDisabledDateIds : [
57
50
toDateId ( addDays ( today , 1 ) ) ,
58
51
toDateId ( subDays ( today , 1 ) ) ,
@@ -105,3 +98,16 @@ export const ActiveDateRanges: StoryObj<typeof Calendar> = {
105
98
calendarMonthId : "2024-01-01" ,
106
99
} ,
107
100
} ;
101
+
102
+ export const WithCustomFormatting = ( args : typeof KichenSink . args ) => {
103
+ return (
104
+ < Calendar
105
+ { ...args }
106
+ calendarMonthId = { toDateId ( startOfThisMonth ) }
107
+ getCalendarDayFormat = { format ( "dd" ) }
108
+ getCalendarMonthFormat = { format ( "MMMM yyyy (LL/yyyy)" ) }
109
+ getCalendarWeekDayFormat = { format ( "E" ) }
110
+ onCalendarDayPress = { loggingHandler ( "onCalendarDayPress" ) }
111
+ />
112
+ ) ;
113
+ } ;
0 commit comments