debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/clipboard_button.vue

68 lines
1.2 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2018-10-15 14:42:47 +05:30
/**
* Falls back to the code used in `copy_to_clipboard.js`
*
* Renders a button with a clipboard icon that copies the content of `data-clipboard-text`
* when clicked.
*
* @example
* <clipboard-button
* title="Copy to clipbard"
* text="Content to be copied"
* css-class="btn-transparent"
* />
*/
import tooltip from '../directives/tooltip';
2018-03-17 18:26:18 +05:30
2018-10-15 14:42:47 +05:30
export default {
name: 'ClipboardButton',
directives: {
tooltip,
},
props: {
text: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
title: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-10-15 14:42:47 +05:30
tooltipPlacement: {
type: String,
required: false,
default: 'top',
},
tooltipContainer: {
type: [String, Boolean],
required: false,
default: false,
},
cssClass: {
type: String,
required: false,
default: 'btn-default',
},
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
<button
2018-11-08 19:23:39 +05:30
v-tooltip
2018-03-27 19:54:05 +05:30
:class="cssClass"
2018-03-17 18:26:18 +05:30
:title="title"
:data-clipboard-text="text"
:data-container="tooltipContainer"
:data-placement="tooltipPlacement"
2018-11-08 19:23:39 +05:30
type="button"
class="btn"
2018-03-17 18:26:18 +05:30
>
<i
aria-hidden="true"
class="fa fa-clipboard"
>
</i>
</button>
</template>