diff --git a/example/src/App.tsx b/example/src/App.tsx index c2ab602eb..6e9482ec3 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -78,6 +78,7 @@ const App = () => { { = ({ const date = dateSetup.dates[i]; const bottomValue = date.getFullYear(); bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if ( i === 0 || @@ -129,14 +139,24 @@ export const Calendar: React.FC = ({ const date = dateSetup.dates[i]; const bottomValue = getLocaleMonth(date, locale); bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if ( i === 0 || @@ -176,20 +196,37 @@ export const Calendar: React.FC = ({ let topValue = ""; if (i === 0 || date.getMonth() !== dates[i - 1].getMonth()) { // top - topValue = `${getLocaleMonth(date, locale)}, ${date.getFullYear()}`; + if (locale === "kor") { + topValue = `${date.getFullYear()}년 ${getLocaleMonth(date, locale)}`; + } else { + topValue = `${getLocaleMonth(date, locale)}, ${date.getFullYear()}`; + } } // bottom - const bottomValue = `W${getWeekNumberISO8601(date)}`; + const bottomValue = + locale === "kor" + ? `${getLocaleMonth(date, locale)} ${getWeekOfMonth(date)}주` + : `W${getWeekOfMonth(date)}`; bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if (topValue) { @@ -221,19 +258,39 @@ export const Calendar: React.FC = ({ const dates = dateSetup.dates; for (let i = 0; i < dates.length; i++) { const date = dates[i]; - const bottomValue = `${getLocalDayOfWeek(date, locale, "short")}, ${date - .getDate() - .toString()}`; + const bottomValue = + locale === "kor" + ? `${getLocaleMonth( + date, + locale + )} ${date.getDate()}일 (${getLocalDayOfWeek( + date, + locale, + "short" + )})` + : `${getLocalDayOfWeek(date, locale, "short")}, ${date + .getDate() + .toString()}`; bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if ( i + 1 !== dates.length && @@ -275,22 +332,41 @@ export const Calendar: React.FC = ({ }).format(date); bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if (i === 0 || date.getDate() !== dates[i - 1].getDate()) { - const topValue = `${getLocalDayOfWeek( - date, - locale, - "short" - )}, ${date.getDate()} ${getLocaleMonth(date, locale)}`; + const topValue = + locale === "kor" + ? `${getLocaleMonth( + date, + locale + )} ${date.getDate()}일 (${getLocalDayOfWeek( + date, + locale, + "short" + )})` + : `${getLocalDayOfWeek( + date, + locale, + "short" + )}, ${date.getDate()} ${getLocaleMonth(date, locale)}`; topValues.push( = ({ }).format(date); bottomValues.push( - - {bottomValue} - + + + + {bottomValue} + + ); if (i !== 0 && date.getDate() !== dates[i - 1].getDate()) { const displayDate = dates[i - 1]; - const topValue = `${getLocalDayOfWeek( - displayDate, - locale, - "long" - )}, ${displayDate.getDate()} ${getLocaleMonth(displayDate, locale)}`; + const topValue = + locale === "kor" + ? `${getLocaleMonth( + displayDate, + locale + )} ${displayDate.getDate()}일 (${getLocalDayOfWeek( + displayDate, + locale, + "long" + )})` + : `${getLocalDayOfWeek( + date, + locale, + "long" + )}, ${date.getDate()} ${getLocaleMonth(date, locale)}`; const topPosition = (date.getHours() - 24) / 2; topValues.push( = ({ ).getTime() >= now.getTime()) ) { today = ( - + + {/* 사각형 (배경) */} + + + {/* 중앙 세로선 */} + + + {/* 세로로 긴 역삼각형 화살표 머리 */} + + ); } // rtl for today diff --git a/src/components/other/tooltip.tsx b/src/components/other/tooltip.tsx index 7542a14eb..938a09076 100644 --- a/src/components/other/tooltip.tsx +++ b/src/components/other/tooltip.tsx @@ -123,13 +123,18 @@ export const StandardTooltipContent: React.FC<{ }; return (
- {`${ - task.name - }: ${task.start.getDate()}-${ - task.start.getMonth() + 1 - }-${task.start.getFullYear()} - ${task.end.getDate()}-${ - task.end.getMonth() + 1 - }-${task.end.getFullYear()}`} + {`${task.name}`} +

+

+ {`date : ${task.start.getFullYear()}-${ + task.start.getMonth() + 1 + }-${task.start.getDate()} ~ ${task.end.getFullYear()}-${ + task.end.getMonth() + 1 + }-${task.end.getDate()}`} +

{task.end.getTime() - task.start.getTime() !== 0 && (

{`Duration: ${~~( (task.end.getTime() - task.start.getTime()) / diff --git a/src/components/task-item/project/project.tsx b/src/components/task-item/project/project.tsx index 5a47ba90b..8793b2cbc 100644 --- a/src/components/task-item/project/project.tsx +++ b/src/components/task-item/project/project.tsx @@ -11,23 +11,6 @@ export const Project: React.FC = ({ task, isSelected }) => { : task.styles.progressColor; const projectWith = task.x2 - task.x1; - const projectLeftTriangle = [ - task.x1, - task.y + task.height / 2 - 1, - task.x1, - task.y + task.height, - task.x1 + 15, - task.y + task.height / 2 - 1, - ].join(","); - const projectRightTriangle = [ - task.x2, - task.y + task.height / 2 - 1, - task.x2, - task.y + task.height, - task.x2 - 15, - task.y + task.height / 2 - 1, - ].join(","); - return ( = ({ task, isSelected }) => { rx={task.barCornerRadius} fill={processColor} /> - - - ); }; diff --git a/src/components/task-item/task-item.tsx b/src/components/task-item/task-item.tsx index 0f5c769ce..cbdf829c6 100644 --- a/src/components/task-item/task-item.tsx +++ b/src/components/task-item/task-item.tsx @@ -117,6 +117,7 @@ export const TaskItem: React.FC = props => { : style.barLabel && style.barLabelOutside } ref={textRef} + fontSize={12} > {task.name} diff --git a/src/helpers/date-helper.ts b/src/helpers/date-helper.ts index 8c495a374..d5285b251 100644 --- a/src/helpers/date-helper.ts +++ b/src/helpers/date-helper.ts @@ -216,6 +216,30 @@ const getMonday = (date: Date) => { return new Date(date.setDate(diff)); }; +export const getWeekOfMonth = (date: any) => { + // 주어진 날짜의 첫 번째 날을 가져옵니다. + const startOfMonth = new Date(date.getFullYear(), date.getMonth(), 1); + + // 주어진 날짜의 첫 번째 월요일을 가져옵니다. + const firstMonday: any = new Date(startOfMonth); + while (firstMonday.getDay() !== 1) { + firstMonday.setDate(firstMonday.getDate() + 1); + } + + // 주어진 날짜와 첫 번째 월요일 사이의 일수를 계산합니다. + const diffDays = Math.ceil((date - firstMonday) / (24 * 60 * 60 * 1000)); + + // 주 수를 계산합니다. 주어진 날짜가 첫 번째 월요일 이전이면 1주차로 간주합니다. + const weekNumber = Math.ceil((diffDays + 1) / 7); + + // 만약 주어진 날짜가 첫 번째 월요일보다 앞에 있다면 첫 번째 주로 간주합니다. + if (diffDays < 0) { + return 1; + } + + return weekNumber; +}; + export const getWeekNumberISO8601 = (date: Date) => { const tmpDate = new Date(date.valueOf()); const dayNumber = (tmpDate.getDay() + 6) % 7;