0.0.1-alpha.10 • Published 5 months ago

@mopex/react-gantt-flow v0.0.1-alpha.10

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

React Gantt Flow

Contributors Forks Stargazers Issues MIT License

About The Project

🔧 Built With

React

✨ Features

  • Drag & Resize to modify start/end dates
  • Update the progress bar using slider control
  • Automatic rendering of dependency arrows
  • Toggle today's line and planned vs actual disparity display with a single click
  • Type-safe TypeScript API
  • No dependencies except for react and date-fns

Getting Started

💿 Installation

# pnpm
pnpm add @mopex/react-gantt-flow

# npm
npm install @mopex/react-gantt-flow

React 19 or higher is required as a peer dependency.

⚡ Quick Start

import { useState } from "react";
import GanttFlow from "@mopex/react-gantt-flow";

const initialTasks = [
  {
    id: "task-001",
    name: "Design",
    startDate: new Date(2025, 0, 1),
    endDate: new Date(2025, 0, 7),
    progress: 30,
    dependencies: [],
  },
  {
    id: "task-002",
    name: "Implementation",
    startDate: new Date(2025, 0, 8),
    endDate: new Date(2025, 0, 21),
    progress: 0,
    dependencies: ["task-001"],
  },
];

export default function App() {
  const [tasks, setTasks] = useState(initialTasks);

  return (
    <GanttFlow
      task={tasks}
      todaysLineDisplay
      disparityDisplay
      onChange={(id, newStart, newEnd, newProgress) => {
        setTasks((prev) =>
          prev.map((t) =>
            t.id === id
              ? {
                  ...t,
                  startDate: newStart,
                  endDate: newEnd,
                  progress: newProgress ?? t.progress,
                }
              : t,
          ),
        );
      }}
    />
  );
}

API Reference

📚 <GanttFlow /> Props

NameTypeDefaultDescription
taskTask[]Array of tasks to display
todaysLineDisplaybooleanfalseDisplay a vertical line indicating today
disparityDisplaybooleanfalseRender disparity between planned and actual as a rectangle
onChange(taskId, newStartDate, newEndDate, newProgress?) => voidCallback invoked when a task is updated

▪️ Task Type

type Task = {
  id: string;
  name: string;
  startDate: Date;
  endDate: Date;
  progress: number; // 0 ~ 100
  dependencies: string[];
};

Development

pnpm install       # Install dependencies
pnpm storybook     # View the UI using Storybook
pnpm build         # Build the library (generate dist)

👦 Top contributors

0.0.1-alpha.10

5 months ago

0.0.1-alpha.9

5 months ago

0.0.1-alpha.8

5 months ago

0.0.1-alpha.7

5 months ago

0.0.1-alpha.6

5 months ago

0.0.1-alpha.5

5 months ago

0.0.1-alpha.4

5 months ago

0.0.1-alpha.3

6 months ago

0.0.1-alpha.2

6 months ago

0.0.1-alpha.1

6 months ago

0.0.1-alpha.0

6 months ago