Skip to content

Commit

Permalink
chore(format): update format settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant authored and gruhn committed Oct 16, 2023
1 parent b9906f2 commit aa80113
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
"trailingComma": "none",
"singleAttributePerLine": true
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
48 changes: 32 additions & 16 deletions docs/.vitepress/components/demos/Torch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@
<p>
Pick camera:
<select v-model="selected">
<option v-for="device in devices" :key="device.label" :value="device">
<option
v-for="device in devices"
:key="device.label"
:value="device"
>
{{ device.label }}
</option>
</select>
</p>

<p v-if="torchNotSupported" class="error">Torch not supported for active camera</p>
<p
v-if="torchNotSupported"
class="error"
>
Torch not supported for active camera
</p>

<qrcode-stream
:torch="torchActive"
:constraints="{ deviceId: selected.deviceId }"
v-if="selected !== null"
<qrcode-stream
:torch="torchActive"
:constraints="{ deviceId: selected.deviceId }"
v-if="selected !== null"
@error="console.error"
@camera-on="onCameraOn"
v-memo="[torchActive, selected.deviceId]"
>
<button @click="torchActive = !torchActive" :disabled="torchNotSupported">
<img :src="withBase(icon)" alt="toggle torch" />
<button
@click="torchActive = !torchActive"
:disabled="torchNotSupported"
>
<img
:src="withBase(icon)"
alt="toggle torch"
/>
</button>
</qrcode-stream>
</div>
Expand All @@ -35,21 +50,22 @@ const selected = ref(null as MediaDeviceInfo | null)
const devices = ref([] as MediaDeviceInfo[])
onMounted(async () => {
devices.value = (await navigator.mediaDevices.enumerateDevices())
.filter(({ kind }) => kind === 'videoinput')
devices.value = (await navigator.mediaDevices.enumerateDevices()).filter(
({ kind }) => kind === 'videoinput'
)
if (devices.value.length > 0) {
selected.value = devices.value[0]
}
if (devices.value.length > 0) {
selected.value = devices.value[0]
}
})
const torchActive = ref(false)
const torchNotSupported = ref(false)
const icon = computed(() => {
if (torchActive.value) {
if (torchActive.value) {
return '/flash-off.svg'
} else {
} else {
return '/flash-on.svg'
}
})
Expand All @@ -59,7 +75,7 @@ function onCameraOn(capabilities) {
torchNotSupported.value = !capabilities.torch
}
function onError(err) {
function onError(err) {
console.error(err)
}
</script>
Expand Down

0 comments on commit aa80113

Please sign in to comment.