Show "New" badge on contract cards too

This commit is contained in:
Austin Chen 2022-04-20 23:03:16 -07:00
parent 7847a9e781
commit 9ce82b1b6f
3 changed files with 19 additions and 21 deletions

View File

@ -18,6 +18,7 @@ import { Avatar } from '../avatar'
import { useState } from 'react' import { useState } from 'react'
import { ContractInfoDialog } from './contract-info-dialog' import { ContractInfoDialog } from './contract-info-dialog'
import { Bet } from '../../../common/bet' import { Bet } from '../../../common/bet'
import NewContractBadge from '../new-contract-badge'
export function AbbrContractDetails(props: { export function AbbrContractDetails(props: {
contract: Contract contract: Contract
@ -25,7 +26,8 @@ export function AbbrContractDetails(props: {
showCloseTime?: boolean showCloseTime?: boolean
}) { }) {
const { contract, showHotVolume, showCloseTime } = props const { contract, showHotVolume, showCloseTime } = props
const { volume24Hours, creatorName, creatorUsername, closeTime } = contract const { volume, volume24Hours, creatorName, creatorUsername, closeTime } =
contract
const { volumeLabel } = contractMetrics(contract) const { volumeLabel } = contractMetrics(contract)
return ( return (
@ -54,11 +56,10 @@ export function AbbrContractDetails(props: {
{(closeTime || 0) < Date.now() ? 'Closed' : 'Closes'}{' '} {(closeTime || 0) < Date.now() ? 'Closed' : 'Closes'}{' '}
{fromNow(closeTime || 0)} {fromNow(closeTime || 0)}
</Row> </Row>
) : volume > 0 ? (
<Row>{volumeLabel}</Row>
) : ( ) : (
<Row className="gap-1"> <NewContractBadge />
{/* <DatabaseIcon className="h-5 w-5" /> */}
{volumeLabel}
</Row>
)} )}
</Row> </Row>
</Col> </Col>

View File

@ -48,6 +48,7 @@ import { User } from '../../../common/user'
import { Modal } from '../layout/modal' import { Modal } from '../layout/modal'
import { trackClick } from '../../lib/firebase/tracking' import { trackClick } from '../../lib/firebase/tracking'
import { DAY_MS } from '../../../common/util/time' import { DAY_MS } from '../../../common/util/time'
import NewContractBadge from '../new-contract-badge'
export function FeedItems(props: { export function FeedItems(props: {
contract: Contract contract: Contract
@ -313,7 +314,6 @@ export function FeedQuestion(props: {
creatorName, creatorName,
creatorUsername, creatorUsername,
question, question,
resolution,
outcomeType, outcomeType,
volume, volume,
createdTime, createdTime,
@ -322,15 +322,6 @@ export function FeedQuestion(props: {
const isBinary = outcomeType === 'BINARY' const isBinary = outcomeType === 'BINARY'
const isNew = createdTime > Date.now() - DAY_MS const isNew = createdTime > Date.now() - DAY_MS
// const closeMessage =
// contract.isResolved || !contract.closeTime ? null : (
// <>
// <span className="mx-2">•</span>
// {contract.closeTime > Date.now() ? 'Closes' : 'Closed'}
// <RelativeTimestamp time={contract.closeTime || 0} />
// </>
// )
return ( return (
<> <>
<Avatar <Avatar
@ -346,15 +337,12 @@ export function FeedQuestion(props: {
/>{' '} />{' '}
asked asked
{/* Currently hidden on mobile; ideally we'd fit this in somewhere. */} {/* Currently hidden on mobile; ideally we'd fit this in somewhere. */}
<div className="relative -top-2 float-right text-gray-400"> <div className="relative -top-2 float-right ">
{isNew || volume === 0 ? ( {isNew || volume === 0 ? (
<Row className="gap-1"> <NewContractBadge />
<SparklesIcon className="h-5 w-5" aria-hidden="true" /> New
</Row>
) : ( ) : (
<span className="hidden sm:inline"> <span className="hidden text-gray-400 sm:inline">
{volumeLabel} {volumeLabel}
{/* {closeMessage} */}
</span> </span>
)} )}
</div> </div>

View File

@ -0,0 +1,9 @@
import { SparklesIcon } from '@heroicons/react/solid'
export default function NewContractBadge() {
return (
<span className="inline-flex items-center gap-1 rounded-full bg-blue-100 px-3 py-0.5 text-sm font-medium text-blue-800">
<SparklesIcon className="h-4 w-4" aria-hidden="true" /> New
</span>
)
}