How bitnoise/react-scheduler works
Project Type & Purpose
• This is an open-source, front-end React/TypeScript component library (“@bitnoise/react-scheduler”) for rendering ultra-fast, lightweight Gantt-style charts in React apps.
• It exposes a single <Scheduler> component, consumes props (data, config, callbacks), and renders a scheduler grid on an HTML canvas plus ancillary UI (side panel, buttons, tooltips).
File Structure
• Top-level files (package.json, vite.config.ts, Dockerfile, tsconfig.json): indicate a packaged library built with Vite + TypeScript.
• src/ holds all source code:
– context/ : CalendarProvider & LocaleProvider using React Context API for global state (current date range, zoom, i18n).
– utils/ : pure functions for date calculations and low-level canvas drawing routines (drawGrid, drawHeaderRows, drawRow, etc.).
– hooks/, assets/, styles.ts, constants.ts: support modules and global styles.
README Insights
• The README confirms it’s a React component library, lists props, config options (zoom, pagination, lang, theme), and shows example usage.
a. Main Components & Layers
• Consumer App (importing <Scheduler>).
• Scheduler Entry Component
• Context Providers:
– LocaleProvider (i18n strings, dayjs locale)
– CalendarProvider (date range, zoom, filter state)
• UI Components:
– Calendar
– Header (Topbar: Prev/Next/Today/View controls)
– Grid (canvas for weeks/days/hours)
– Tiles (positioned overlays or drawn on canvas)
– ConfigPanel (filter toggles)
– Loader, EmptyBox (state placeholders)
– PaginationButton, Toggle, Tooltip
• Utils & Helpers:
– Date functions (getDatesRange, getCols, getOccupancy…)
b. Relationships & Data Flow
1. Consumer App → <Scheduler> (props: data[], isLoading, callbacks, config)
2. <Scheduler> wraps:
– <LocaleProvider> & <CalendarProvider> (inject context)
– UI Components consume context and props.
3. On mount & on scroll/zoom/filter: CalendarProvider updates date range → triggers re-render.
4. Grid & Header call utils to compute cell coordinates & issue Canvas API calls (drawing).
5. LeftColumn renders React DOM elements for row labels.
6. Tiles: either drawn on canvas or positioned overlays (React elements) using coords from utils.
7. User interactions (click on tile/row/filter) → fire callback props (onTileClick, onItemClick, onFilterData, onClearFilterData).
c. Architectural Patterns & Principles
• Component composition (small reusable React components).
• Separation of concerns: UI layer vs rendering logic (canvas utils).
• Context API for global config & state (zoom, locale, date range).
• Functional utils for pure computations (date math, layout).
d. Relevant Technologies
• React + TypeScript
• Vite bundler
• Context API, custom hooks
• HTML Canvas API for high-performance rendering
• dayjs for date manipulations
• styled-components (CSS-in-JS)
Be Detailed & Capture Essentials
1. Consumer integration
2. Core component tree & context
3. Utility/rendering engine
• Build/bundle assets (vite.config.ts) as part of packaging.