Skip to content

Commit 6e51f7f

Browse files
committed
Add VLibras plugins and component
1 parent 8177629 commit 6e51f7f

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

src/VLibras.vue

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<!-- Doc: https://www.vlibras.gov.br/doc/widget/installation/webpageintegration.html -->
3+
<div
4+
vw
5+
class="enabled"
6+
>
7+
<div
8+
vw-access-button
9+
class="active"
10+
/>
11+
<div vw-plugin-wrapper>
12+
<div class="vw-plugin-top-wrapper" />
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
let script = null
19+
20+
export default {
21+
name: 'VLibras',
22+
23+
props: {
24+
src: {
25+
type: String,
26+
default: 'https://vlibras.gov.br/app/vlibras-plugin.js'
27+
},
28+
29+
urlWidget: {
30+
type: String,
31+
default: 'https://vlibras.gov.br/app'
32+
}
33+
},
34+
35+
mounted () {
36+
this.init()
37+
},
38+
39+
methods: {
40+
init () {
41+
script = document.createElement('script')
42+
script.addEventListener('load', this.createWidget)
43+
script.src = this.src
44+
document.querySelector('body').appendChild(script)
45+
},
46+
47+
createWidget () {
48+
script.removeEventListener('load', this.createWidget)
49+
// eslint-disable-next-line
50+
new window.VLibras.Widget(this.urlWidget)
51+
}
52+
}
53+
}
54+
</script>

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import VLibrasPlugin from './plugin'
2+
3+
export default VLibrasPlugin
4+
export { default as VLibras } from './VLibras.vue'

src/plugin.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import VLibras from './VLibras.vue'
2+
3+
export default function install (Vue) {
4+
if (install.installed) return
5+
install.installed = true
6+
Vue.component('VLibras', VLibras)
7+
}
8+
9+
// auto install
10+
if (typeof window !== 'undefined' && typeof window.Vue !== 'undefined') {
11+
window.Vue.use(install)
12+
}

0 commit comments

Comments
 (0)