To achieve the functionality where multi-column blocks can be dragged and dropped as a single entity, ensuring that all their columns remain intact and move together within the graph, you'll need to make several adjustments to your current implementation. Below, I'll guide you through the necessary steps and provide code snippets to help you implement this feature effectively.
1. Understanding the Current Structure
From your provided code, here's a brief overview:
- App.js: Manages the state of graph blocks and handles adding and moving blocks.
- Graph.js: Renders the graph and acts as a drop target.
- GraphBlock.js: Represents individual blocks within the graph.
- WorkoutBlocks.js: Contains draggable workout blocks, some of which have multiple columns.
2. Key Objectives
- Multi-Column Handling: Ensure that blocks with multiple columns are treated as single entities when dragged and dropped.
- Maintain Integrity: All columns within a multi-column block should remain synchronized during movement.
- Visual Representation: The graph should visually reflect multi-column blocks accurately.
3. Step-by-Step Implementation
A. Update constants.js
Ensure you have a centralized location for your item types. If you don't have this file yet, create one.
// constants.js
export const ItemTypes = {
WORKOUT_BLOCK: 'WORKOUT_BLOCK',
GRAPH_BLOCK: 'GRAPH_BLOCK',
};
B. Modify WorkoutBlocks.js
Ensure that each WorkoutBlock correctly represents its type and structure, especially for multi-column blocks.
// WorkoutBlocks.js
import React from 'react';
import { useDrag } from 'react-dnd';
import { ItemTypes } from './constants';
import { FiInfo } from 'react-icons/fi';
const WorkoutBlock = ({ type, columns, height }) => {
const [{ isDragging }, drag] = useDrag({
type: ItemTypes.WORKOUT_BLOCK,
item: { type, columns, height }, // Pass columns data
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
const renderColumns = () => {
return columns.map((col, idx) => (
<div
key={idx}
className={`flex-1`}
style={{ height: `${col.height}%`, background: col.color }}
></div>
));
};
return (
<div
ref={drag}
className={`relative bg-gray-200 rounded-lg overflow-hidden h-20 cursor-pointer ${
isDragging ? 'opacity-50' : 'opacity-100'
}`}
>
<div className="flex h-full">{renderColumns()}</div>
</div>
);
};
const WorkoutBlocks = () => {
const workoutBlocks = [
{
type: 'block50',
height: 50,
columns: [{ height: 50, color: '#4339F280' }],
},
{
type: 'block75',
height: 75,
columns: [{ height: 75, color: '#4339F280' }],
},
{
type: 'block30',
height: 30,
columns: [{ height: 30, color: '#4339F280' }],
},
{
type: 'block60_40',
height: 60,
columns: [
{ height: 60, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
],
},
{
type: 'block80_60_40_20',
height: 80,
columns: [
{ height: 80, color: '#4339F280' },
{ height: 60, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
{ height: 20, color: '#4339F280' },
],
},
{
type: 'block20_40_60_80',
height: 20,
columns: [
{ height: 20, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
{ height: 60, color: '#4339F280' },
{ height: 80, color: '#4339F280' },
],
},
];
return (
<div className="bg-white p-6 rounded-lg shadow-md max-w-sm w-full">
<div className="flex justify-between items-center mb-3">
<h2 className="text-lg font-semibold">Click or drag the blocks to build workout</h2>
<FiInfo className="text-gray-400 text-2xl" />
</div>
<hr className="border-gray-300 mb-4" />
<div className="grid grid-cols-2 gap-3">
{workoutBlocks.map((block, index) => (
<WorkoutBlock
key={index}
type={block.type}
height={block.height}
columns={block.columns}
/>
))}
</div>
</div>
);
};
export default WorkoutBlocks;
Explanation:
- Pass
columns Data: Each WorkoutBlock now receives a columns prop, which is an array representing the individual columns within the block.
- Render Columns: The
renderColumns function dynamically renders each column based on the columns data.
C. Update GraphBlock.js
Modify GraphBlock to handle multi-column blocks as single entities.
// GraphBlock.js
import React, { useRef } from 'react';
import { useDrag, useDrop } from 'react-dnd';
import { ItemTypes } from './constants';
const GraphBlock = ({
id,
index,
block,
moveBlock,
removeBlock,
addBlockToGraph,
totalBlocks,
}) => {
const ref = useRef(null);
const [{ isDragging }, drag] = useDrag({
type: ItemTypes.GRAPH_BLOCK,
item: { type: ItemTypes.GRAPH_BLOCK, id, index },
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
const [, drop] = useDrop({
accept: [ItemTypes.GRAPH_BLOCK, ItemTypes.WORKOUT_BLOCK],
hover(item, monitor) {
if (!ref.current) return;
if (item.type === ItemTypes.GRAPH_BLOCK) {
const dragIndex = item.index;
const hoverIndex = index;
if (dragIndex === hoverIndex) return;
// Determine rectangle on screen
const hoverBoundingRect = ref.current.getBoundingClientRect();
const hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
const clientOffset = monitor.getClientOffset();
const hoverClientX = clientOffset.x - hoverBoundingRect.left;
// Only perform move when the mouse has crossed half of the item's width
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
return;
}
if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
return;
}
moveBlock(dragIndex, hoverIndex);
item.index = hoverIndex;
}
},
drop(item, monitor) {
if (item.type === ItemTypes.WORKOUT_BLOCK) {
const clientOffset = monitor.getClientOffset();
const hoverBoundingRect = ref.current.getBoundingClientRect();
const hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
const hoverClientX = clientOffset.x - hoverBoundingRect.left;
const insertIndex = hoverClientX < hoverMiddleX ? index : index + 1;
addBlockToGraph(item, insertIndex);
}
},
collect: (monitor) => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
drag(drop(ref));
const handleRemove = () => {
removeBlock(id);
};
return (
<div
ref={ref}
className={`relative bg-[#4339F280] rounded cursor-move flex flex-col items-center transition-all duration-200
${isDragging ? 'opacity-50' : 'opacity-100'}
`}
style={{
width: `calc(${100 / totalBlocks}% - 8px)`,
height: `${block.height}%`,
marginRight: index !== totalBlocks - 1 ? '8px' : '0',
}}
>
{/* Remove Button */}
<button
onClick={handleRemove}
className="absolute top-1 right-1 text-red-500 hover:text-red-700 text-xs"
title="Remove Block"
>
×
</button>
{/* Render Columns */}
<div className="flex w-full h-full">
{block.columns.map((col, idx) => (
<div
key={idx}
className="flex-1"
style={{ height: `${col.height}%`, background: col.color }}
></div>
))}
</div>
</div>
);
};
export default GraphBlock;
Explanation:
- Unified Drag Type: Use
ItemTypes.GRAPH_BLOCK for entire blocks, regardless of their internal columns.
- Render Columns Inside GraphBlock: Each
GraphBlock renders its own columns based on the block.columns data, ensuring that multi-column blocks are displayed correctly.
- Drag Behavior: When dragging a
GRAPH_BLOCK, the entire GraphBlock (including all its columns) is treated as a single entity.
D. Adjust Graph.js
Ensure that the Graph component correctly handles the rendering and dropping of multi-column blocks.
// Graph.js
import React from 'react';
import GraphBlock from './GraphBlock';
import { useDrop } from 'react-dnd';
import { ItemTypes } from './constants';
const Graph = ({ blocks, addBlockToGraph, moveBlock, removeBlock }) => {
const [{ isOver, canDrop }, drop] = useDrop({
accept: [ItemTypes.WORKOUT_BLOCK, ItemTypes.GRAPH_BLOCK],
drop: (item, monitor) => {
if (!monitor.didDrop()) {
if (item.type === ItemTypes.WORKOUT_BLOCK) {
addBlockToGraph(item, blocks.length);
}
}
},
canDrop: () => true,
collect: (monitor) => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
const isActive = isOver && canDrop;
return (
<div
ref={drop}
className={`graph-container relative w-full h-[300px] bg-[#EAEAEA] rounded-lg shadow-md p-4 mb-4 ${
isActive ? 'bg-[#D3D3D3]' : ''
}`}
>
<div className="absolute inset-0 flex items-end space-x-2 px-2">
{blocks.map((block, index) => (
<GraphBlock
key={block.id}
id={block.id}
index={index}
block={block}
moveBlock={moveBlock}
removeBlock={removeBlock}
addBlockToGraph={addBlockToGraph}
totalBlocks={blocks.length}
/>
))}
</div>
{/* X-Axis Labels */}
<div className="absolute bottom-0 w-full flex justify-between text-xs mt-1">
{blocks.map((_, index) => (
<span key={index}>{index + 1} km</span>
))}
</div>
{/* Y-Axis Labels */}
<div className="absolute left-0 top-0 h-full flex flex-col justify-between text-xs mr-1">
<span>100%</span>
<span>75%</span>
<span>50%</span>
<span>25%</span>
<span>0%</span>
</div>
</div>
);
};
export default Graph;
Explanation:
- Accept Multiple Types: The
Graph component now accepts both WORKOUT_BLOCK and GRAPH_BLOCK item types.
- Add Graph Blocks: When a
WORKOUT_BLOCK is dropped onto the graph, it's added as a single GraphBlock, regardless of the number of columns it contains.
E. Update App.js
Ensure that the App component correctly manages the graph blocks, including their columns.
// App.js
import React, { useState, useCallback, useRef } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import Header from './Header';
import WorkoutBlocks from './WorkoutBlocks';
import Graph from './Graph';
import ColumnsList from './ColumnsList';
function App() {
const [graphBlocks, setGraphBlocks] = useState([]);
const idRef = useRef(0);
const addBlockToGraph = useCallback((block, index = graphBlocks.length) => {
if (!block || !block.type || typeof block.height !== 'number') {
console.error('Invalid block:', block);
return;
}
const newBlock = { ...block, id: idRef.current++ };
setGraphBlocks((prevBlocks) => {
const updatedBlocks = [...prevBlocks];
const insertIndex =
index >= 0 && index <= updatedBlocks.length ? index : updatedBlocks.length;
updatedBlocks.splice(insertIndex, 0, newBlock);
return updatedBlocks;
});
}, [graphBlocks.length]);
const moveGraphBlock = useCallback((dragIndex, hoverIndex) => {
setGraphBlocks((prevBlocks) => {
const updatedBlocks = [...prevBlocks];
const [removed] = updatedBlocks.splice(dragIndex, 1);
updatedBlocks.splice(hoverIndex, 0, removed);
return updatedBlocks;
});
}, []);
const removeGraphBlock = useCallback((id) => {
setGraphBlocks((prevBlocks) => prevBlocks.filter((block) => block.id !== id));
}, []);
return (
<DndProvider backend={HTML5Backend}>
<div className="justify-center min-h-screen bg-[#F8F8F8] w-full p-4">
<Header />
{/* Main content */}
<div className="flex justify-between mx-6 my-3 items-start">
{/* Workout blocks card */}
<WorkoutBlocks />
{/* Graph and Columns List */}
<div className="w-full ml-6">
<Graph
blocks={graphBlocks}
addBlockToGraph={addBlockToGraph}
moveBlock={moveGraphBlock}
removeBlock={removeGraphBlock} // Pass remove function
/>
<ColumnsList blocks={graphBlocks} />
</div>
</div>
</div>
</DndProvider>
);
}
export default App;
Explanation:
- Maintain Column Data: When adding a block to the graph, ensure that all its column data is preserved.
- Removal Handling: Pass the
removeBlock function to Graph so that each GraphBlock can remove itself when needed.
F. Ensure ColumnsList.js is Updated
If you have a ColumnsList component that displays the columns, ensure it's compatible with multi-column blocks. Here's a basic example:
// ColumnsList.js
import React from 'react';
const ColumnsList = ({ blocks }) => {
return (
<div className="mt-4">
<h3 className="text-md font-semibold mb-2">Columns List</h3>
<ul className="list-disc list-inside">
{blocks.map((block) => (
<li key={block.id}>
{block.type} - Height: {block.height}%
{block.columns.length > 1 && (
<ul className="list-circle list-inside ml-4">
{block.columns.map((col, idx) => (
<li key={idx}>
Column {idx + 1}: {col.height}% Height
</li>
))}
</ul>
)}
</li>
))}
</ul>
</div>
);
};
export default ColumnsList;
Explanation:
- Display Columns: For blocks with multiple columns, list each column's details.
4. Additional Enhancements
To further improve the user experience and maintainability, consider the following enhancements:
A. Unique Identifiers for Columns
If you need to manage columns individually in the future, assign unique IDs to each column. For now, using the index suffices.
B. Styling Adjustments
Fine-tune the CSS to ensure that multi-column blocks are visually distinct and aligned properly within the graph.
C. Performance Optimization
For larger graphs, consider using virtualization libraries (like react-window) to optimize rendering performance.
D. Feedback During Dragging
Provide visual cues (like highlighting the drop target) to enhance the drag-and-drop experience.
5. Complete Example
Here's a consolidated version of the updated components for clarity:
constants.js
// constants.js
export const ItemTypes = {
WORKOUT_BLOCK: 'WORKOUT_BLOCK',
GRAPH_BLOCK: 'GRAPH_BLOCK',
};
WorkoutBlocks.js
// WorkoutBlocks.js
import React from 'react';
import { useDrag } from 'react-dnd';
import { ItemTypes } from './constants';
import { FiInfo } from 'react-icons/fi';
const WorkoutBlock = ({ type, columns, height }) => {
const [{ isDragging }, drag] = useDrag({
type: ItemTypes.WORKOUT_BLOCK,
item: { type, columns, height },
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
const renderColumns = () => {
return columns.map((col, idx) => (
<div
key={idx}
className={`flex-1`}
style={{ height: `${col.height}%`, background: col.color }}
></div>
));
};
return (
<div
ref={drag}
className={`relative bg-gray-200 rounded-lg overflow-hidden h-20 cursor-pointer ${
isDragging ? 'opacity-50' : 'opacity-100'
}`}
>
<div className="flex h-full">{renderColumns()}</div>
</div>
);
};
const WorkoutBlocks = () => {
const workoutBlocks = [
{
type: 'block50',
height: 50,
columns: [{ height: 50, color: '#4339F280' }],
},
{
type: 'block75',
height: 75,
columns: [{ height: 75, color: '#4339F280' }],
},
{
type: 'block30',
height: 30,
columns: [{ height: 30, color: '#4339F280' }],
},
{
type: 'block60_40',
height: 60,
columns: [
{ height: 60, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
],
},
{
type: 'block80_60_40_20',
height: 80,
columns: [
{ height: 80, color: '#4339F280' },
{ height: 60, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
{ height: 20, color: '#4339F280' },
],
},
{
type: 'block20_40_60_80',
height: 20,
columns: [
{ height: 20, color: '#4339F280' },
{ height: 40, color: '#4339F280' },
{ height: 60, color: '#4339F280' },
{ height: 80, color: '#4339F280' },
],
},
];
return (
<div className="bg-white p-6 rounded-lg shadow-md max-w-sm w-full">
<div className="flex justify-between items-center mb-3">
<h2 className="text-lg font-semibold">Click or drag the blocks to build workout</h2>
<FiInfo className="text-gray-400 text-2xl" />
</div>
<hr className="border-gray-300 mb-4" />
<div className="grid grid-cols-2 gap-3">
{workoutBlocks.map((block, index) => (
<WorkoutBlock
key={index}
type={block.type}
height={block.height}
columns={block.columns}
/>
))}
</div>
</div>
);
};
export default WorkoutBlocks;
GraphBlock.js
// GraphBlock.js
import React, { useRef } from 'react';
import { useDrag, useDrop } from 'react-dnd';
import { ItemTypes } from './constants';
const GraphBlock = ({
id,
index,
block,
moveBlock,
removeBlock,
addBlockToGraph,
totalBlocks,
}) => {
const ref = useRef(null);
const [{ isDragging }, drag] = useDrag({
type: ItemTypes.GRAPH_BLOCK,
item: { type: ItemTypes.GRAPH_BLOCK, id, index },
collect: (monitor) => ({
isDragging: monitor.isDragging(),
}),
});
const [, drop] = useDrop({
accept: [ItemTypes.GRAPH_BLOCK, ItemTypes.WORKOUT_BLOCK],
hover(item, monitor) {
if (!ref.current) return;
if (item.type === ItemTypes.GRAPH_BLOCK) {
const dragIndex = item.index;
const hoverIndex = index;
if (dragIndex === hoverIndex) return;
const hoverBoundingRect = ref.current.getBoundingClientRect();
const hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
const clientOffset = monitor.getClientOffset();
const hoverClientX = clientOffset.x - hoverBoundingRect.left;
if (dragIndex < hoverIndex && hoverClientX < hoverMiddleX) {
return;
}
if (dragIndex > hoverIndex && hoverClientX > hoverMiddleX) {
return;
}
moveBlock(dragIndex, hoverIndex);
item.index = hoverIndex;
}
},
drop(item, monitor) {
if (item.type === ItemTypes.WORKOUT_BLOCK) {
const clientOffset = monitor.getClientOffset();
const hoverBoundingRect = ref.current.getBoundingClientRect();
const hoverMiddleX = (hoverBoundingRect.right - hoverBoundingRect.left) / 2;
const hoverClientX = clientOffset.x - hoverBoundingRect.left;
const insertIndex = hoverClientX < hoverMiddleX ? index : index + 1;
addBlockToGraph(item, insertIndex);
}
},
collect: (monitor) => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
drag(drop(ref));
const handleRemove = () => {
removeBlock(id);
};
return (
<div
ref={ref}
className={`relative bg-[#4339F280] rounded cursor-move flex flex-col items-center transition-all duration-200
${isDragging ? 'opacity-50' : 'opacity-100'}
`}
style={{
width: `calc(${100 / totalBlocks}% - 8px)`,
height: `${block.height}%`,
marginRight: index !== totalBlocks - 1 ? '8px' : '0',
}}
>
{/* Remove Button */}
<button
onClick={handleRemove}
className="absolute top-1 right-1 text-red-500 hover:text-red-700 text-xs"
title="Remove Block"
>
×
</button>
{/* Render Columns */}
<div className="flex w-full h-full">
{block.columns.map((col, idx) => (
<div
key={idx}
className="flex-1"
style={{ height: `${col.height}%`, background: col.color }}
></div>
))}
</div>
</div>
);
};
export default GraphBlock;
Graph.js
// Graph.js
import React from 'react';
import GraphBlock from './GraphBlock';
import { useDrop } from 'react-dnd';
import { ItemTypes } from './constants';
const Graph = ({ blocks, addBlockToGraph, moveBlock, removeBlock }) => {
const [{ isOver, canDrop }, drop] = useDrop({
accept: [ItemTypes.WORKOUT_BLOCK, ItemTypes.GRAPH_BLOCK],
drop: (item, monitor) => {
if (!monitor.didDrop()) {
if (item.type === ItemTypes.WORKOUT_BLOCK) {
addBlockToGraph(item, blocks.length);
}
}
},
canDrop: () => true,
collect: (monitor) => ({
isOver: monitor.isOver(),
canDrop: monitor.canDrop(),
}),
});
const isActive = isOver && canDrop;
return (
<div
ref={drop}
className={`graph-container relative w-full h-[300px] bg-[#EAEAEA] rounded-lg shadow-md p-4 mb-4 ${
isActive ? 'bg-[#D3D3D3]' : ''
}`}
>
<div className="absolute inset-0 flex items-end space-x-2 px-2">
{blocks.map((block, index) => (
<GraphBlock
key={block.id}
id={block.id}
index={index}
block={block}
moveBlock={moveBlock}
removeBlock={removeBlock}
addBlockToGraph={addBlockToGraph}
totalBlocks={blocks.length}
/>
))}
</div>
{/* X-Axis Labels */}
<div className="absolute bottom-0 w-full flex justify-between text-xs mt-1">
{blocks.map((_, index) => (
<span key={index}>{index + 1} km</span>
))}
</div>
{/* Y-Axis Labels */}
<div className="absolute left-0 top-0 h-full flex flex-col justify-between text-xs mr-1">
<span>100%</span>
<span>75%</span>
<span>50%</span>
<span>25%</span>
<span>0%</span>
</div>
</div>
);
};
export default Graph;
App.js
// App.js
import React, { useState, useCallback, useRef } from 'react';
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
import Header from './Header';
import WorkoutBlocks from './WorkoutBlocks';
import Graph from './Graph';
import ColumnsList from './ColumnsList';
function App() {
const [graphBlocks, setGraphBlocks] = useState([]);
const idRef = useRef(0);
const addBlockToGraph = useCallback((block, index = graphBlocks.length) => {
if (!block || !block.type || typeof block.height !== 'number') {
console.error('Invalid block:', block);
return;
}
const newBlock = { ...block, id: idRef.current++ };
setGraphBlocks((prevBlocks) => {
const updatedBlocks = [...prevBlocks];
const insertIndex =
index >= 0 && index <= updatedBlocks.length ? index : updatedBlocks.length;
updatedBlocks.splice(insertIndex, 0, newBlock);
return updatedBlocks;
});
}, [graphBlocks.length]);
const moveGraphBlock = useCallback((dragIndex, hoverIndex) => {
setGraphBlocks((prevBlocks) => {
const updatedBlocks = [...prevBlocks];
const [removed] = updatedBlocks.splice(dragIndex, 1);
updatedBlocks.splice(hoverIndex, 0, removed);
return updatedBlocks;
});
}, []);
const removeGraphBlock = useCallback((id) => {
setGraphBlocks((prevBlocks) => prevBlocks.filter((block) => block.id !== id));
}, []);
return (
<DndProvider backend={HTML5Backend}>
<div className="justify-center min-h-screen bg-[#F8F8F8] w-full p-4">
<Header />
{/* Main content */}
<div className="flex justify-between mx-6 my-3 items-start">
{/* Workout blocks card */}
<WorkoutBlocks />
{/* Graph and Columns List */}
<div className="w-full ml-6">
<Graph
blocks={graphBlocks}
addBlockToGraph={addBlockToGraph}
moveBlock={moveGraphBlock}
removeBlock={removeGraphBlock}
/>
<ColumnsList blocks={graphBlocks} />
</div>
</div>
</div>
</DndProvider>
);
}
export default App;
ColumnsList.js
// ColumnsList.js
import React from 'react';
const ColumnsList = ({ blocks }) => {
return (
<div className="mt-4">
<h3 className="text-md font-semibold mb-2">Columns List</h3>
<ul className="list-disc list-inside">
{blocks.map((block) => (
<li key={block.id}>
{block.type} - Height: {block.height}%
{block.columns.length > 1 && (
<ul className="list-circle list-inside ml-4">
{block.columns.map((col, idx) => (
<li key={idx}>
Column {idx + 1}: {col.height}% Height
</li>
))}
</ul>
)}
</li>
))}
</ul>
</div>
);
};
export default ColumnsList;
6. Testing the Implementation
After implementing the changes:
-
Drag Single-Column Blocks: Ensure that single-column blocks can be dragged and dropped onto the graph and moved within the graph as expected.
-
Drag Multi-Column Blocks: Similarly, drag multi-column blocks (e.g., block60_40, block80_60_40_20) and verify:
- They are added to the graph as single entities.
- All their columns are displayed correctly.
- They can be moved within the graph without separating the columns.
-
Confirm Removal: Test the removal functionality to ensure blocks are deleted correctly.
-
Visual Verification: Ensure that the visual representation aligns with the desired layout, and that multi-column blocks maintain their structure during interactions.
7. Conclusion
By restructuring your components to handle multi-column blocks as single entities and ensuring that both dragging and dropping mechanisms account for the entire block (instead of individual columns), you can achieve the desired functionality. This approach maintains the integrity of multi-column blocks, providing a seamless user experience when building workouts with complex block structures.
Feel free to further customize the styling and behavior to better fit your specific requirements. If you encounter any issues or need further assistance, don't hesitate to ask!