Simplify mobile text label editor

This commit is contained in:
Mikei386
2026-06-22 13:59:11 +02:00
parent e4a7679bc7
commit e880260aa5
4 changed files with 30 additions and 58 deletions
+3 -3
View File
@@ -114,13 +114,13 @@ button.primary {
gap: 8px;
}
.check-row {
.toggle-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}
.check-row label {
.toggle-row label {
display: flex;
align-items: center;
gap: 9px;
@@ -131,7 +131,7 @@ button.primary {
background: #303030;
}
.check-row input {
.toggle-row input {
width: 20px;
min-height: 20px;
}
+5 -13
View File
@@ -1,13 +1,10 @@
const fields = {
text: document.getElementById("mobileText"),
tape: document.getElementById("mobileTape"),
length: document.getElementById("mobileLength"),
autoLength: document.getElementById("mobileAutoLength"),
margin: document.getElementById("mobileMargin"),
font: document.getElementById("mobileFont"),
copies: document.getElementById("mobileCopies"),
align: document.getElementById("mobileAlign"),
cutMode: document.getElementById("mobileCutMode"),
bold: document.getElementById("mobileBold"),
frame: document.getElementById("mobileFrame"),
preview: document.getElementById("mobilePreview"),
@@ -31,12 +28,7 @@ function mobileDesign() {
const margin = Number(fields.margin.value);
const text = fields.text.value.trim() || " ";
const fontSize = Number(fields.font.value);
const autoLength = fields.autoLength.checked;
const length = autoLength
? estimateTextLengthMm(text, fontSize, margin, fields.frame.checked)
: Number(fields.length.value);
fields.length.value = String(length);
fields.length.disabled = autoLength;
const length = estimateTextLengthMm(text, fontSize, margin, fields.frame.checked);
const objects = [];
if (fields.frame.checked) {
objects.push({
@@ -66,10 +58,10 @@ function mobileDesign() {
return {
tapeWidthMm: tapeWidth,
lengthMm: length,
autoLength,
autoLength: true,
marginMm: margin,
orientation: "landscape",
cutMode: fields.cutMode.value,
cutMode: "auto",
halfcut: "off",
objects,
};
@@ -105,9 +97,9 @@ document.getElementById("mobileDetect").addEventListener("click", async () => {
setMessage(`Band erkannt: ${payload.width} mm`, "success");
});
["text", "font", "margin", "frame", "autoLength"].forEach((name) => {
["text", "font", "margin", "frame", "bold", "align", "tape"].forEach((name) => {
fields[name].addEventListener("input", () => {
if (name === "autoLength" || fields.autoLength.checked) mobileDesign();
mobileDesign();
});
});