Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new prop weekendColor to grid #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ npm start
| barBackgroundSelectedColor | string | Specifies the taskbar background fill color globally on select. |
| arrowColor | string | Specifies the relationship arrow fill color. |
| arrowIndent | number | Specifies the relationship arrow right indent. Sets in px |
| todayColor | string | Specifies the current period column fill color. |
| todayColor | string | Specifies the current period column fill color.
| weekendColor | string | Specifies the current period column fill color. |
| TooltipContent | | Specifies the Tooltip view for selected taskbar. |
| TaskListHeader | | Specifies the task list Header view |
| TaskListTable | | Specifies the task list Table view |
Expand Down
1 change: 1 addition & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const App = () => {
onExpanderClick={handleExpanderClick}
listCellWidth={isChecked ? "155px" : ""}
columnWidth={columnWidth}
weekendColor={"#97979714"}
/>
<h3>Gantt With Limited Height</h3>
<Gantt
Expand Down
4 changes: 3 additions & 1 deletion src/components/gantt/gantt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
fontFamily = "Arial, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue",
fontSize = "14px",
arrowIndent = 20,
todayColor = "rgba(252, 248, 227, 0.5)",
todayColor = "rgba(252, 248, 227, 1)",
weekendColor = "transparent",
viewDate,
TooltipContent = StandardTooltipContent,
TaskListHeader = TaskListHeaderDefault,
Expand Down Expand Up @@ -394,6 +395,7 @@ export const Gantt: React.FunctionComponent<GanttProps> = ({
rowHeight,
dates: dateSetup.dates,
todayColor,
weekendColor,
rtl,
};
const calendarProps: CalendarProps = {
Expand Down
19 changes: 19 additions & 0 deletions src/components/grid/grid-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type GridBodyProps = {
rowHeight: number;
columnWidth: number;
todayColor: string;
weekendColor: string;
rtl: boolean;
};
export const GridBody: React.FC<GridBodyProps> = ({
Expand All @@ -19,6 +20,7 @@ export const GridBody: React.FC<GridBodyProps> = ({
svgWidth,
columnWidth,
todayColor,
weekendColor,
rtl,
}) => {
let y = 0;
Expand Down Expand Up @@ -60,6 +62,7 @@ export const GridBody: React.FC<GridBodyProps> = ({
const now = new Date();
let tickX = 0;
const ticks: ReactChild[] = [];
const weekends: ReactChild[] = [];
let today: ReactChild = <rect />;
for (let i = 0; i < dates.length; i++) {
const date = dates[i];
Expand All @@ -73,6 +76,20 @@ export const GridBody: React.FC<GridBodyProps> = ({
className={styles.gridTick}
/>
);

if (weekendColor !== "transparent" && dates[i + 1] && [0,6].includes(dates[i + 1].getDay())) {
weekends.push(
<rect
key={"WeekendColumn" + i}
x={tickX + columnWidth}
y={0}
width={columnWidth}
height={y}
fill={weekendColor}
/>
);
}

if (
(i + 1 !== dates.length &&
date.getTime() < now.getTime() &&
Expand Down Expand Up @@ -114,13 +131,15 @@ export const GridBody: React.FC<GridBodyProps> = ({
/>
);
}

tickX += columnWidth;
}
return (
<g className="gridBody">
<g className="rows">{gridRows}</g>
<g className="rowLines">{rowLines}</g>
<g className="ticks">{ticks}</g>
<g className="weekends">{weekends}</g>
<g className="today">{today}</g>
</g>
);
Expand Down
1 change: 1 addition & 0 deletions src/types/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface StylingOption {
arrowColor?: string;
arrowIndent?: number;
todayColor?: string;
weekendColor?: string;
TooltipContent?: React.FC<{
task: Task;
fontSize: string;
Expand Down