@@ -31,17 +31,50 @@ export function Calendar() {
31
31
}
32
32
} ;
33
33
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ const updateSize = ( ) => {
36
+ const isMobile = window . innerWidth < 768 ;
37
+ setCalendarHeight ( isMobile ? 500 : 'auto' ) ;
38
+ updateTitle ( ) ;
39
+ } ;
40
+
41
+ const updateTitle = ( ) => {
42
+ const calendarApi = calendarRef ?. current ?. getApi ( ) ;
43
+ if ( calendarApi ) {
44
+ const calendarView = calendarApi . view ;
45
+
46
+ const date = new Date ( calendarView . currentStart ) ;
47
+ const year = date . getFullYear ( ) ;
48
+ const month = ( date . getMonth ( ) + 1 ) . toString ( ) . padStart ( 2 , '0' ) ;
49
+ const newTitle = `${ year } .${ month } ` ;
50
+
51
+ const titleElement = document . querySelector ( '.fc-toolbar-title' ) ;
52
+ if ( titleElement ) {
53
+ titleElement . textContent = newTitle ;
54
+ }
55
+ }
56
+ } ;
57
+
34
58
useEffect ( ( ) => {
35
- const updateSize = ( ) => {
36
- const isMobile = window . innerWidth < 768 ;
37
- setCalendarHeight ( isMobile ? 500 : 'auto' ) ;
38
- } ;
59
+ const calendarApi = calendarRef ?. current ?. getApi ( ) ;
60
+
61
+ if ( calendarApi ) {
62
+ calendarApi . on ( 'datesSet' , updateTitle ) ;
63
+ }
64
+
65
+ updateTitle ( ) ; // ์ปดํฌ๋ํธ ๋ง์ดํธ ์ ์ ๋ชฉ ์
๋ฐ์ดํธ
39
66
67
+ /* ์บ๋ฆฐ๋ - ๋ฐ์ํ ์ฌ์ด์ฆ */
40
68
window . addEventListener ( 'resize' , updateSize ) ;
41
- updateSize ( ) ;
69
+ updateSize ( ) ; // ์ปดํฌ๋ํธ ๋ง์ดํธ ์ ํ๋ฉด ํฌ๊ธฐ์ ๋ฐ๋ฅธ ์
๋ฐ์ดํธ
42
70
43
- return ( ) => window . removeEventListener ( 'resize' , updateSize ) ;
44
- } , [ ] ) ;
71
+ return ( ) => {
72
+ window . removeEventListener ( 'resize' , updateSize ) ;
73
+ if ( calendarApi ) {
74
+ calendarApi . off ( 'datesSet' , updateTitle ) ;
75
+ }
76
+ } ;
77
+ } , [ updateSize ] ) ;
45
78
46
79
return (
47
80
< div >
@@ -58,6 +91,10 @@ export function Calendar() {
58
91
titleFormat = { {
59
92
year : 'numeric' ,
60
93
month : '2-digit' ,
94
+ } }
95
+ eventTimeFormat = { {
96
+ hour : '2-digit' ,
97
+ minute : '2-digit' ,
61
98
meridiem : false ,
62
99
} }
63
100
dayHeaderFormat = { {
@@ -70,11 +107,9 @@ export function Calendar() {
70
107
} }
71
108
customButtons = { {
72
109
prevButton : {
73
- icon : 'chevron-left' ,
74
110
click : handlePrev ,
75
111
} ,
76
112
nextButton : {
77
- icon : 'chevron-right' ,
78
113
click : handleNext ,
79
114
} ,
80
115
} }
@@ -93,8 +128,10 @@ interface EventInfo {
93
128
function renderEventContent ( eventInfo : EventInfo ) {
94
129
return (
95
130
< >
96
- < b > { eventInfo . timeText } </ b >
97
- < i > { eventInfo . event . title } </ i >
131
+ < div className = "w-full border-0 bg-secondary p-0.5 text-white" >
132
+ < b className = "border-0" > { eventInfo . timeText } </ b >
133
+ < i > { eventInfo . event . title } </ i >
134
+ </ div >
98
135
</ >
99
136
) ;
100
137
}
0 commit comments