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
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gantt-task-react
# gantt-task-react (한국식 날짜 표기 적용)

## Interactive Gantt Chart for React with TypeScript.

Expand All @@ -9,7 +9,15 @@
## Install

```
npm install gantt-task-react
npm install gantt-task-react-korea
yarn add gantt-task-react-korea
```

## Updates

```
locale값에 kor을 사용하면 한국식 날짜 표기를 사용합니다.
Today에 Jira 스타일 노란색 화살표를 추가했습니다!
```

## How to use it
Expand Down Expand Up @@ -84,13 +92,13 @@ npm start

### DisplayOption

| Parameter Name | Type | Description |
| :------------- | :------ | :---------------------------------------------------------------------------------------------------------- |
| Parameter Name | Type | Description |
| :------------- | :------ | :----------------------------------------------------------------------------------------------------------------------- |
| viewMode | enum | Specifies the time scale. Hour, Quarter Day, Half Day, Day, Week(ISO-8601, 1st day is Monday), Month, QuarterYear, Year. |
| viewDate | date | Specifies display date and time for display. |
| preStepsCount | number | Specifies empty space before the fist task |
| locale | string | Specifies the month name language. Able formats: ISO 639-2, Java Locale. |
| rtl | boolean | Sets rtl mode. |
| viewDate | date | Specifies display date and time for display. |
| preStepsCount | number | Specifies empty space before the fist task |
| locale | string | Specifies the month name language. Able formats: ISO 639-2, Java Locale. |
| rtl | boolean | Sets rtl mode. |

### StylingOption

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "gantt-task-react",
"version": "0.3.9",
"description": "Interactive Gantt Chart for React with TypeScript.",
"name": "gantt-task-react-korea",
"version": "0.0.2",
"description": "This is a package that clones MaTeMaTuK/gantt-task-react to support the korean format.",
"author": "MaTeMaTuK <maksym.vikarii@gmail.com>",
"homepage": "https://github.com/MaTeMaTuK/gantt-task-react",
"homepage": "https://github.com/ohshinyeop/gantt-task-react-korea",
"license": "MIT",
"repository": "MaTeMaTuK/gantt-task-react",
"repository": "ohshinyeop/gantt-task-react-korea",
"main": "dist/index.js",
"module": "dist/index.modern.js",
"source": "src/index.tsx",
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
Loading