summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/help_popover.vue
blob: f3b871c91b69d17ab51ed4335c878bc210c9bbcf (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
<script>
import { GlButton, GlPopover, GlSafeHtmlDirective } from '@gitlab/ui';

/**
 * Render a button with a question mark icon
 * On hover shows a popover. The popover will be dismissed on mouseleave
 */
export default {
  name: 'HelpPopover',
  components: {
    GlButton,
    GlPopover,
  },
  directives: {
    SafeHtml: GlSafeHtmlDirective,
  },
  props: {
    options: {
      type: Object,
      required: false,
      default: () => ({}),
    },
  },
};
</script>
<template>
  <span>
    <gl-button ref="popoverTrigger" variant="link" icon="question" :aria-label="__('Help')" />
    <gl-popover :target="() => $refs.popoverTrigger.$el" v-bind="options">
      <template v-if="options.title" #title>
        <span v-safe-html="options.title"></span>
      </template>
      <template #default>
        <div v-safe-html="options.content"></div>
      </template>
      <template v-for="slot in Object.keys($slots)" #[slot]>
        <slot :name="slot"></slot>
      </template>
    </gl-popover>
  </span>
</template>