Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Tooltip): be able to change max width #2643

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/core/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ interface TooltipBaseProps extends VibeComponentProps {
* The icon of the tooltip next to the title
*/
icon?: SubIcon;
/**
* Sets the max width of the Tooltip, defaults to 240px
*/
maxWidth?: number;
}
// When last tooltip was shown in the last 1.5 second - the next tooltip will be shown immediately
const IMMEDIATE_SHOW_THRESHOLD_MS = 1500;
Expand Down Expand Up @@ -174,7 +178,7 @@ export default class Tooltip extends PureComponent<TooltipProps> {
}

renderTooltipContent() {
const { theme, content, className, style, title, image, icon } = this.props;
const { theme, content, className, style, maxWidth, title, image, icon } = this.props;
if (!content) {
// don't render empty tooltip
return null;
Expand All @@ -196,7 +200,10 @@ export default class Tooltip extends PureComponent<TooltipProps> {
}

return (
<div style={style} className={cx(styles.tooltip, getStyle(styles, camelCase(theme)), className)}>
<div
style={{ ...style, "--tooltip-max-width": `${maxWidth}px` } as CSSProperties}
talkor marked this conversation as resolved.
Show resolved Hide resolved
className={cx(styles.tooltip, getStyle(styles, camelCase(theme)), className)}
>
{image && <img className={styles.image} src={image} alt="" />}
<div className={cx(styles.content)}>
{title && (
Expand Down
Loading