Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Convert CopyCode component to Composition API #124

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions lib/components/base/CopyCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,24 @@
</button>
</template>

<script setup>
<script setup lang="ts">
import { ref } from 'vue'
import { CheckIcon, ClipboardCopyIcon } from '@'
import { useVIntl, defineMessage } from '@vintl/vintl'

const copiedMessage = defineMessage({
id: 'omorphia.component.copy.action.copy',
defaultMessage: 'Copy code to clipboard',
})
const { formatMessage } = useVIntl()
</script>

<script>
export default {
props: {
text: {
type: String,
required: true,
},
},
data() {
return {
copied: false,
}
},
methods: {
async copyText() {
await navigator.clipboard.writeText(this.text)
this.copied = true
},
},
const props = defineProps<{ text: string }>()

const copied = ref(false)

async function copyText() {
await navigator.clipboard.writeText(props.text)
copied.value = true
}
</script>

Expand Down