mirror of
https://github.com/traefik/traefik
synced 2026-02-03 10:00:33 +00:00
29 lines
679 B
TypeScript
29 lines
679 B
TypeScript
import { CSS, Text } from '@traefiklabs/faency'
|
|
import { useMemo } from 'react'
|
|
|
|
import Tooltip from 'components/Tooltip'
|
|
|
|
type TooltipTextProps = {
|
|
isTruncated?: boolean
|
|
text?: string
|
|
css?: CSS
|
|
}
|
|
|
|
export default function TooltipText({ isTruncated = false, text, css }: TooltipTextProps) {
|
|
const appliedCss = useMemo(
|
|
() =>
|
|
isTruncated
|
|
? { whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis', maxWidth: '100%', ...css }
|
|
: css,
|
|
[isTruncated, css],
|
|
)
|
|
|
|
if (typeof text === 'undefined') return <Text>-</Text>
|
|
|
|
return (
|
|
<Tooltip label={text} action="copy">
|
|
<Text css={appliedCss}>{text}</Text>
|
|
</Tooltip>
|
|
)
|
|
}
|