Skip to content

Commit

Permalink
feat: loading preview signature
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos committed Apr 12, 2024
1 parent 800c9a2 commit e1d4a78
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
27 changes: 25 additions & 2 deletions src/Components/PreviewSignature/PreviewSignature.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,40 @@
<template>
<div class="modal-draw">
<img :src="src">
<div>
<NcLoadingIcon v-if="loading" :size="64" :name="t('libresign', 'Loading file')" />
<div v-show="isLoaded" class="modal-draw">
<img v-show="isLoaded" :src="src" @load="onImageLoad">
</div>
</div>
</template>

<script>
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
export default {
name: 'PreviewSignature',
components: {
NcLoadingIcon,
},
props: {
src: {
type: String,
default: () => '',
required: true,
},
},
data() {
return {
loading: true,
isLoaded: false,
}
},
methods: {
onImageLoad() {
this.loading = false
this.isLoaded = true
this.$emit('loaded')
},
},
}
</script>

Expand All @@ -23,5 +44,7 @@ export default {
border-radius: 10px;
margin-top: 10px;
margin-bottom: 10px;
min-width: 350px;
min-height: 95px;
}
</style>
9 changes: 7 additions & 2 deletions src/views/Account/partials/Signature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h2>
<slot name="title" />
</h2>
<NcActions :inline="2">
<NcActions :inline="2" v-if="isSignatureLoaded">

Check warning on line 7 in src/views/Account/partials/Signature.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute "v-if" should go before ":inline"
<NcActionButton v-if="hasSignature" @click="removeSignature">
<template #icon>
<DeleteIcon :size="20" />
Expand All @@ -19,7 +19,8 @@
</header>

<div v-if="hasSignature">
<PreviewSignature :src="imgSrc" />
<PreviewSignature :src="imgSrc"
@loaded="signatureLoaded" />
</div>
<div v-else class="no-signatures" @click="edit">
<slot name="no-signatures" />
Expand Down Expand Up @@ -67,6 +68,7 @@ export default {
},
data: () => ({
isEditing: false,
isSignatureLoaded: false,
}),
computed: {
hasSignature() {
Expand All @@ -80,6 +82,9 @@ export default {
},
},
methods: {
signatureLoaded() {
this.isSignatureLoaded = true
},
edit() {
this.isEditing = true
},
Expand Down

0 comments on commit e1d4a78

Please sign in to comment.