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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.1 KiB
Vue
Raw Normal View History

2018-11-18 11:00:15 +05:30
<script>
2021-04-29 21:17:54 +05:30
import { GlButton, GlPopover, GlSafeHtmlDirective } from '@gitlab/ui';
2018-11-18 11:00:15 +05:30
/**
* 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: {
2021-02-22 17:27:13 +05:30
GlButton,
2021-03-11 19:13:27 +05:30
GlPopover,
2018-11-18 11:00:15 +05:30
},
2021-04-29 21:17:54 +05:30
directives: {
SafeHtml: GlSafeHtmlDirective,
},
2018-11-18 11:00:15 +05:30
props: {
options: {
type: Object,
required: false,
default: () => ({}),
},
},
2022-06-21 17:19:12 +05:30
methods: {
targetFn() {
return this.$refs.popoverTrigger?.$el;
},
},
2018-11-18 11:00:15 +05:30
};
</script>
<template>
2021-03-11 19:13:27 +05:30
<span>
2022-06-21 17:19:12 +05:30
<gl-button ref="popoverTrigger" variant="link" icon="question-o" :aria-label="__('Help')" />
<gl-popover :target="targetFn" v-bind="options">
2021-04-29 21:17:54 +05:30
<template v-if="options.title" #title>
<span v-safe-html="options.title"></span>
2021-03-11 19:13:27 +05:30
</template>
<template #default>
2021-04-29 21:17:54 +05:30
<div v-safe-html="options.content"></div>
2021-03-11 19:13:27 +05:30
</template>
2022-08-13 15:12:31 +05:30
<!-- eslint-disable-next-line @gitlab/vue-prefer-dollar-scopedslots -->
2022-04-04 11:22:00 +05:30
<template v-for="slot in Object.keys($slots)" #[slot]>
<slot :name="slot"></slot>
</template>
2021-03-11 19:13:27 +05:30
</gl-popover>
</span>
2018-11-18 11:00:15 +05:30
</template>