createPages = (items) => {
window.setTimeout(() => {
JsBarcode(".barcode").init();
}, 30);
return html`<style>
body {
margin: 0;
}
.pages {
display: flex;
flex-direction: column;
}
.page {
width: 8.5in;
height: 11in;
padding: 0.5in 0.1875in;
display: grid;
grid-template-columns: repeat(3, 2.625in);
grid-auto-rows: 1in;
column-gap: 0.125in;
row-gap: 0;
box-sizing: border-box;
/* outline: 1px dotted silver; */
}
.sticker {
width: 2.625in;
height: 1in;
padding: 0.125in;
text-align: center;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-sizing: border-box;
overflow: hidden;
/* outline: 1px dotted silver; */
}
.barcode {
width: 100%;
}
.sku {
width: 100%;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 12px;
/* font-weight: bold; */
white-space: nowrap;
text-overflow: ellipsis;
}
.page-break {
clear: left;
display: block;
page-break-after: always;
}
</style>
<div class="pages">
${split(items, 30).map(
(page) => `<div class="page">
${page
.map(
({ sku, barcode }) => `<div class="sticker">
<svg class="barcode" jsbarcode-value="${barcode}" jsbarcode-width=4 jsbarcode-height=60 jsbarcode-font="Helvetica" jsbarcode-fontSize=24></svg>
<div class="sku">${sku}</div>
</div>`
)
.join("\n")}
</div>`
)}
</div>`;
}