primevue-mirror/apps/volt/components/doc/DocSectionCode.vue

43 lines
961 B
Vue
Raw Permalink Normal View History

2025-02-28 11:49:42 +00:00
<template>
2025-02-28 22:59:25 +00:00
<div class="doc-section-code">
2025-02-28 11:49:42 +00:00
<div class="doc-section-code-buttons">
<button type="button" @click="copyCode" class="h-8 w-8 p-0 inline-flex items-center justify-center">
2025-02-28 11:49:42 +00:00
<i class="pi pi-copy"></i>
</button>
</div>
<div dir="ltr">
2025-02-28 22:59:25 +00:00
<template v-if="!lang">
<pre v-code><code>{{ code }}
2025-02-28 11:49:42 +00:00
</code></pre>
</template>
2025-02-28 22:59:25 +00:00
<template v-else-if="lang === 'script'">
2025-03-03 15:43:42 +00:00
<pre v-code.script><code>
{{ code }}
2025-02-28 11:49:42 +00:00
</code></pre>
</template>
</div>
</div>
</template>
<script>
export default {
props: {
code: {
type: null,
default: null
},
2025-02-28 22:59:25 +00:00
lang: {
2025-02-28 11:49:42 +00:00
type: String,
default: null
}
},
methods: {
async copyCode() {
await navigator.clipboard.writeText(this.code[this.codeLang]);
}
}
};
</script>