feat(overflowtooltip): add text as default title for tooltip

This commit is contained in:
Kiran Patel
2021-02-04 09:04:23 +11:00
parent ba070def57
commit c380f32c35
4 changed files with 30 additions and 8 deletions
@@ -13,14 +13,36 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Box } from '@material-ui/core';
import React from 'react';
import { OverflowTooltip } from './OverflowTooltip';
export default {
title: 'Data Display/OverflowTooltip',
component: OverflowTooltip,
};
const text =
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.';
export const Default = () => <OverflowTooltip title={text} text={text} />;
export const Default = () => (
<Box maxWidth="200px">
<OverflowTooltip text={text} />
</Box>
);
export const MultiLine = () => (
<OverflowTooltip title={text} text={text} line={2} />
<Box maxWidth="200px">
<OverflowTooltip text={text} line={2} />
</Box>
);
export const DifferentTitle = () => (
<Box maxWidth="200px">
<OverflowTooltip
title="Visit loremipsum.io for more info"
text={text}
line={2}
/>
</Box>
);
@@ -19,11 +19,11 @@ import React, { useState } from 'react';
import TextTruncate, { TextTruncateProps } from 'react-text-truncate';
type Props = {
title: TooltipProps['title'];
placement?: TooltipProps['placement'];
text?: TextTruncateProps['text'];
text: TextTruncateProps['text'];
line?: TextTruncateProps['line'];
element?: TextTruncateProps['element'];
title?: TooltipProps['title'];
placement?: TooltipProps['placement'];
};
export const OverflowTooltip = (props: Props) => {
@@ -36,7 +36,7 @@ export const OverflowTooltip = (props: Props) => {
return (
<Tooltip
title={props.title}
title={props.title ?? (props.text as string)}
placement={props.placement}
disableHoverListener={!hover}
>
@@ -95,8 +95,8 @@ const columns: TableColumn<EntityRow>[] = [
field: 'entity.metadata.description',
render: ({ entity }) => (
<OverflowTooltip
title={entity.metadata.description as string}
text={entity.metadata.description}
placement="bottom-start"
/>
),
},
@@ -94,8 +94,8 @@ const columns: TableColumn<EntityRow>[] = [
field: 'entity.metadata.description',
render: ({ entity }) => (
<OverflowTooltip
title={entity.metadata.description as string}
text={entity.metadata.description}
placement="bottom-start"
/>
),
},