manifold/web/components/datetime-tooltip.tsx

26 lines
571 B
TypeScript
Raw Permalink Normal View History

import { Tooltip } from './tooltip'
const FORMATTER = new Intl.DateTimeFormat('default', {
dateStyle: 'medium',
timeStyle: 'long',
})
export function DateTimeTooltip(props: {
time: number
2022-01-19 22:01:54 +00:00
text?: string
className?: string
children?: React.ReactNode
noTap?: boolean
}) {
const { className, time, text, noTap } = props
2022-01-19 22:01:54 +00:00
const formattedTime = FORMATTER.format(time)
2022-01-19 22:01:54 +00:00
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
return (
<Tooltip className={className} text={toolTip} noTap={noTap}>
{props.children}
</Tooltip>
)
}