Receipt printer

A long paper trail for an imaginary order.

Ready to print.

Fictional items and amounts. No real order data.

Key CSS & implementation tricks

.paper-viewport { position: absolute; top: 94px; bottom: 0; overflow: hidden; }
.receipt-paper { transform: translateY(calc(-100% + 34px)); } /* a strip shows in the slot */
[data-state="printing"] .receipt-paper {
  animation: receipt-feed var(--print-duration) linear forwards; }
[data-state="printed"] .receipt-paper { transform: translateY(0); }
@keyframes receipt-feed { from { transform: translateY(calc(-100% + 34px)); } to { transform: none; } }

.receipt-paper {
  clip-path: polygon(0 0, 100% 0, 100% 99%, 98% 100%, 96% 99%, 94% 100%,
                     /* … every 2% … */ 4% 99%, 2% 100%, 0 99%);
}

.receipt-barcode {
  height: 32px;
  background: repeating-linear-gradient(90deg,
    var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px,
    transparent 5px 9px, var(--ink) 9px 12px, transparent 12px 15px);
}

function print() {
  cancel();                       // clears any pending completion
  setState('idle');
  void paper.offsetWidth;         // restart the keyframe
  setState(isStill() ? 'printed' : 'printing');
  if (!isStill()) timer = setTimeout(() => setState('printed'), 2550);
}
[data-state="printed"] .paper-viewport { overflow-y: auto; }