summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/clipboard_button.vue
blob: cab126a7ecafcdf113f715694675e069f63b8248 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
<script>
  /**
   * Falls back to the code used in `copy_to_clipboard.js`
   */
  import tooltip from '../directives/tooltip';

  export default {
    name: 'ClipboardButton',
    directives: {
      tooltip,
    },
    props: {
      text: {
        type: String,
        required: true,
      },
      title: {
        type: String,
        required: true,
      },
      tooltipPlacement: {
        type: String,
        required: false,
        default: 'top',
      },
      tooltipContainer: {
        type: [String, Boolean],
        required: false,
        default: false,
      },
      cssClass: {
        type: String,
        required: false,
        default: 'btn-default',
      },
    },
  };
</script>

<template>
  <button
    type="button"
    class="btn"
    :class="cssClass"
    :title="title"
    :data-clipboard-text="text"
    v-tooltip
    :data-container="tooltipContainer"
    :data-placement="tooltipPlacement"
  >
    <i
      aria-hidden="true"
      class="fa fa-clipboard"
    >
    </i>
  </button>
</template>