forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopyButton.vue
More file actions
46 lines (41 loc) · 1.28 KB
/
CopyButton.vue
File metadata and controls
46 lines (41 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<template>
<v-btn
:disabled="disabled"
:color="color"
:small="$vuetify.breakpoint.smAndDown"
:block="block"
:large="large"
@click="copy"
>
<v-icon left>{{ mdiContentCopy }}</v-icon>
{{ copyText }}
</v-btn>
</template>
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
import { mdiContentCopy } from '@mdi/js'
import { NotificationRequest } from '~/store'
@Component
export default class CopyButton extends Vue {
@Prop({ required: true, type: String }) value!: string
@Prop({ required: false, type: String, default: 'default' }) color!: string
@Prop({ required: false, type: Boolean, default: false }) block!: boolean
@Prop({ required: false, type: Boolean, default: false }) large!: boolean
@Prop({ required: false, type: String, default: 'Copy' }) copyText!: string
@Prop({ required: false, type: String, default: 'Copied' })
notificationText!: string
disabled = false
mdiContentCopy = mdiContentCopy
async copy() {
this.disabled = true
await navigator.clipboard.writeText(this.value)
await this.$store.dispatch('addNotification', {
message: this.notificationText,
type: 'success',
} as NotificationRequest)
setTimeout(() => {
this.disabled = false
}, 5000)
}
}
</script>