feat(overflowtooltip): add text as default title for tooltip
This commit is contained in:
@@ -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"
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user