2018-07-13 10:52:08 -04:00
|
|
|
<script>
|
2021-03-22 14:09:24 -04:00
|
|
|
import { GlButton, GlPopover, GlSafeHtmlDirective } from '@gitlab/ui';
|
2018-07-13 10:52:08 -04:00
|
|
|
|
2018-08-03 11:14:05 -04:00
|
|
|
/**
|
|
|
|
* Render a button with a question mark icon
|
|
|
|
* On hover shows a popover. The popover will be dismissed on mouseleave
|
|
|
|
*/
|
2018-07-13 10:52:08 -04:00
|
|
|
export default {
|
2018-08-03 11:14:05 -04:00
|
|
|
name: 'HelpPopover',
|
2018-07-13 10:52:08 -04:00
|
|
|
components: {
|
2020-12-15 07:10:17 -05:00
|
|
|
GlButton,
|
2021-01-28 16:09:04 -05:00
|
|
|
GlPopover,
|
2018-07-13 10:52:08 -04:00
|
|
|
},
|
2021-03-22 14:09:24 -04:00
|
|
|
directives: {
|
|
|
|
SafeHtml: GlSafeHtmlDirective,
|
|
|
|
},
|
2018-07-13 10:52:08 -04:00
|
|
|
props: {
|
|
|
|
options: {
|
|
|
|
type: Object,
|
2018-08-03 11:14:05 -04:00
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
2018-07-13 10:52:08 -04:00
|
|
|
},
|
|
|
|
},
|
2022-04-05 17:08:46 -04:00
|
|
|
methods: {
|
|
|
|
targetFn() {
|
|
|
|
return this.$refs.popoverTrigger?.$el;
|
|
|
|
},
|
|
|
|
},
|
2018-07-13 10:52:08 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2021-01-28 16:09:04 -05:00
|
|
|
<span>
|
2022-03-30 17:09:29 -04:00
|
|
|
<gl-button ref="popoverTrigger" variant="link" icon="question-o" :aria-label="__('Help')" />
|
2022-04-05 17:08:46 -04:00
|
|
|
<gl-popover :target="targetFn" v-bind="options">
|
2021-03-22 14:09:24 -04:00
|
|
|
<template v-if="options.title" #title>
|
|
|
|
<span v-safe-html="options.title"></span>
|
2021-01-28 16:09:04 -05:00
|
|
|
</template>
|
|
|
|
<template #default>
|
2021-03-22 14:09:24 -04:00
|
|
|
<div v-safe-html="options.content"></div>
|
2021-01-28 16:09:04 -05:00
|
|
|
</template>
|
2022-01-27 13:14:37 -05:00
|
|
|
<template v-for="slot in Object.keys($slots)" #[slot]>
|
|
|
|
<slot :name="slot"></slot>
|
|
|
|
</template>
|
2021-01-28 16:09:04 -05:00
|
|
|
</gl-popover>
|
|
|
|
</span>
|
2018-07-13 10:52:08 -04:00
|
|
|
</template>
|