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

Reexport LongTextTooltip component from PF #1922

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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';