Skip to content

Commit 3ab9247

Browse files
committed
Improved render style to prevent sliding window from breaking on browser zoom
1 parent d145111 commit 3ab9247

File tree

1 file changed

+62
-71
lines changed

1 file changed

+62
-71
lines changed

src/render/src/App.svelte

Lines changed: 62 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,7 @@ async function createCFG(params: Params): Promise<CFG> {
281281
}
282282
}
283283
284-
let functionAndCFGMetadata: FunctionAndCFGMetadata = {
285-
functionData: { name: "", lineCount: 0, language: undefined },
286-
cfgGraphData: { nodeCount: 0, edgeCount: 0, cyclomaticComplexity: 0 },
287-
};
284+
let functionAndCFGMetadata: FunctionAndCFGMetadata | undefined;
288285
289286
function updateMetadata(func: SyntaxNode, language: Language, CFG: CFG) {
290287
// Update function metadata
@@ -391,7 +388,7 @@ onMount(() => {
391388
>Open Code</button>
392389
<button onclick={saveSVG}>Download SVG</button>
393390
</div>
394-
{#if rawSVG}
391+
{#if functionAndCFGMetadata}
395392
<!-- Metadata display -->
396393
{#if Object.values(showMetadata).some(value => value)}
397394
<div class="metadata" class:panel-open={isPanelOpen}>
@@ -432,120 +429,114 @@ onMount(() => {
432429
.controlsContainer {
433430
position: fixed;
434431
display: flex;
435-
justify-content: right;
432+
justify-content: flex-end;
436433
width: 100%;
437-
z-index: 1000;
434+
top: 0;
435+
right: 0;
436+
z-index: 1002;
438437
}
439438
440439
.controls {
441440
margin: 1em;
442441
}
443-
442+
444443
.metadata {
445-
margin: 0;
446-
padding: 1em;
447444
position: fixed;
448-
top: 5%;
449-
right: 300px;
445+
top: 4em;
446+
right: 18.5em;
447+
padding: 1em;
448+
background-color: var(--metadata-bg);
450449
transition: right 0.2s ease;
451-
text-align: left;
452-
background-color: var(--metadata-bg, rgba(30, 30, 30, 0.7));
453-
max-width: 500px;
454450
}
455-
451+
456452
.metadata:not(.panel-open) {
457-
right: 25px;
453+
right: 2.5em;
458454
}
459-
455+
460456
.metadata span {
461457
display: block;
462-
margin-top: 0.5em;
463-
margin-bottom: 0.5em;
458+
margin: 0.5em;
464459
white-space: nowrap;
465460
overflow: hidden;
466-
text-overflow: ellipsis;
467-
color: var(--text-color, gray);
468-
font-size: 16px;
461+
text-overflow: ellipsis;
462+
color: var(--text-color);
463+
font-size: 1em;
469464
}
470-
465+
471466
.panel-toggle {
472467
position: fixed;
473-
top: 5%;
474-
right: 0;
475-
z-index: 1; /* IMPORTANT */
476-
width: 25px;
477-
height: 60px;
468+
top: 4em;
469+
z-index: 1001;
470+
width: 2em;
471+
height: 4em;
478472
background-color: var(--toggle-bg);
479-
color: var(--toggle-color, white);
473+
color: var(--toggle-color);
480474
border: none;
481-
cursor: pointer;
482-
font-size: 16px;
475+
font-size: 1em;
483476
}
484-
477+
478+
.panel-toggle:hover {
479+
cursor: pointer;
480+
}
481+
485482
.control-panel {
486483
position: fixed;
487-
font-size: 1em;
488-
top: 5%;
489-
right: -20em;
490-
width: 18em;
491-
height: 36%;
492-
background-color: var(--panel-bg, rgba(30, 30, 30, 0.7));
493-
color: var(--panel-text, white);
494-
transition: right 0.2s ease;
495-
padding: 1.25em;
484+
top: 4em;
485+
right: -20em;
486+
width: 18em;
487+
padding: 1.25em;
488+
background-color: var(--panel-bg);
489+
color: var(--panel-text);
496490
box-sizing: border-box;
497-
box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
491+
font-size: 1em;
492+
transition: right 0.2s ease;
498493
}
499-
494+
500495
.control-panel.open {
501496
right: 0;
502497
}
503498
504499
.control-panel h3 {
505-
margin-top: 0px;
506-
margin-bottom: 20px;
500+
margin: 0 0 1.25em;
507501
font-size: 1.5em;
508-
color: var(--panel-heading, #fff);
502+
color: var(--panel-heading);
509503
}
510-
504+
511505
.control-panel label {
512-
display: block;
513-
margin-bottom: 15px;
506+
display: flex;
507+
align-items: center;
508+
gap: 0.5em;
509+
margin-bottom: 1em;
514510
cursor: pointer;
515-
user-select: none;
516-
}
517-
518-
.control-panel input[type="checkbox"] {
519-
margin-right: 10px;
520511
}
521-
512+
522513
.svgContainer {
523514
display: flex;
524515
flex-direction: column;
525516
align-items: center;
526517
justify-content: center;
527-
width: 100dvw;
528-
height: 100dvh;
518+
width: 100%;
519+
height: 100vh;
520+
overflow: hidden;
529521
}
530-
522+
531523
:global(body), :global(body[data-theme="dark"]) {
532524
--text-color: white;
533525
--panel-bg: rgba(30, 30, 30, 0.7);
534-
--panel-text: #fff;
535-
--panel-heading: #fff;
526+
--panel-text: white;
527+
--panel-heading: white;
536528
--toggle-bg: #555;
537-
--toggle-color: #fff;
538-
--metadata-bg: rgba(30, 30, 30, 0.7);
529+
--toggle-color: white;
530+
--metadata-bg: rgba(30, 30, 30, 0.7);
539531
}
540-
532+
541533
:global(body[data-theme="light"]) {
542-
--text-color: #000000;
534+
--text-color: black;
543535
--panel-bg: rgba(240, 240, 240, 0.9);
544-
--panel-text: #000000;
545-
--panel-heading: #000000;
546-
--toggle-bg: rgb(170, 169, 169);
547-
--toggle-color: #000000;
536+
--panel-text: black;
537+
--panel-heading: black;
538+
--toggle-bg: #aaa;
539+
--toggle-color: black;
548540
--metadata-bg: rgba(240, 240, 240, 0.9);
549541
}
550-
</style>
551-
542+
</style>

0 commit comments

Comments
 (0)