Skip to content

Commit 0152518

Browse files
committed
docs: include docs in master branch
1 parent 3262070 commit 0152518

File tree

108 files changed

+5038
-231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+5038
-231
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ install:
66

77
script:
88
- npm run build
9+
- npm run build:docs
910

1011
cache: npm
1112

@@ -17,3 +18,10 @@ deploy:
1718
condition: $TRAVIS_BRANCH =~ ^(master|alpha)$
1819
script:
1920
- npx semantic-release
21+
- provider: pages
22+
skip_cleanup: true
23+
keep_history: true
24+
github_token: $GITHUB_TOKEN
25+
on:
26+
branch: master
27+
local_dir: /docs/.vuepress/dist

demos/Demo.vue

Lines changed: 0 additions & 68 deletions
This file was deleted.

demos/index.js

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<template>
2+
<component :is="currentDemo" />
3+
</template>
4+
5+
<script>
6+
import CustomTracking from './demos/CustomTracking.vue'
7+
import DecodeAll from './demos/DecodeAll.vue'
8+
import SwitchCamera from './demos/SwitchCamera.vue'
9+
import DragDrop from './demos/DragDrop.vue'
10+
import Upload from './demos/Upload.vue'
11+
import Fallback from './demos/Fallback.vue'
12+
import Fullscreen from './demos/Fullscreen.vue'
13+
import LoadingIndicator from './demos/LoadingIndicator.vue'
14+
import Torch from './demos/Torch.vue'
15+
import Validate from './demos/Validate.vue'
16+
17+
export default {
18+
components: {
19+
DecodeAll,
20+
CustomTracking,
21+
SwitchCamera,
22+
DragDrop,
23+
Upload,
24+
Fallback,
25+
Fullscreen,
26+
LoadingIndicator,
27+
Torch,
28+
Validate
29+
},
30+
31+
props: {
32+
component: String
33+
},
34+
35+
data () {
36+
return {
37+
currentDemo: null
38+
}
39+
},
40+
41+
mounted () {
42+
this.currentDemo = this.component
43+
}
44+
45+
}
46+
</script>
47+
48+
<style>
49+
.decode-result {
50+
overflow: hidden;
51+
text-overflow: ellipsis;
52+
white-space: nowrap;
53+
}
54+
</style>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<template>
2+
<div>
3+
<p>
4+
Track function:
5+
<select v-model="selected">
6+
<option v-for="option in options" :value="option">
7+
{{ option.text }}
8+
</option>
9+
</select>
10+
</p>
11+
12+
<p class="decode-result">
13+
Last result: <b>{{ result }}</b>
14+
</p>
15+
16+
<qrcode-stream :key="_uid" :track="selected.value" @decode="onDecode" @init="logErrors" />
17+
</div>
18+
</template>
19+
20+
<script>
21+
import { QrcodeStream } from '../../../../src'
22+
23+
export default {
24+
25+
components: { QrcodeStream },
26+
27+
data () {
28+
const options = [
29+
{ text: "None", value: false },
30+
{ text: "Red square (default)", value: true },
31+
{ text: "Green text", value: this.paintGreenText },
32+
{ text: "Blue dots", value: this.paintBlueDots },
33+
]
34+
35+
const selected = options[2]
36+
37+
return { selected, options, result: null }
38+
},
39+
40+
methods: {
41+
paintBlueDots (location, ctx) {
42+
const {
43+
topLeftFinderPattern,
44+
topRightFinderPattern,
45+
bottomLeftFinderPattern
46+
} = location
47+
48+
const pointArray = [
49+
topLeftFinderPattern,
50+
topRightFinderPattern,
51+
bottomLeftFinderPattern
52+
]
53+
54+
ctx.fillStyle = '#007bff'
55+
56+
pointArray.forEach(({ x, y }) => {
57+
ctx.fillRect(x - 5, y - 5, 10, 10)
58+
})
59+
},
60+
61+
paintGreenText (location, ctx) {
62+
const {
63+
topLeftCorner,
64+
topRightCorner,
65+
bottomLeftCorner,
66+
bottomRightCorner
67+
} = location
68+
69+
const pointArray = [
70+
topLeftCorner,
71+
topRightCorner,
72+
bottomLeftCorner,
73+
bottomRightCorner
74+
]
75+
76+
const centerX = pointArray.reduce((sum, { x }) => x + sum, 0) / 4
77+
const centerY = pointArray.reduce((sum, { y }) => y + sum, 0) / 4
78+
79+
ctx.font = "bold 24px sans-serif"
80+
ctx.textAlign = "center"
81+
82+
ctx.lineWidth = 3
83+
ctx.strokeStyle = '#35495e'
84+
ctx.strokeText(this.result, centerX, centerY)
85+
86+
ctx.fillStyle = '#5cb984'
87+
ctx.fillText(this.result, centerX, centerY)
88+
},
89+
90+
onDecode (result) {
91+
this.result = result
92+
},
93+
94+
logErrors (promise) {
95+
promise.catch(console.error)
96+
}
97+
}
98+
99+
}
100+
</script>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<div>
3+
<p class="error">{{ error }}</p>
4+
5+
<p class="decode-result">Last result: <b>{{ result }}</b></p>
6+
7+
<qrcode-stream @decode="onDecode" @init="onInit" />
8+
</div>
9+
</template>
10+
11+
<script>
12+
import { QrcodeStream } from '../../../../src'
13+
14+
export default {
15+
16+
components: { QrcodeStream },
17+
18+
data () {
19+
return {
20+
result: '',
21+
error: ''
22+
}
23+
},
24+
25+
methods: {
26+
onDecode (result) {
27+
this.result = result
28+
},
29+
30+
async onInit (promise) {
31+
try {
32+
await promise
33+
} catch (error) {
34+
if (error.name === 'NotAllowedError') {
35+
this.error = "ERROR: you need to grant camera access permisson"
36+
} else if (error.name === 'NotFoundError') {
37+
this.error = "ERROR: no camera on this device"
38+
} else if (error.name === 'NotSupportedError') {
39+
this.error = "ERROR: secure context required (HTTPS, localhost)"
40+
} else if (error.name === 'NotReadableError') {
41+
this.error = "ERROR: is the camera already in use?"
42+
} else if (error.name === 'OverconstrainedError') {
43+
this.error = "ERROR: installed cameras are not suitable"
44+
} else if (error.name === 'StreamApiNotSupportedError') {
45+
this.error = "ERROR: Stream API is not supported in this browser"
46+
}
47+
}
48+
}
49+
}
50+
}
51+
</script>
52+
53+
<style scoped>
54+
.error {
55+
font-weight: bold;
56+
color: red;
57+
}
58+
</style>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<div>
3+
<p class="decode-result">Last result: <b>{{ result }}</b></p>
4+
5+
<p v-if="error !== null" class="drop-error">
6+
{{ error }}
7+
</p>
8+
9+
<qrcode-drop-zone @detect="onDetect" @dragover="onDragOver" @init="logErrors">
10+
<div class="drop-area" :class="{ 'dragover': dragover }">
11+
DROP SOME IMAGES HERE
12+
</div>
13+
</qrcode-drop-zone>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import { QrcodeDropZone } from '../../../../src'
19+
20+
export default {
21+
22+
components: { QrcodeDropZone },
23+
24+
data () {
25+
return {
26+
result: null,
27+
error: null,
28+
dragover: false
29+
}
30+
},
31+
32+
methods: {
33+
async onDetect (promise) {
34+
try {
35+
const { content } = await promise
36+
37+
this.result = content
38+
this.error = null
39+
} catch (error) {
40+
if (error.name === 'DropImageFetchError') {
41+
this.error = 'Sorry, you can\'t load cross-origin images :/'
42+
} else if (error.name === 'DropImageDecodeError') {
43+
this.error = 'Ok, that\'s not an image. That can\'t be decoded.'
44+
} else {
45+
this.error = 'Ups, what kind of error is this?! ' + error.message
46+
}
47+
}
48+
},
49+
50+
logErrors (promise) {
51+
promise.catch(console.error)
52+
},
53+
54+
onDragOver (isDraggingOver) {
55+
this.dragover = isDraggingOver
56+
}
57+
}
58+
}
59+
</script>
60+
61+
<style>
62+
.drop-area {
63+
height: 300px;
64+
color: #fff;
65+
text-align: center;
66+
font-weight: bold;
67+
padding: 10px;
68+
69+
background-color: rgba(0,0,0,.5);
70+
}
71+
72+
.dragover {
73+
background-color: rgba(0,0,0,.8);
74+
}
75+
76+
.drop-error {
77+
color: red;
78+
font-weight: bold;
79+
}
80+
</style>

0 commit comments

Comments
 (0)