/* eslint-disable @gitlab/require-i18n-strings */
import TooltipOnTruncate from './tooltip_on_truncate.vue';
const defaultWidth = '250px';
export default {
component: TooltipOnTruncate,
title: 'vue_shared/components/tooltip_on_truncate/tooltip_on_truncate.vue',
};
const createStory = ({ ...options }) => {
return (_, { argTypes }) => {
const comp = {
components: { TooltipOnTruncate },
props: Object.keys(argTypes),
template: `
{{title}}
`,
...options,
};
return comp;
};
};
export const Default = createStory();
Default.args = {
width: defaultWidth,
title: 'Hover on this text to see the content in a tooltip.',
};
export const NoOverflow = createStory();
NoOverflow.args = {
width: defaultWidth,
title: "Short text doesn't need a tooltip.",
};
export const Placement = createStory();
Placement.args = {
width: defaultWidth,
title: 'Use `placement="right"` to display this tooltip at the right.',
placement: 'right',
};
const TIMEOUT_S = 3;
export const LiveUpdates = createStory({
props: ['width', 'placement'],
data() {
return {
title: `(loading in ${TIMEOUT_S}s)`,
};
},
mounted() {
setTimeout(() => {
this.title = 'Content updated! The content is now overflowing so we use a tooltip!';
}, TIMEOUT_S * 1000);
},
});
LiveUpdates.args = {
width: defaultWidth,
};
LiveUpdates.argTypes = {
title: {
control: false,
},
};
export const TruncateTarget = createStory({
template: `
`,
});
TruncateTarget.args = {
width: defaultWidth,
truncateTarget: 'child',
title: 'Wrap in container and use `truncate-target="child"` prop.',
};