Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const App = () => {
<Gantt
tasks={tasks}
viewMode={view}
locale="kor"
onDateChange={handleTaskChange}
onDelete={handleTaskDelete}
onProgressChange={handleProgressChange}
Expand All @@ -92,6 +93,7 @@ const App = () => {
<Gantt
tasks={tasks}
viewMode={view}
locale="kor"
onDateChange={handleTaskChange}
onDelete={handleTaskDelete}
onProgressChange={handleProgressChange}
Expand Down
227 changes: 161 additions & 66 deletions src/components/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getDaysInMonth,
getLocalDayOfWeek,
getLocaleMonth,
getWeekNumberISO8601,
getWeekOfMonth,
} from "../../helpers/date-helper";
import { DateSetup } from "../../types/date-setup";
import styles from "./calendar.module.css";
Expand Down Expand Up @@ -40,14 +40,24 @@ export const Calendar: React.FC<CalendarProps> = ({
const date = dateSetup.dates[i];
const bottomValue = date.getFullYear();
bottomValues.push(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
className={styles.calendarBottomText}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);
if (
i === 0 ||
Expand Down Expand Up @@ -129,14 +139,24 @@ export const Calendar: React.FC<CalendarProps> = ({
const date = dateSetup.dates[i];
const bottomValue = getLocaleMonth(date, locale);
bottomValues.push(
<text
key={bottomValue + date.getFullYear()}
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
className={styles.calendarBottomText}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);
if (
i === 0 ||
Expand Down Expand Up @@ -176,20 +196,37 @@ export const Calendar: React.FC<CalendarProps> = ({
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(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * (i + +rtl)}
className={styles.calendarBottomText}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);

if (topValue) {
Expand Down Expand Up @@ -221,19 +258,39 @@ export const Calendar: React.FC<CalendarProps> = ({
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(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
className={styles.calendarBottomText}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);
if (
i + 1 !== dates.length &&
Expand Down Expand Up @@ -275,22 +332,41 @@ export const Calendar: React.FC<CalendarProps> = ({
}).format(date);

bottomValues.push(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * (i + +rtl)}
className={styles.calendarBottomText}
fontFamily={fontFamily}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);
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(
<TopPartOfCalendar
key={topValue + date.getFullYear()}
Expand Down Expand Up @@ -320,23 +396,42 @@ export const Calendar: React.FC<CalendarProps> = ({
}).format(date);

bottomValues.push(
<text
key={date.getTime()}
y={headerHeight * 0.8}
x={columnWidth * (i + +rtl)}
className={styles.calendarBottomText}
fontFamily={fontFamily}
>
{bottomValue}
</text>
<g key={date.getTime()}>
<line
x1={columnWidth * i}
y1={headerHeight * 0.6}
x2={columnWidth * i}
y2={headerHeight}
style={{ stroke: "black", strokeWidth: 1 }}
/>
<text
y={headerHeight * 0.8}
x={columnWidth * i + columnWidth * 0.5}
textAnchor="middle"
alignmentBaseline="middle"
className={styles.calendarBottomText}
>
{bottomValue}
</text>
</g>
);
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(
<TopPartOfCalendar
Expand Down
42 changes: 35 additions & 7 deletions src/components/grid/grid-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,41 @@ export const GridBody: React.FC<GridBodyProps> = ({
).getTime() >= now.getTime())
) {
today = (
<rect
x={tickX}
y={0}
width={columnWidth}
height={y}
fill={todayColor}
/>
<svg z={1000}>
{/* μ‚¬κ°ν˜• (λ°°κ²½) */}
<rect
x={tickX}
y={0}
width={columnWidth}
height={y}
fill={todayColor}
/>

{/* 쀑앙 μ„Έλ‘œμ„  */}
<rect
x={tickX + columnWidth / 2 - 0.5}
y={5}
width={1}
height={y - 5}
style={{
fill: "#fea362",
stroke: "#fea362",
strokeWidth: 1,
}}
/>

{/* μ„Έλ‘œλ‘œ κΈ΄ μ—­μ‚Όκ°ν˜• ν™”μ‚΄ν‘œ 머리 */}
<polygon
points={`${tickX + columnWidth / 2 - 5},0 ${
tickX + columnWidth / 2 + 5
},0 ${tickX + columnWidth / 2},5 `}
style={{
fill: "#fea362",
stroke: "#fea362",
strokeWidth: 1,
}}
/>
</svg>
);
}
// rtl for today
Expand Down
19 changes: 12 additions & 7 deletions src/components/other/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,18 @@ export const StandardTooltipContent: React.FC<{
};
return (
<div className={styles.tooltipDefaultContainer} style={style}>
<b style={{ fontSize: fontSize + 6 }}>{`${
task.name
}: ${task.start.getDate()}-${
task.start.getMonth() + 1
}-${task.start.getFullYear()} - ${task.end.getDate()}-${
task.end.getMonth() + 1
}-${task.end.getFullYear()}`}</b>
<b style={{ fontSize: fontSize + 6 }}>{`${task.name}`}</b>
<p></p>
<p
className={styles.tooltipDefaultContainerParagraph}
style={{ marginTop: 4 }}
>
{`date : ${task.start.getFullYear()}-${
task.start.getMonth() + 1
}-${task.start.getDate()} ~ ${task.end.getFullYear()}-${
task.end.getMonth() + 1
}-${task.end.getDate()}`}
</p>
{task.end.getTime() - task.start.getTime() !== 0 && (
<p className={styles.tooltipDefaultContainerParagraph}>{`Duration: ${~~(
(task.end.getTime() - task.start.getTime()) /
Expand Down
Loading