-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ui): Enhance workflow designer background with dot grid
Replace the simple linear grid background with a more sophisticated dot-based grid system that dynamically adjusts to container size. The implementation uses intersection points with small circles at grid junctions, creating a more polished visual appearance for the workflow designer canvas. - Remove commented out background code - Add responsive grid calculation based on container dimensions - Implement dot intersections with proper styling and positioning - Maintain radial gradient overlay for depth effect
- Loading branch information
1 parent
8d15fad
commit 9b4b245
Showing
2 changed files
with
73 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 73 additions & 12 deletions
85
internal-packages/workflow-designer-ui/src/ui/background.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,78 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
const gridWidth = "0.3px"; | ||
const gridSize = 22; | ||
const ellipseSize = 4; | ||
|
||
export function Background() { | ||
const [intersections, setIntersections] = useState< | ||
{ x: number; y: number }[] | ||
>([]); | ||
|
||
useEffect(() => { | ||
// Calculate grid dimensions based on container size | ||
const calculateIntersections = () => { | ||
const container = document.getElementById("grid-container"); | ||
if (!container) return; | ||
|
||
const width = container.clientWidth; | ||
const height = container.clientHeight; | ||
|
||
const horizontalLines = Math.floor(height / gridSize) + 1; | ||
const verticalLines = Math.floor(width / gridSize) + 1; | ||
|
||
const points: { x: number; y: number }[] = []; | ||
|
||
// Calculate all intersection points | ||
for (let y = 0; y < horizontalLines; y++) { | ||
for (let x = 0; x < verticalLines; x++) { | ||
points.push({ | ||
x: x * gridSize, | ||
y: y * gridSize, | ||
}); | ||
} | ||
} | ||
|
||
setIntersections(points); | ||
}; | ||
|
||
calculateIntersections(); | ||
window.addEventListener("resize", calculateIntersections); | ||
|
||
return () => { | ||
window.removeEventListener("resize", calculateIntersections); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className="relative w-full h-full bg-black-900" | ||
style={{ | ||
backgroundImage: ` | ||
linear-gradient(to right, hsl(from var(--color-white-800) h s l / 0.1) 1px, transparent 1px), | ||
linear-gradient(to bottom, hsl(from var(--color-white-800) h s l / 0.1) 1px, transparent 1px) | ||
`, | ||
backgroundSize: "20px 20px", | ||
backgroundPosition: "0 0", | ||
}} | ||
> | ||
<div className="bg-radial from-black-200/0 to-black-800/100 w-hull h-full"/> | ||
<div className="relative w-full h-full"> | ||
<div | ||
id="grid-container" | ||
className="absolute inset-0" | ||
style={{ | ||
backgroundImage: ` | ||
linear-gradient(to right, hsl(from var(--color-white-950) h s l / 0.3) ${gridWidth}, transparent ${gridWidth}), | ||
linear-gradient(to bottom, hsl(from var(--color-white-950) h s l / 0.3) ${gridWidth}, transparent ${gridWidth}) | ||
`, | ||
backgroundSize: `${gridSize}px ${gridSize}px`, | ||
}} | ||
> | ||
{intersections.map((point, index) => ( | ||
<div | ||
// biome-ignore lint/suspicious/noArrayIndexKey: for internal use | ||
key={index} | ||
className="absolute bg-white-950/30 rounded-full transform -translate-x-1/2 -translate-y-1/2" | ||
style={{ | ||
width: `${ellipseSize}px`, | ||
height: `${ellipseSize}px`, | ||
left: `${point.x}px`, | ||
top: `${point.y}px`, | ||
}} | ||
/> | ||
))} | ||
</div> | ||
|
||
<div className="absolute w-full h-full bg-radial-[31.95%_31.95%_at_50%_50%] from-[rgba(1,4,26,0.20)] to-[rgba(1,4,26,0.80)] w-full h-full" /> | ||
</div> | ||
); | ||
} |