Skip to content

Commit

Permalink
fix(UI): improve dependency graph node rendering (#937)
Browse files Browse the repository at this point in the history
Fixes #915
  • Loading branch information
EGAMAGZ authored Feb 6, 2025
1 parent e4f2d55 commit aedc70d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions frontend/routes/package/(_islands)/DependencyGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function renderDependency(
content = `${tooltip}\n${
dependency.entrypoints.map((entrypoint) => {
if (entrypoint == ".") {
return "<I>default entrypoint</I>";
return "<i>default entrypoint</i>";
} else {
return entrypoint;
}
Expand All @@ -262,11 +262,22 @@ function renderDependency(
break;
}

const renderAttributeValue = (content?: string) => {
if (!content) return content;

const hasHTMLTag = /<i>(.+?)<\/i>/.test(content);
if (hasHTMLTag) {
const htmlContent = content.replace(/\n/g, "<br/>");
return `<${htmlContent}>`;
}
return `"${content}"`;
};

return `[${
Object
.entries({ href, tooltip, label: content, color })
.filter(([_, v]) => v)
.map(([k, v]) => `${k}="${v}"`)
.map(([k, v]) => `${k}=${renderAttributeValue(v)}`)
.join(", ")
}]`;
}
Expand Down

0 comments on commit aedc70d

Please sign in to comment.