2022-08-12 19:04:23 +00:00
|
|
|
import { Tooltip } from './tooltip'
|
2022-01-16 09:16:15 +00:00
|
|
|
|
2022-08-27 20:46:35 +00:00
|
|
|
const FORMATTER = new Intl.DateTimeFormat('default', {
|
|
|
|
dateStyle: 'medium',
|
|
|
|
timeStyle: 'long',
|
|
|
|
})
|
2022-01-16 09:16:15 +00:00
|
|
|
|
|
|
|
export function DateTimeTooltip(props: {
|
2022-08-27 20:46:35 +00:00
|
|
|
time: number
|
2022-01-19 22:01:54 +00:00
|
|
|
text?: string
|
2022-08-13 00:48:41 +00:00
|
|
|
className?: string
|
2022-01-16 09:16:15 +00:00
|
|
|
children?: React.ReactNode
|
2022-08-12 19:04:23 +00:00
|
|
|
noTap?: boolean
|
2022-01-16 09:16:15 +00:00
|
|
|
}) {
|
2022-08-13 00:48:41 +00:00
|
|
|
const { className, time, text, noTap } = props
|
2022-01-19 22:01:54 +00:00
|
|
|
|
2022-08-27 20:46:35 +00:00
|
|
|
const formattedTime = FORMATTER.format(time)
|
2022-01-19 22:01:54 +00:00
|
|
|
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
|
|
|
|
|
2022-01-16 09:16:15 +00:00
|
|
|
return (
|
2022-08-13 00:48:41 +00:00
|
|
|
<Tooltip className={className} text={toolTip} noTap={noTap}>
|
2022-08-12 19:04:23 +00:00
|
|
|
{props.children}
|
|
|
|
</Tooltip>
|
2022-01-16 09:16:15 +00:00
|
|
|
)
|
|
|
|
}
|