Map: a Lines setting for curved or right-angled connections
Both map views can draw their lines as right-angled runs with rounded corners instead of curves; the choice is remembered per browser. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
939ebf8d83
commit
2986734196
7 files changed
+191
-5
No files matched your search
@@ -4,6 +4,8 @@ import { api, type DependencyGraph, type DependencyGraphNode } from "../api/clie
|
||||
import { ErrorNotice } from "./Notice";
|
||||
import { PageSkeleton } from "./Skeleton";
|
||||
import { readableError } from "../utils/errors";
|
||||
import MapLinesToggle, { useMapLineStyle } from "../components/MapLinesToggle";
|
||||
import { edgePath } from "../utils/mapLines";
|
||||
|
||||
const NODE_W = 200;
|
||||
const NODE_H = 46;
|
||||
@@ -88,6 +90,7 @@ const names = (graph: DependencyGraph, keys: Iterable<string>) => [...keys].map(
|
||||
* hovering does the same for a moment. This is the answer to "what breaks if I reboot this?" before doing it.
|
||||
*/
|
||||
export default function DependencyMap() {
|
||||
const [lineStyle] = useMapLineStyle();
|
||||
const [graph, setGraph] = useState<DependencyGraph | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
// From the command palette ("What depends on …?"): start with that box picked.
|
||||
@@ -127,6 +130,7 @@ export default function DependencyMap() {
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="card-body map-scroll">
|
||||
<MapLinesToggle />
|
||||
<div className="map-canvas" style={{ width: view.width, height: view.height }}>
|
||||
<svg className="map-lines" width={view.width} height={view.height} aria-hidden="true">
|
||||
{graph.edges.map((e) => {
|
||||
@@ -137,14 +141,13 @@ export default function DependencyMap() {
|
||||
const y1 = a.y + NODE_H / 2;
|
||||
const x2 = b.x;
|
||||
const y2 = b.y + NODE_H / 2;
|
||||
const mid = (x1 + x2) / 2;
|
||||
let cls = "map-edge";
|
||||
if (sets && active) {
|
||||
const downPath = (e.from === active || sets.down.has(e.from)) && sets.down.has(e.to);
|
||||
const upPath = (e.to === active || sets.up.has(e.to)) && sets.up.has(e.from);
|
||||
cls = downPath ? "map-edge map-edge-down" : upPath ? "map-edge map-edge-up" : "map-edge map-dim";
|
||||
}
|
||||
return <path key={`${e.from}>${e.to}`} d={`M${x1},${y1} C${mid},${y1} ${mid},${y2} ${x2},${y2}`} className={cls} fill="none" strokeDasharray={e.kind !== "written" ? "5 4" : undefined} />;
|
||||
return <path key={`${e.from}>${e.to}`} d={edgePath(x1, y1, x2, y2, lineStyle)} className={cls} fill="none" strokeDasharray={e.kind !== "written" ? "5 4" : undefined} />;
|
||||
})}
|
||||
</svg>
|
||||
{[...view.placed.values()].map((n) => (
|
||||
|
||||
Reference in new issue
Block a user