How frappe/gantt works
Project type and purpose
• This is an open‑source, frontend JavaScript library (“Frappe Gantt”) for rendering customizable Gantt charts in the browser. It’s not a full‑stack app but a component library that provides an embeddable Gantt chart widget.
File structure
• Top‑level:
• styles under src/styles – three theme CSS files
• builder/ – a small demo harness (demo.js, demo.css) used to showcase the library
• tests/ – unit tests for utility functions
• index.html, vite.config.js, package.json, build and config files – build, packaging, CI (publish.yml)
Key insights from README
• The library exports a Gantt class (new Gantt(...)) that takes a container selector and an array of tasks.
• It’s built to be framework‑agnostic (vanilla JS + CSS + SVG).
Main components
a. Core Modules (in src/):
• Gantt Class (index.js) – orchestrator, public API
• Bar Renderer (bar.js) – draws task bars
• SVG Utilities (svg_utils.js) – helper for SVG element creation/manipulation
• Date Utilities (date_utils.js) – date math (intervals, diff, formatting)
• Popup Manager (popup.js) – event handling + dynamic popup generation
• Defaults & Configuration (defaults.js) – default options & override logic
• CSS Themes (dark.css, light.css, gantt.css) – styling layers
b. Build & Packaging
• Vite (vite.config.js) – bundles and outputs ESM and UMD artifacts
• builder/ – demo harness showing integration example
• CI/CD (publish.yml) – on‑push publishing to npm/CDN
c. Tests
• date_utils.test.js – ensures time calculations are correct
Relationships and interactions
• Build pipeline: src/ → Vite → dist/frappe-gantt.umd.js + dist/frappe-gantt.esm.js + CSS → published to npm or CDN
• Demo harness: index.html + builder/demo.js/css imports the distributed bundle to illustrate usage
Architectural patterns & design principles
• Modular design: each renderer and utility is encapsulated in its own module
• Single Responsibility: date logic, rendering logic, popup logic separated
• Plugin‑style configuration: defaults.js merges with user options to customize behavior
• Build‑time bundling for universal module definition (UMD) and ESM