|
6 | 6 | getDaysInMonth, |
7 | 7 | getLocalDayOfWeek, |
8 | 8 | getLocaleMonth, |
9 | | - getWeekNumberISO8601, |
| 9 | + getWeekOfMonth, |
10 | 10 | } from "../../helpers/date-helper"; |
11 | 11 | import { DateSetup } from "../../types/date-setup"; |
12 | 12 | import styles from "./calendar.module.css"; |
@@ -40,14 +40,24 @@ export const Calendar: React.FC<CalendarProps> = ({ |
40 | 40 | const date = dateSetup.dates[i]; |
41 | 41 | const bottomValue = date.getFullYear(); |
42 | 42 | bottomValues.push( |
43 | | - <text |
44 | | - key={date.getTime()} |
45 | | - y={headerHeight * 0.8} |
46 | | - x={columnWidth * i + columnWidth * 0.5} |
47 | | - className={styles.calendarBottomText} |
48 | | - > |
49 | | - {bottomValue} |
50 | | - </text> |
| 43 | + <g key={date.getTime()}> |
| 44 | + <line |
| 45 | + x1={columnWidth * i} |
| 46 | + y1={headerHeight * 0.6} |
| 47 | + x2={columnWidth * i} |
| 48 | + y2={headerHeight} |
| 49 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 50 | + /> |
| 51 | + <text |
| 52 | + y={headerHeight * 0.8} |
| 53 | + x={columnWidth * i + columnWidth * 0.5} |
| 54 | + textAnchor="middle" |
| 55 | + alignmentBaseline="middle" |
| 56 | + className={styles.calendarBottomText} |
| 57 | + > |
| 58 | + {bottomValue} |
| 59 | + </text> |
| 60 | + </g> |
51 | 61 | ); |
52 | 62 | if ( |
53 | 63 | i === 0 || |
@@ -129,14 +139,24 @@ export const Calendar: React.FC<CalendarProps> = ({ |
129 | 139 | const date = dateSetup.dates[i]; |
130 | 140 | const bottomValue = getLocaleMonth(date, locale); |
131 | 141 | bottomValues.push( |
132 | | - <text |
133 | | - key={bottomValue + date.getFullYear()} |
134 | | - y={headerHeight * 0.8} |
135 | | - x={columnWidth * i + columnWidth * 0.5} |
136 | | - className={styles.calendarBottomText} |
137 | | - > |
138 | | - {bottomValue} |
139 | | - </text> |
| 142 | + <g key={date.getTime()}> |
| 143 | + <line |
| 144 | + x1={columnWidth * i} |
| 145 | + y1={headerHeight * 0.6} |
| 146 | + x2={columnWidth * i} |
| 147 | + y2={headerHeight} |
| 148 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 149 | + /> |
| 150 | + <text |
| 151 | + y={headerHeight * 0.8} |
| 152 | + x={columnWidth * i + columnWidth * 0.5} |
| 153 | + textAnchor="middle" |
| 154 | + alignmentBaseline="middle" |
| 155 | + className={styles.calendarBottomText} |
| 156 | + > |
| 157 | + {bottomValue} |
| 158 | + </text> |
| 159 | + </g> |
140 | 160 | ); |
141 | 161 | if ( |
142 | 162 | i === 0 || |
@@ -176,20 +196,37 @@ export const Calendar: React.FC<CalendarProps> = ({ |
176 | 196 | let topValue = ""; |
177 | 197 | if (i === 0 || date.getMonth() !== dates[i - 1].getMonth()) { |
178 | 198 | // top |
179 | | - topValue = `${getLocaleMonth(date, locale)}, ${date.getFullYear()}`; |
| 199 | + if (locale === "kor") { |
| 200 | + topValue = `${date.getFullYear()}년 ${getLocaleMonth(date, locale)}`; |
| 201 | + } else { |
| 202 | + topValue = `${getLocaleMonth(date, locale)}, ${date.getFullYear()}`; |
| 203 | + } |
180 | 204 | } |
181 | 205 | // bottom |
182 | | - const bottomValue = `W${getWeekNumberISO8601(date)}`; |
| 206 | + const bottomValue = |
| 207 | + locale === "kor" |
| 208 | + ? `${getLocaleMonth(date, locale)} ${getWeekOfMonth(date)}주` |
| 209 | + : `W${getWeekOfMonth(date)}`; |
183 | 210 |
|
184 | 211 | bottomValues.push( |
185 | | - <text |
186 | | - key={date.getTime()} |
187 | | - y={headerHeight * 0.8} |
188 | | - x={columnWidth * (i + +rtl)} |
189 | | - className={styles.calendarBottomText} |
190 | | - > |
191 | | - {bottomValue} |
192 | | - </text> |
| 212 | + <g key={date.getTime()}> |
| 213 | + <line |
| 214 | + x1={columnWidth * i} |
| 215 | + y1={headerHeight * 0.6} |
| 216 | + x2={columnWidth * i} |
| 217 | + y2={headerHeight} |
| 218 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 219 | + /> |
| 220 | + <text |
| 221 | + y={headerHeight * 0.8} |
| 222 | + x={columnWidth * i + columnWidth * 0.5} |
| 223 | + textAnchor="middle" |
| 224 | + alignmentBaseline="middle" |
| 225 | + className={styles.calendarBottomText} |
| 226 | + > |
| 227 | + {bottomValue} |
| 228 | + </text> |
| 229 | + </g> |
193 | 230 | ); |
194 | 231 |
|
195 | 232 | if (topValue) { |
@@ -221,19 +258,39 @@ export const Calendar: React.FC<CalendarProps> = ({ |
221 | 258 | const dates = dateSetup.dates; |
222 | 259 | for (let i = 0; i < dates.length; i++) { |
223 | 260 | const date = dates[i]; |
224 | | - const bottomValue = `${getLocalDayOfWeek(date, locale, "short")}, ${date |
225 | | - .getDate() |
226 | | - .toString()}`; |
| 261 | + const bottomValue = |
| 262 | + locale === "kor" |
| 263 | + ? `${getLocaleMonth( |
| 264 | + date, |
| 265 | + locale |
| 266 | + )} ${date.getDate()}일 (${getLocalDayOfWeek( |
| 267 | + date, |
| 268 | + locale, |
| 269 | + "short" |
| 270 | + )})` |
| 271 | + : `${getLocalDayOfWeek(date, locale, "short")}, ${date |
| 272 | + .getDate() |
| 273 | + .toString()}`; |
227 | 274 |
|
228 | 275 | bottomValues.push( |
229 | | - <text |
230 | | - key={date.getTime()} |
231 | | - y={headerHeight * 0.8} |
232 | | - x={columnWidth * i + columnWidth * 0.5} |
233 | | - className={styles.calendarBottomText} |
234 | | - > |
235 | | - {bottomValue} |
236 | | - </text> |
| 276 | + <g key={date.getTime()}> |
| 277 | + <line |
| 278 | + x1={columnWidth * i} |
| 279 | + y1={headerHeight * 0.6} |
| 280 | + x2={columnWidth * i} |
| 281 | + y2={headerHeight} |
| 282 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 283 | + /> |
| 284 | + <text |
| 285 | + y={headerHeight * 0.8} |
| 286 | + x={columnWidth * i + columnWidth * 0.5} |
| 287 | + textAnchor="middle" |
| 288 | + alignmentBaseline="middle" |
| 289 | + className={styles.calendarBottomText} |
| 290 | + > |
| 291 | + {bottomValue} |
| 292 | + </text> |
| 293 | + </g> |
237 | 294 | ); |
238 | 295 | if ( |
239 | 296 | i + 1 !== dates.length && |
@@ -275,22 +332,41 @@ export const Calendar: React.FC<CalendarProps> = ({ |
275 | 332 | }).format(date); |
276 | 333 |
|
277 | 334 | bottomValues.push( |
278 | | - <text |
279 | | - key={date.getTime()} |
280 | | - y={headerHeight * 0.8} |
281 | | - x={columnWidth * (i + +rtl)} |
282 | | - className={styles.calendarBottomText} |
283 | | - fontFamily={fontFamily} |
284 | | - > |
285 | | - {bottomValue} |
286 | | - </text> |
| 335 | + <g key={date.getTime()}> |
| 336 | + <line |
| 337 | + x1={columnWidth * i} |
| 338 | + y1={headerHeight * 0.6} |
| 339 | + x2={columnWidth * i} |
| 340 | + y2={headerHeight} |
| 341 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 342 | + /> |
| 343 | + <text |
| 344 | + y={headerHeight * 0.8} |
| 345 | + x={columnWidth * i + columnWidth * 0.5} |
| 346 | + textAnchor="middle" |
| 347 | + alignmentBaseline="middle" |
| 348 | + className={styles.calendarBottomText} |
| 349 | + > |
| 350 | + {bottomValue} |
| 351 | + </text> |
| 352 | + </g> |
287 | 353 | ); |
288 | 354 | if (i === 0 || date.getDate() !== dates[i - 1].getDate()) { |
289 | | - const topValue = `${getLocalDayOfWeek( |
290 | | - date, |
291 | | - locale, |
292 | | - "short" |
293 | | - )}, ${date.getDate()} ${getLocaleMonth(date, locale)}`; |
| 355 | + const topValue = |
| 356 | + locale === "kor" |
| 357 | + ? `${getLocaleMonth( |
| 358 | + date, |
| 359 | + locale |
| 360 | + )} ${date.getDate()}일 (${getLocalDayOfWeek( |
| 361 | + date, |
| 362 | + locale, |
| 363 | + "short" |
| 364 | + )})` |
| 365 | + : `${getLocalDayOfWeek( |
| 366 | + date, |
| 367 | + locale, |
| 368 | + "short" |
| 369 | + )}, ${date.getDate()} ${getLocaleMonth(date, locale)}`; |
294 | 370 | topValues.push( |
295 | 371 | <TopPartOfCalendar |
296 | 372 | key={topValue + date.getFullYear()} |
@@ -320,23 +396,42 @@ export const Calendar: React.FC<CalendarProps> = ({ |
320 | 396 | }).format(date); |
321 | 397 |
|
322 | 398 | bottomValues.push( |
323 | | - <text |
324 | | - key={date.getTime()} |
325 | | - y={headerHeight * 0.8} |
326 | | - x={columnWidth * (i + +rtl)} |
327 | | - className={styles.calendarBottomText} |
328 | | - fontFamily={fontFamily} |
329 | | - > |
330 | | - {bottomValue} |
331 | | - </text> |
| 399 | + <g key={date.getTime()}> |
| 400 | + <line |
| 401 | + x1={columnWidth * i} |
| 402 | + y1={headerHeight * 0.6} |
| 403 | + x2={columnWidth * i} |
| 404 | + y2={headerHeight} |
| 405 | + style={{ stroke: "black", strokeWidth: 1 }} |
| 406 | + /> |
| 407 | + <text |
| 408 | + y={headerHeight * 0.8} |
| 409 | + x={columnWidth * i + columnWidth * 0.5} |
| 410 | + textAnchor="middle" |
| 411 | + alignmentBaseline="middle" |
| 412 | + className={styles.calendarBottomText} |
| 413 | + > |
| 414 | + {bottomValue} |
| 415 | + </text> |
| 416 | + </g> |
332 | 417 | ); |
333 | 418 | if (i !== 0 && date.getDate() !== dates[i - 1].getDate()) { |
334 | 419 | const displayDate = dates[i - 1]; |
335 | | - const topValue = `${getLocalDayOfWeek( |
336 | | - displayDate, |
337 | | - locale, |
338 | | - "long" |
339 | | - )}, ${displayDate.getDate()} ${getLocaleMonth(displayDate, locale)}`; |
| 420 | + const topValue = |
| 421 | + locale === "kor" |
| 422 | + ? `${getLocaleMonth( |
| 423 | + displayDate, |
| 424 | + locale |
| 425 | + )} ${displayDate.getDate()}일 (${getLocalDayOfWeek( |
| 426 | + displayDate, |
| 427 | + locale, |
| 428 | + "long" |
| 429 | + )})` |
| 430 | + : `${getLocalDayOfWeek( |
| 431 | + displayDate, |
| 432 | + locale, |
| 433 | + "long" |
| 434 | + )}, ${displayDate.getDate()} ${getLocaleMonth(displayDate, locale)}`; |
340 | 435 | const topPosition = (date.getHours() - 24) / 2; |
341 | 436 | topValues.push( |
342 | 437 | <TopPartOfCalendar |
|
0 commit comments