-
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.
- Loading branch information
Showing
6 changed files
with
97 additions
and
11 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
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
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,27 @@ | ||
var script = null | ||
export default ({ | ||
height, | ||
barcode | ||
}) => { | ||
const target = document.createElement("img") | ||
const build = () => { | ||
JsBarcode(target, barcode, { | ||
displayValue: true | ||
}) | ||
target.height = height || 100 | ||
} | ||
if (!window.JsBarcode) { | ||
if (!script) { | ||
script = document.createElement('script') | ||
script.src = 'https://cdn.jsdelivr.net/npm/[email protected]/dist/'+ | ||
'JsBarcode.all.min.js' | ||
script.async = false | ||
document.head.appendChild(script) | ||
} | ||
script.addEventListener('load', build) | ||
} else { | ||
build() | ||
} | ||
|
||
return target | ||
} |
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,47 @@ | ||
import barcode from './index.js' | ||
|
||
export default ({ | ||
icon: 'barcode', | ||
title: 'barcode', | ||
description: 'Generate barcode with img tag', | ||
component: barcode, | ||
properties: { | ||
barcode: { | ||
type: 'string', | ||
description: 'The text or value that will be used to generate the barcode.' | ||
}, | ||
height: { | ||
type: 'integer', | ||
description: 'The height of the img tag in pixels.' | ||
} | ||
}, | ||
examples: [ | ||
{ | ||
title: 'A default size', | ||
data: [ | ||
{ | ||
barcode: 'hjkl6789' | ||
}, { | ||
barcode: 'hjkl6789', | ||
height: 100 | ||
} | ||
] | ||
}, { | ||
title: 'A big size', | ||
data: [ | ||
{ | ||
barcode: 'abc1234', | ||
height: 200 | ||
} | ||
] | ||
}, { | ||
title: 'A small size', | ||
data: [ | ||
{ | ||
barcode: 'dog', | ||
height: 50 | ||
} | ||
] | ||
} | ||
] | ||
}) |
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
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