Skip to content

ei-shadi/Block_Graph

Repository files navigation

🧩 Block Graph ---> [Draggable Block Tree]

A dynamic and interactive block tree where blocks can be added, dragged, and connected with parent-child dashed lines.


πŸ–₯️ Project Overview

This project demonstrates a draggable block tree UI built in React with Tailwind CSS. Users can:

  • Add new blocks dynamically.
  • Drag blocks around freely.
  • See dashed lines connecting each block to its parent, updating automatically as blocks move.

⚑ Features

  • 🎯 Random Initial Position: Blocks appear at random positions on page load.
  • βž• Add Child Blocks: Each block has a + button to create child blocks.
  • βœ‹ Drag & Drop: Blocks can be moved around by mouse drag.
  • πŸ“ Dynamic Connecting Lines: Dashed lines connect parent and child blocks and update as blocks move.
  • 🧩 Fully Interactive: Supports multiple levels of block hierarchy.

πŸ› οΈ Tech Stack

Feature Technology
UI React.js
Styling Tailwind CSS
State Management React useState / useRef

πŸ§‘β€πŸ’» User Roles

  • User: Can interact with blocks, add child blocks, and drag them around.

πŸ–ΌοΈ Interface Snapshots

Draggable Block Tree Screenshot

πŸš€ Getting Started

1️⃣ Clone the Repository

git clone https://github.com/ei-shadi/Block_Graph.git
cd Block_Graph

2️⃣ Install Dependencies

npm install

3️⃣ Start the Development Server

npm run dev

Open http://localhost:5173 to view it in your browser.


πŸ—‚οΈ Project Structure

src/
β”œβ”€ components/
β”‚  β”œβ”€ Block.jsx          # Block component with + button & drag logic
β”‚  β”œβ”€ ConnectionLine.jsx # Dashed line between parent and child
β”œβ”€ utils/
β”‚  └─ randomPosition.js  # Utility for generating random coordinates
β”œβ”€ App.jsx               # Main component managing state of blocks

πŸ“Œ Notes

  • Blocks’ positions are managed using React state and refs.
  • Connecting lines update automatically based on parent-child positions.
  • Tailwind CSS handles all styling; feel free to customize for your theme.

πŸ”— Live Demo

View Live Demo


πŸ’» License

This project is licensed under the Fringecore License.

About

Block Graph ---> A dynamic and interactive block tree where blocks can be added, dragged, and connected with parent-child dashed lines.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors