Skip to content

Commit

Permalink
Merge pull request #1922 from fhlavac/replace-tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac authored Oct 5, 2023
2 parents ecf7292 + beee58e commit 5994dbe
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 255 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/components/src/Ansible/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from '@patternfly/react-component-groups/dist/dynamic/Ansible';
export { default } from './Ansible';
export { default as Ansible } from './Ansible';
1 change: 1 addition & 0 deletions packages/components/src/Battery/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from '@patternfly/react-component-groups/dist/dynamic/Battery';
export { default } from './Battery';
export { default as Battery } from './Battery';
export { default as CriticalBattery } from './CriticalBattery';
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/ErrorBoundary/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from '@patternfly/react-component-groups/dist/dynamic/ErrorBoundary';
export { default } from './ErrorBoundary';
export { default as ErrorBoundary } from './ErrorBoundary';
1 change: 1 addition & 0 deletions packages/components/src/ErrorState/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from '@patternfly/react-component-groups/dist/dynamic/ErrorState';
export { default } from './ErrorState';
export { default as ErrorState } from './ErrorState';
export { default as DefaultErrorMessage } from './DefaultErrorMessage';
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.

2 changes: 1 addition & 1 deletion packages/components/src/LongTextTooltip/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from '@patternfly/react-component-groups/dist/dynamic/LongTextTooltip';
export { default } from './LongTextTooltip';
export { default as LongTextTooltip } from './LongTextTooltip';
export * from './LongTextTooltip';
1 change: 1 addition & 0 deletions packages/components/src/NotAuthorized/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized';
export { default } from './NotAuthorized';
export { default as NotAuthorized } from './NotAuthorized';

0 comments on commit 5994dbe

Please sign in to comment.