An open API service indexing awesome lists of open source software.

https://github.com/ritikrk96/react-flow-task

Interactive drag-and-drop board built with React Flow. Allows only valid Block A β†’ Block B connections, custom context menu, and live preview.
https://github.com/ritikrk96/react-flow-task

drag-and-drop flow-editor frontend-task interaction-board react reactflow tailwind

Last synced: 5 months ago
JSON representation

Interactive drag-and-drop board built with React Flow. Allows only valid Block A β†’ Block B connections, custom context menu, and live preview.

Awesome Lists containing this project

README

          

# πŸš€ React Flow Interaction Board

This project is a task-based implementation demonstrating the use of **React**, **React Flow**, **Tailwind CSS**, and **Vite** to build a clean and responsive drag-and-drop interaction board.

> βœ… **Live Demo:** [https://ritik.lancway.com](https://ritik.lancway.com)

---

## πŸ“‹ Task Objectives

I was assigned a frontend developer task to build an interactive UI that fulfills the following:

- πŸ“¦ Show a draggable panel with `Block A` and `Block B`.
- 🧲 Allow dragging blocks into a central React Flow canvas.
- πŸ”— Only allow valid connections: `Block A β†’ Block B`.
- 🚫 Prevent invalid connections like `Block B β†’ Block A`.
- πŸ–±οΈ Show a custom context menu with β€œHello World” on right-click.

---

## 🎯 Additional Features Implemented

- 🎨 Tailwind-styled blocks with color coding:
- Blue β†’ Block A
- Green β†’ Block B
- πŸ”Œ Animated connections (visually enhance data flow)
- πŸ—ΊοΈ MiniMap, Zoom Controls, and Background Grid
- 🌐 Deployed on Hostinger: [https://ritik.lancway.com](https://ritik.lancway.com)

---

## πŸ“ Project Structure

```

src/
β”œβ”€β”€ components/
β”‚ β”œβ”€β”€ FlowCanvas.jsx // Main board & logic
β”‚ β”œβ”€β”€ BlockPanel.jsx // Right-side draggable block list
β”‚ └── ContextMenu.jsx // Right-click menu
β”œβ”€β”€ constants/
β”‚ └── blocks.js // JSON-style static block config
β”œβ”€β”€ utils/
β”‚ └── connectionRules.js // Connection validation logic
β”œβ”€β”€ App.jsx
β”œβ”€β”€ main.jsx
└── index.css

````

---

## πŸ§ͺ Installation Steps

```bash
# Clone the repository
git clone https://github.com/RitikRK96/react-flow-task.git
cd react-flow-task

# Install dependencies
npm install

# Run the development server
npm run dev
````

---

## πŸ–₯️ How to Run the App

After running the app with `npm run dev`, visit:

πŸ“ [http://localhost:5173](http://localhost:5173)

You can now drag Block A/B from the right panel into the canvas and connect A β†’ B.

---

## 🧠 Summary of the Solution

The solution leverages React Flow for building node-based interactions and constraints. It includes a right-click custom context menu, strict connection validation (A β†’ B only), and clean layout using TailwindCSS.

The board is responsive, includes animated edges, a MiniMap, and styled block nodes.

---

## 🧱 Notes on Design Decisions

* **React Flow** was used for its powerful node editor and custom connection handling.
* **TailwindCSS** allowed for fast prototyping and clean, utility-first styles.
* Separation of concerns was maintained by using:

* `components/` for UI logic
* `constants/` for static config
* `utils/` for business rules like connection validation

---

## πŸ–ΌοΈ Project Outcome

### 1️⃣ Valid Connection (Block A β†’ Block B)

![Dragging blocks](./src/assets/outcome1.png)

---

### 2️⃣ Invalid Connection (Block B β†’ Block A)

![Invalid connection alert](./src/assets/outcome2.png)

---

### 3️⃣ Right-click Context Menu

![Context menu](./src/assets/outcome3.png)

---