Skip to content

Commit d0158fe

Browse files
committed
feat: add size preview
1 parent ab01a16 commit d0158fe

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/pages/index.astro

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { presets } from "../components/presets.ts";
4444
id="preview-container"
4545
style="background-color: #f5f5f5;"
4646
>
47-
<div id="icon-wrapper" class="transition-all duration-200 ease-out w-[97%] h-[97%]">
47+
<div id="icon-wrapper" class="transition-all duration-300 ease-out w-[97%] h-[97%] origin-center" style="transform: scale(1);">
4848
<APatchIcon id="apatch-icon" color="#3ddc84" />
4949
</div>
5050
</div>
@@ -329,12 +329,27 @@ import { presets } from "../components/presets.ts";
329329
sizeInput.value = String(exportSize);
330330
sizeDisplay.textContent = String(exportSize);
331331

332+
updatePreviewScale();
333+
332334
document.querySelectorAll(".size-chip").forEach((chip) => {
333335
const chipSize = Number(chip.dataset.size);
334336
chip.dataset.active = chipSize === exportSize ? "true" : "false";
335337
});
336338
}
337339

340+
function updatePreviewScale() {
341+
const iconWrapper = document.getElementById("icon-wrapper");
342+
if (!iconWrapper) return;
343+
344+
const minSize = 64;
345+
const maxSize = 2048;
346+
const minScale = 0.5;
347+
const maxScale = 2.0;
348+
349+
const scale = minScale + ((exportSize - minSize) / (maxSize - minSize)) * (maxScale - minScale);
350+
iconWrapper.style.transform = `scale(${scale.toFixed(2)})`;
351+
}
352+
338353
function getPresetButtons() {
339354
return Array.from(document.querySelectorAll(".preset-btn"));
340355
}
@@ -569,5 +584,6 @@ import { presets } from "../components/presets.ts";
569584
});
570585

571586
updateExportSize(exportSize);
587+
updatePreviewScale();
572588
updateColor(currentColor);
573589
</script>

0 commit comments

Comments
 (0)