fix: Corregir alineación y espaciado en visualizador de papel
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 36s

- Fijar ancho del papel a 33ch (referencia Font A)
- Agregar transform-origin basado en alineación (left/center/right)
- Reducir interlineado (line-height 1.2, margins ajustados)
- Compensar altura visual de elementos con doble alto
This commit is contained in:
2025-11-26 20:38:00 -06:00
parent 4714bac31a
commit 5a0da4d149

View File

@@ -11,11 +11,11 @@ const emit = defineEmits<{
'edit-variable': [variableName: string, currentValue: string] 'edit-variable': [variableName: string, currentValue: string]
}>() }>()
// Ancho del papel según la fuente (agregamos padding extra) // Ancho del papel FIJO basado en Font A (33ch) como referencia
// Font B se escala para caber en el mismo ancho físico
const paperWidth = computed(() => { const paperWidth = computed(() => {
// Usamos calc para agregar espacio para el padding interno + margen para doble ancho // Siempre usamos 33ch (Font A) como referencia para mantener alineaciones consistentes
const chars = props.font === 'font_b' ? 40 : 33 return `calc(33ch + 80px)` // 40px padding cada lado para acomodar doble ancho
return `calc(${chars}ch + 80px)` // 40px padding cada lado para acomodar doble ancho
}) })
// Obtener clases CSS para el contenido de una línea (sin alineación, eso va en el padre) // Obtener clases CSS para el contenido de una línea (sin alineación, eso va en el padre)
@@ -86,7 +86,7 @@ function handleVariableClick(segment: TextSegment) {
.paper-simulator { .paper-simulator {
font-family: 'Courier New', Courier, monospace; font-family: 'Courier New', Courier, monospace;
font-size: 14px; font-size: 14px;
line-height: 1.4; line-height: 1.2;
background: linear-gradient(to bottom, #fefefe 0%, #f8f8f8 100%); background: linear-gradient(to bottom, #fefefe 0%, #f8f8f8 100%);
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 4px; border-radius: 4px;
@@ -113,7 +113,7 @@ function handleVariableClick(segment: TextSegment) {
/* Cada línea del ticket - usa flexbox para alineación */ /* Cada línea del ticket - usa flexbox para alineación */
.line { .line {
display: flex; display: flex;
min-height: 1.4em; min-height: 1.2em;
color: #1a1a1a; color: #1a1a1a;
} }
@@ -136,56 +136,82 @@ function handleVariableClick(segment: TextSegment) {
display: inline-block; display: inline-block;
} }
/* Font B - caracteres más angostos (40 chars vs 33) */ /* ========================================
.line-content.font-b { TRANSFORMS BASE (sin considerar alineación)
transform: scaleX(0.825); ======================================== */
}
/* Font B con doble ancho */ /* Font A - Normal (sin transform) */
.line-content.font-b.text-double-width { /* Font A es la referencia base, no necesita scaling */
transform: scaleX(1.65); /* 0.825 * 2 */
}
/* Font B con doble alto */ /* Font A - Doble ancho */
.line-content.font-b.text-double-height {
transform: scaleX(0.825) scaleY(2);
}
/* Font B con doble ancho Y alto */
.line-content.font-b.text-double-width.text-double-height {
transform: scale(1.65, 2);
}
/* Transform origin para líneas centradas - permite que scale funcione correctamente con flexbox center */
.align-center .line-content.font-b.text-double-width,
.align-center .line-content.font-b.text-double-height,
.align-center .line-content.font-b.text-double-width.text-double-height,
.align-center .line-content.text-double-width,
.align-center .line-content.text-double-height,
.align-center .line-content.text-double-width.text-double-height {
transform-origin: center;
}
/* Línea vacía (feed) */
.line-feed {
height: 1.4em;
}
/* Doble ancho - escalar horizontalmente (Font A) */
.line-content.text-double-width { .line-content.text-double-width {
transform: scaleX(2); transform: scaleX(2);
} }
/* Doble alto - escalar verticalmente (Font A) */ /* Font A - Doble alto */
.line-content.text-double-height { .line-content.text-double-height {
transform: scaleY(2); transform: scaleY(2);
transform-origin: top;
} }
/* Doble ancho Y alto combinados (Font A) */ /* Font A - Doble ancho Y alto */
.line-content.text-double-width.text-double-height { .line-content.text-double-width.text-double-height {
transform: scale(2, 2); transform: scale(2, 2);
transform-origin: top left; }
/* Font B - Normal (33/40 = 0.825 para caber en mismo ancho de papel) */
.line-content.font-b {
transform: scaleX(0.825);
}
/* Font B - Doble ancho (0.825 * 2 = 1.65) */
.line-content.font-b.text-double-width {
transform: scaleX(1.65);
}
/* Font B - Doble alto */
.line-content.font-b.text-double-height {
transform: scaleX(0.825) scaleY(2);
}
/* Font B - Doble ancho Y alto */
.line-content.font-b.text-double-width.text-double-height {
transform: scale(1.65, 2);
}
/* ========================================
TRANSFORM-ORIGIN SEGÚN ALINEACIÓN
Para que el punto de anclaje sea consistente
======================================== */
/* IZQUIERDA: el texto se ancla a la izquierda */
.align-left .line-content {
transform-origin: left top;
}
/* CENTRO: el texto se ancla al centro */
.align-center .line-content {
transform-origin: center top;
}
/* DERECHA: el texto se ancla a la derecha */
.align-right .line-content {
transform-origin: right top;
}
/* ========================================
COMPENSACIÓN DE ALTURA PARA DOBLE ALTO
El scaleY(2) expande visualmente pero no afecta layout,
agregamos margen para compensar el espacio extra
======================================== */
/* Doble alto ocupa 2x el espacio vertical */
.line-content.text-double-height {
margin-bottom: 0.6em; /* Espacio reducido para doble alto */
}
/* Línea vacía (feed) */
.line-feed {
height: 1.2em;
} }
/* Línea que excede el límite */ /* Línea que excede el límite */