Skip to content

Commit 6383859

Browse files
committed
Used better space management
1 parent 35a60f8 commit 6383859

1 file changed

Lines changed: 50 additions & 20 deletions

File tree

script.js

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -257,38 +257,68 @@ async function renderProblemPage(platform, problemName) {
257257
</a>
258258
</div>
259259
260-
<h1 class="page-title">${pageTitle}</h1>
261-
<p class="page-subtitle">${platformTitle}${platform === 'vicutils' ? ' Script' : ' Problem Solution'}</p>
260+
<div class="content-wrapper">
261+
<h1 class="page-title">${pageTitle}</h1>
262+
<p class="page-subtitle">${platformTitle}${platform === 'vicutils' ? ' Script' : ' Problem Solution'}</p>
262263
`;
263264

264-
if (problem.hasPng && problem.pngFiles.length > 0) {
265-
pageContent += `<div class="images-grid">`;
265+
// Use side-by-side layout if there's exactly 1 image and code
266+
const useSideBySide = problem.hasPng && problem.pngFiles.length === 1 && pythonCode;
267+
268+
if (useSideBySide) {
269+
pageContent += `<div class="side-by-side-layout">`;
266270

267-
problem.pngFiles.forEach((pngFile, index) => {
268-
const imageUrl = `${platform}/${problem.name}/${pngFile.name}`;
269-
const caption = problem.pngFiles.length > 1 ? `Solution Step ${index + 1}` : 'Solution Visualization';
270-
271-
pageContent += `
272-
<div class="image-container">
273-
<img src="${imageUrl}" alt="${caption}" loading="lazy">
274-
<div class="image-caption">${caption}</div>
275-
</div>
276-
`;
277-
});
271+
// Image side
272+
const pngFile = problem.pngFiles[0];
273+
const imageUrl = `${platform}/${problem.name}/${pngFile.name}`;
274+
pageContent += `
275+
<div class="image-container">
276+
<img src="${imageUrl}" alt="Solution Visualization" loading="lazy">
277+
<div class="image-caption">Solution Visualization</div>
278+
</div>
279+
`;
278280

279-
pageContent += `</div>`;
280-
}
281-
282-
if (pythonCode) {
281+
// Code side
283282
pageContent += `
284283
<div class="code-section">
285284
<h3>Python ${platform === 'vicutils' ? 'Script' : 'Solution'}</h3>
286285
<div class="code-content"><pre>${escapeHtml(pythonCode)}</pre></div>
287286
</div>
288287
`;
288+
289+
pageContent += `</div>`;
290+
} else {
291+
// Regular stacked layout for multiple images or no code
292+
if (problem.hasPng && problem.pngFiles.length > 0) {
293+
const gridClass = problem.pngFiles.length === 1 ? 'images-grid single-image' : 'images-grid';
294+
pageContent += `<div class="${gridClass}">`;
295+
296+
problem.pngFiles.forEach((pngFile, index) => {
297+
const imageUrl = `${platform}/${problem.name}/${pngFile.name}`;
298+
const caption = problem.pngFiles.length > 1 ? `Solution Step ${index + 1}` : 'Solution Visualization';
299+
300+
pageContent += `
301+
<div class="image-container">
302+
<img src="${imageUrl}" alt="${caption}" loading="lazy">
303+
<div class="image-caption">${caption}</div>
304+
</div>
305+
`;
306+
});
307+
308+
pageContent += `</div>`;
309+
}
310+
311+
if (pythonCode) {
312+
pageContent += `
313+
<div class="code-section">
314+
<h3>Python ${platform === 'vicutils' ? 'Script' : 'Solution'}</h3>
315+
<div class="code-content"><pre>${escapeHtml(pythonCode)}</pre></div>
316+
</div>
317+
`;
318+
}
289319
}
290320

291-
pageContent += `</div>`;
321+
pageContent += `</div></div>`;
292322

293323
main.innerHTML = pageContent;
294324
hljs.highlightAll();

0 commit comments

Comments
 (0)