-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from juitnow/v2
V2 including a nice demo
- Loading branch information
Showing
56 changed files
with
3,151 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Publish Pages | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup NodeJS | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
id: setup | ||
|
||
- name: Build Pages | ||
run: | | ||
npm clean-install | ||
npm run build | ||
env: | ||
VITE_BASE_URL: "${{steps.setup.outputs.base_url}}" | ||
|
||
- name: Upload Pages Artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: dist-demo | ||
|
||
- name: Deploy Pages | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
.vscode/ | ||
coverage/ | ||
dist/ | ||
dist-demo/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@font-face { | ||
font-family: 'LibreBarcode128'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128-Regular.otf') format('opentype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcode128Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128Text-Regular.otf') format('opentype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcodeEAN13Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcodeEAN13Text-Regular.otf') format('opentype'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@font-face { | ||
font-family: 'LibreBarcode128'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128-Regular.ttf') format('truetype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcode128Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128Text-Regular.ttf') format('truetype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcodeEAN13Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcodeEAN13Text-Regular.ttf') format('truetype'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@font-face { | ||
font-family: 'LibreBarcode128'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128-Regular.woff') format('woff'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcode128Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128Text-Regular.woff') format('woff'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcodeEAN13Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcodeEAN13Text-Regular.woff') format('woff'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@font-face { | ||
font-family: 'LibreBarcode128'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128-Regular.woff2') format('woff2'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcode128Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128Text-Regular.woff2') format('woff2'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcodeEAN13Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcodeEAN13Text-Regular.woff2') format('woff2'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@font-face { | ||
font-family: 'LibreBarcode128'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128-Regular.woff2') format('woff2'), | ||
url('LibreBarcode128-Regular.woff') format('woff'), | ||
url('LibreBarcode128-Regular.otf') format('opentype'), | ||
url('LibreBarcode128-Regular.ttf') format('truetype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcode128Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcode128Text-Regular.woff2') format('woff2'), | ||
url('LibreBarcode128Text-Regular.woff') format('woff'), | ||
url('LibreBarcode128Text-Regular.otf') format('opentype'), | ||
url('LibreBarcode128Text-Regular.ttf') format('truetype'); | ||
} | ||
|
||
@font-face { | ||
font-family: 'LibreBarcodeEAN13Text'; | ||
font-style: normal; | ||
font-weight: 400; | ||
src: url('LibreBarcodeEAN13Text-Regular.woff2') format('woff2'), | ||
url('LibreBarcodeEAN13Text-Regular.woff') format('woff'), | ||
url('LibreBarcodeEAN13Text-Regular.otf') format('opentype'), | ||
url('LibreBarcodeEAN13Text-Regular.ttf') format('truetype'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { tasks } from '@plugjs/build' | ||
|
||
export default tasks() | ||
export default tasks({ | ||
extraLint: [ | ||
[ '**/*.vue', { directory: 'demo' } ], | ||
[ 'build.ts', { directory: '.' } ], | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<template> | ||
<q-layout view="hHh LpR fff"> | ||
<q-header elevated> | ||
<q-toolbar> | ||
<q-toolbar-title>Juit Librebarcode Demo</q-toolbar-title> | ||
</q-toolbar> | ||
</q-header> | ||
|
||
<q-page-container> | ||
<q-page class="q-pa-md text-center"> | ||
<!-- Code 128 --> | ||
<h2>Code 128</h2> | ||
|
||
<div> | ||
<q-input | ||
v-model="text128" | ||
:error-message="error128" | ||
:error="!! error128" | ||
:hint="`encoded as: ${barcode128}`" | ||
:placeholder="default128" | ||
label="Code 128" | ||
outlined | ||
/> | ||
<q-btn-group> | ||
<q-btn color="primary" label="FNC 1" @click="text128 += '\u0031\uFE0F\u20E3'" /> | ||
<q-btn color="primary" label="FNC 2" @click="text128 += '\u0032\uFE0F\u20E3'" /> | ||
<q-btn color="primary" label="FNC 3" @click="text128 += '\u0033\uFE0F\u20E3'" /> | ||
<q-btn color="primary" label="FNC 4" @click="text128 += '\u0034\uFE0F\u20E3'" /> | ||
</q-btn-group> | ||
<q-btn-toggle | ||
v-model="codeset128" | ||
class="q-mx-md" | ||
toggle-color="primary" | ||
:options="[ | ||
{ label: 'Codeset A', value: 'A' }, | ||
{ label: 'Codeset B', value: 'B' }, | ||
{ label: 'Codeset C', value: 'C' }, | ||
{ label: 'Auto', value: undefined } | ||
]" | ||
/> | ||
<q-toggle v-model="font128" label="Text" /> | ||
<q-slider | ||
v-model="size128" | ||
class="q-px-lg q-mt-md" | ||
:min="12" | ||
:max="256" | ||
:marker-labels="fontSizes" | ||
/> | ||
</div> | ||
<h5 class="q-mb-none"> | ||
{{ fontName128 }} | ||
</h5> | ||
<div :style="{ fontFamily: fontName128, fontSize: `${size128}px` }"> | ||
{{ barcode128 || 'Code 128' }} | ||
</div> | ||
|
||
<!-- EAN 13 --> | ||
<h2>EAN 13</h2> | ||
|
||
<div> | ||
<q-input | ||
v-model="text13" | ||
:error-message="error13" | ||
:error="!! error13" | ||
:hint="`encoded as: ${barcode13}`" | ||
:placeholder="default13" | ||
label="EAN 13" | ||
outlined | ||
dense | ||
/> | ||
<q-slider | ||
v-model="size13" | ||
class="q-px-lg" | ||
:min="12" | ||
:max="256" | ||
:marker-labels="fontSizes" | ||
/> | ||
</div> | ||
<h4 class="q-mb-none"> | ||
LibreBarcodeEAN13Text | ||
</h4> | ||
<div :style="{ fontFamily: 'LibreBarcodeEAN13Text', fontSize: `${size13}px` }"> | ||
{{ barcode13 || '5369849825693' }} | ||
</div> | ||
</q-page> | ||
</q-page-container> | ||
|
||
<q-footer elevated class="text-center" style="z-index: 99999999"> | ||
Made with love in Berlin by <a style="color: white" href="https://www.juit.com/" target="_blank">Juit GmbH</a> | ||
(Source code on <a style="color: white" href="https://github.com/juitnow/juit-librebarcode" target="_blank">GitHub</a>) | ||
</q-footer> | ||
</q-layout> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, ref, watch } from 'vue' | ||
import '../assets/fonts.css' | ||
import { code128, ean, FNC1, FNC2, FNC3, FNC4 } from '../src' | ||
import type { CodeSet } from '@juit/librebarcode' | ||
const fontSizes = [ 12, 24, 48, 96, 128, 192, 256 ] | ||
const default128 = 'Hello, world!' | ||
const text128 = ref('') | ||
const error128 = ref('') | ||
const barcode128 = ref('') | ||
const size128 = ref(96) | ||
const font128 = ref(false) | ||
const fontName128 = computed(() => font128.value ? 'LibreBarcode128Text' : 'LibreBarcode128') | ||
const codeset128 = ref<CodeSet>() | ||
watch([ text128, codeset128 ], ([ text128, codeset128 ]) => { | ||
try { | ||
text128 = (text128 || default128) | ||
.replaceAll(/\u0031\uFE0F\u20E3/g, FNC1) | ||
.replaceAll(/\u0032\uFE0F\u20E3/g, FNC2) | ||
.replaceAll(/\u0033\uFE0F\u20E3/g, FNC3) | ||
.replaceAll(/\u0034\uFE0F\u20E3/g, FNC4) | ||
barcode128.value = text128 ? code128(text128, codeset128) : '' | ||
error128.value = '' | ||
} catch (error: any) { | ||
error128.value = error.message || 'Unknown error' | ||
barcode128.value = '' | ||
} | ||
}, { immediate: true }) | ||
const default13 = '5369849825693' | ||
const text13 = ref('') | ||
const error13 = ref('') | ||
const barcode13 = ref('') | ||
const size13 = ref(96) | ||
watch(text13, (text13) => { | ||
try { | ||
barcode13.value = ean(text13 || default13) | ||
error13.value = '' | ||
} catch (error: any) { | ||
error13.value = error.message || 'Unknown error' | ||
barcode13.value = '' | ||
} | ||
}, { immediate: true }) | ||
</script> |
Oops, something went wrong.