Skip to content

Instantly share code, notes, and snippets.

@suzukieng
Last active April 6, 2023 12:03
Show Gist options
  • Save suzukieng/bc0324cbd30e3ab55abe3250ca9526c3 to your computer and use it in GitHub Desktop.
Save suzukieng/bc0324cbd30e3ab55abe3250ca9526c3 to your computer and use it in GitHub Desktop.
Schedule2 layout example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Schedule2</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="content-container">
<div class="content-above">
<div class="stepper">
<div class="step">1</div>
<div class="step">2</div>
<div class="step">3</div>
</div>
<div class="info">
<h2>Inv. Box A</h2>
<h2>Created at:<br></br>2023-04-06</h2>
</div>
</div>
<div class="barcode-reader">
<!-- BarcodeReader is instantiated here -->
</div>
<div class="content-below">
<h2>Content below barcode reader</h2>
<label for="manualEntry">Manual entry</label>
<input type="text" id="manualEntry">
<div class="buttons">
<button type="button">Previous</button>
<button type="button">Next</button>
</div>
</div>
</div>
<script type="module" src="index.ts"></script>
</body>
</html>
import { BarcodeReader, Configuration, StrichSDK } from '@pixelverse/strichjs-sdk';
const hostElement = document.querySelector('.barcode-reader') as HTMLElement;
const configuration: Configuration = {
selector: hostElement,
debug: true,
engine: {
symbologies: ['code128'],
numScanlines: 10
},
locator: {
left: 0.05,
right: 0.05,
top: 0.35,
bottom: 0.35,
chromaReject: false
},
frameSource: {
resolution: 'full-hd'
},
overlay: {
showCameraSelector: true,
showFlashlight: true
},
feedback: {
audio: true,
vibration: true
}
};
const licenseKey = '<your license key here>';
StrichSDK.initialize(licenseKey).then(() => {
new BarcodeReader(configuration).initialize()
.then(reader => {
reader.detected = (detections) => {
for (const detection of detections) {
console.log(`Code detected: ${detection.data}`);
document.getElementById('manualEntry').value = detection.data;
}
};
return reader.start();
});
});
body, html {
height: 100%;
width: 100%;
margin: 0;
touch-action: manipulation;
}
.content-container {
display: flex;
flex-direction: column;
height: 100%;
}
.content-above {
}
.stepper {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background-color: black;
height: 60px;
}
.step {
padding-left: 20px;
padding-right: 20px;
color: white;
font-size: 2em;
}
.info {
padding: 10px;
display: flex;
flex-direction: row;
align-items: baseline;
justify-content: space-between;
}
.barcode-reader {
flex-grow: 1;
background-color: black;
/* required for STRICH */
position: relative;
height: 240px;
}
.content-below {
padding: 10px;
}
.buttons {
margin-top: 20px;
display: flex;
flex-direction: row;
gap: 20px;
}
.buttons button {
flex-grow: 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment