manifold/web/components/datetime-tooltip.tsx
Marshall Polaris 4b513a894d
Make tooltip rendering more efficient (#807)
* Don't use very slow dayjs formatter on timestamp tooltips

* Kill dead code in feed-bets.tsx

* Clean up tooltip markup
2022-08-27 13:46:35 -07:00

26 lines
571 B
TypeScript

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