Skip to content

Commit 900bcc4

Browse files
committed
feat(dependencies-of): Limit graph scaling to 2x
If there's a single module, it doesn't need to be friggen' huge
1 parent 205205e commit 900bcc4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

feat/dependencies-of/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ async function serveHtmlGraphPage(req: Request, modUrl: string, modSlug: string,
117117
.then(dotProc => dotProc.captureAllOutput())
118118
.then(raw => {
119119
const fullSvg = new TextDecoder().decode(raw);
120+
const attrs = [`id="graph"`];
121+
const svgWidth = fullSvg.match(/viewBox="(?:([0-9.-]+) ){3}/)?.[1];
122+
if (svgWidth) attrs.push(`style="max-width: ${parseInt(svgWidth)*2}px;"`);
120123
return fullSvg
121124
.slice(fullSvg.indexOf('<!--'))
122-
.replace(/<svg width="[^"]+" height="[^"]+"/, '<svg id="graph"');
125+
.replace(/<svg width="[^"]+" height="[^"]+"/, '<svg '+attrs.join(' '));
123126
})
124127

125128
).catch(err => {

public/global.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ input.url {
4242
svg#graph {
4343
grid-area: graph;
4444
max-height: 100%;
45+
justify-self: center;
4546
}
4647
#graph text {
4748
fill: #111;

0 commit comments

Comments
 (0)