Skip to content

Commit

Permalink
Reexport LongTextTooltip component from PF
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac committed Oct 5, 2023
1 parent ecf7292 commit c8980b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 253 deletions.
46 changes: 0 additions & 46 deletions packages/components/src/LongTextTooltip/LongTextTooltip.test.js

This file was deleted.

31 changes: 6 additions & 25 deletions packages/components/src/LongTextTooltip/LongTextTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import { Tooltip, TooltipPosition, TooltipProps } from '@patternfly/react-core';
import React from 'react';
import LongTextTooltipPF, { LongTextTooltipProps } from '@patternfly/react-component-groups/dist/dynamic/LongTextTooltip';

export interface LongTextTooltipProps extends Omit<TooltipProps, 'content'> {
content?: string;
maxLength?: number;
tooltipPosition?: TooltipPosition;
tooltipMaxWidth?: string;
}

const LongTextTooltip: React.FC<LongTextTooltipProps> = ({
content = '',
maxLength = Infinity,
tooltipMaxWidth = '50vw',
tooltipPosition = TooltipPosition.top,
...rest
}) => {
const truncate = (str: string, max: number) => (str.length > max ? str.substr(0, max - 1) + '…' : str);

return content.length > maxLength ? (
<Tooltip maxWidth={tooltipMaxWidth} position={tooltipPosition} content={<div>{content}</div>} {...rest}>
<div>{truncate(content, maxLength)}</div>
</Tooltip>
) : (
<span>{content}</span>
);
};
/**
* @deprecated Do not use deprecated LongTextTooltip import, the component has been moved to @patternfly/react-component-groups
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const LongTextTooltip: React.FunctionComponent<LongTextTooltipProps> = (props) => <LongTextTooltipPF {...props} />;

export default LongTextTooltip;

This file was deleted.

0 comments on commit c8980b6

Please sign in to comment.