-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reexport LongTextTooltip component from PF
- Loading branch information
Showing
3 changed files
with
6 additions
and
253 deletions.
There are no files selected for viewing
46 changes: 0 additions & 46 deletions
46
packages/components/src/LongTextTooltip/LongTextTooltip.test.js
This file was deleted.
Oops, something went wrong.
31 changes: 6 additions & 25 deletions
31
packages/components/src/LongTextTooltip/LongTextTooltip.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
182 changes: 0 additions & 182 deletions
182
packages/components/src/LongTextTooltip/__snapshots__/LongTextTooltip.test.js.snap
This file was deleted.
Oops, something went wrong.