Make all tooltips use our component
This commit is contained in:
parent
daba28423a
commit
9f9f557741
|
@ -31,6 +31,7 @@ import { useUser } from 'web/hooks/use-user'
|
||||||
import { track } from '@amplitude/analytics-browser'
|
import { track } from '@amplitude/analytics-browser'
|
||||||
import { trackCallback } from 'web/lib/service/analytics'
|
import { trackCallback } from 'web/lib/service/analytics'
|
||||||
import { getMappedValue } from 'common/pseudo-numeric'
|
import { getMappedValue } from 'common/pseudo-numeric'
|
||||||
|
import { Tooltip } from '../tooltip'
|
||||||
|
|
||||||
export function ContractCard(props: {
|
export function ContractCard(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -333,22 +334,19 @@ export function PseudoNumericResolutionOrExpectation(props: {
|
||||||
{resolution === 'CANCEL' ? (
|
{resolution === 'CANCEL' ? (
|
||||||
<CancelLabel />
|
<CancelLabel />
|
||||||
) : (
|
) : (
|
||||||
<div
|
<Tooltip className={textColor} text={value.toFixed(2)}>
|
||||||
className={clsx('tooltip', textColor)}
|
|
||||||
data-tip={value.toFixed(2)}
|
|
||||||
>
|
|
||||||
{formatLargeNumber(value)}
|
{formatLargeNumber(value)}
|
||||||
</div>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div
|
<Tooltip
|
||||||
className={clsx('tooltip text-3xl', textColor)}
|
className={clsx('text-3xl', textColor)}
|
||||||
data-tip={value.toFixed(2)}
|
text={value.toFixed(2)}
|
||||||
>
|
>
|
||||||
{formatLargeNumber(value)}
|
{formatLargeNumber(value)}
|
||||||
</div>
|
</Tooltip>
|
||||||
<div className={clsx('text-base', textColor)}>expected</div>
|
<div className={clsx('text-base', textColor)}>expected</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import React from 'react'
|
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import utc from 'dayjs/plugin/utc'
|
import utc from 'dayjs/plugin/utc'
|
||||||
import timezone from 'dayjs/plugin/timezone'
|
import timezone from 'dayjs/plugin/timezone'
|
||||||
import advanced from 'dayjs/plugin/advancedFormat'
|
import advanced from 'dayjs/plugin/advancedFormat'
|
||||||
import { ClientRender } from './client-render'
|
import { Tooltip } from './tooltip'
|
||||||
|
|
||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
|
@ -19,17 +18,5 @@ export function DateTimeTooltip(props: {
|
||||||
const formattedTime = dayjs(time).format('MMM DD, YYYY hh:mm a z')
|
const formattedTime = dayjs(time).format('MMM DD, YYYY hh:mm a z')
|
||||||
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
|
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
|
||||||
|
|
||||||
return (
|
return <Tooltip text={toolTip}>{props.children}</Tooltip>
|
||||||
<>
|
|
||||||
<ClientRender>
|
|
||||||
<span
|
|
||||||
className="tooltip hidden cursor-default sm:inline-block"
|
|
||||||
data-tip={toolTip}
|
|
||||||
>
|
|
||||||
{props.children}
|
|
||||||
</span>
|
|
||||||
</ClientRender>
|
|
||||||
<span className="whitespace-nowrap sm:hidden">{props.children}</span>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { InformationCircleIcon } from '@heroicons/react/outline'
|
import { InformationCircleIcon } from '@heroicons/react/outline'
|
||||||
|
import { Tooltip } from './tooltip'
|
||||||
|
|
||||||
export function InfoTooltip(props: { text: string }) {
|
export function InfoTooltip(props: { text: string }) {
|
||||||
const { text } = props
|
const { text } = props
|
||||||
return (
|
return (
|
||||||
<div className="tooltip" data-tip={text}>
|
<Tooltip text={text}>
|
||||||
<InformationCircleIcon className="h-5 w-5 text-gray-500" />
|
<InformationCircleIcon className="h-5 w-5 text-gray-500" />
|
||||||
</div>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { ReactNode } from 'react'
|
|
||||||
import { Answer } from 'common/answer'
|
import { Answer } from 'common/answer'
|
||||||
import { getProbability } from 'common/calculate'
|
import { getProbability } from 'common/calculate'
|
||||||
import { getValueFromBucket } from 'common/calculate-dpm'
|
import { getValueFromBucket } from 'common/calculate-dpm'
|
||||||
|
@ -11,7 +10,7 @@ import {
|
||||||
resolution,
|
resolution,
|
||||||
} from 'common/contract'
|
} from 'common/contract'
|
||||||
import { formatLargeNumber, formatPercent } from 'common/util/format'
|
import { formatLargeNumber, formatPercent } from 'common/util/format'
|
||||||
import { ClientRender } from './client-render'
|
import { Tooltip } from './tooltip'
|
||||||
|
|
||||||
export function OutcomeLabel(props: {
|
export function OutcomeLabel(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -91,13 +90,13 @@ export function FreeResponseOutcomeLabel(props: {
|
||||||
const chosen = contract.answers?.find((answer) => answer.id === resolution)
|
const chosen = contract.answers?.find((answer) => answer.id === resolution)
|
||||||
if (!chosen) return <AnswerNumberLabel number={resolution} />
|
if (!chosen) return <AnswerNumberLabel number={resolution} />
|
||||||
return (
|
return (
|
||||||
<FreeResponseAnswerToolTip text={chosen.text}>
|
<Tooltip text={chosen.text}>
|
||||||
<AnswerLabel
|
<AnswerLabel
|
||||||
answer={chosen}
|
answer={chosen}
|
||||||
truncate={truncate}
|
truncate={truncate}
|
||||||
className={answerClassName}
|
className={answerClassName}
|
||||||
/>
|
/>
|
||||||
</FreeResponseAnswerToolTip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,23 +173,3 @@ export function AnswerLabel(props: {
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function FreeResponseAnswerToolTip(props: {
|
|
||||||
text: string
|
|
||||||
children?: ReactNode
|
|
||||||
}) {
|
|
||||||
const { text } = props
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ClientRender>
|
|
||||||
<span
|
|
||||||
className="tooltip hidden cursor-default sm:inline-block"
|
|
||||||
data-tip={text}
|
|
||||||
>
|
|
||||||
{props.children}
|
|
||||||
</span>
|
|
||||||
</ClientRender>
|
|
||||||
<span className="whitespace-nowrap sm:hidden">{props.children}</span>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user