@trimble-oss/moduswebcomponents
Version:
Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust
85 lines (79 loc) • 2.58 kB
JavaScript
import { html } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
const meta = {
title: 'Components/Tooltip',
component: 'modus-wc-tooltip',
args: {
content: 'Tooltip content',
position: 'auto',
},
argTypes: {
position: {
control: { type: 'select' },
options: ['auto', 'top', 'right', 'left', 'bottom'],
},
},
parameters: {
docs: {
description: {
component: `
A customizable tooltip component used to create tooltips with different content.
### Features
- **Escape Key Dismissal**: Tooltips can be dismissed by pressing the Escape key
- **Auto-positioning**: Automatically positions the tooltip to avoid viewport edges
- **Customizable**: Supports custom CSS classes and positioning
### Keyboard Interaction
- Press **Escape** to dismiss the tooltip while it's visible
- The tooltip will automatically re-enable on mouse enter
`,
},
},
},
};
export default meta;
const Template = {
parameters: {
actions: {
handles: ['dismissEscape'],
},
},
render: (args) => {
// prettier-ignore
return html `
<modus-wc-tooltip
content=${ifDefined(args.content)}
custom-class="${ifDefined(args['custom-class'])}"
?disabled="${args.disabled}"
?force-open="${args['force-open']}"
tooltip-id="${ifDefined(args['tooltip-id'])}"
position=${ifDefined(args.position)}
>
<modus-wc-badge>Hover</modus-wc-badge>
</modus-wc-tooltip>
`;
},
};
export const Default = Object.assign({}, Template);
export const Migration = {
parameters: {
docs: {
description: {
story: `
#### Breaking Changes
- In 1.0 tooltip positioning was handled by Popper.js. In 2.0, positioning is handled using CSS.
- The \`text\` prop has been renamed to \`content\`.
#### Prop Mapping
| 1.0 Prop | 2.0 Prop | Notes |
|-------------|-------------|------------------------------------------|
| aria-label | aria-label | |
| disabled | disabled | |
| position | position | Added \`auto\` option as default value |
| text | content | |
`,
},
},
controls: { disable: true },
canvas: { disable: true },
},
render: () => html `<div></div>`,
};