Make small embeds into cards (#976)
* Fix embed style (adjust input, strikethrough) * Turn small embeds into contract cards * Use media query instead of conditional render * Open embed card clicks in new tab
This commit is contained in:
		
							parent
							
								
									758dbfe398
								
							
						
					
					
						commit
						0ffd6c129a
					
				|  | @ -38,8 +38,8 @@ export function AmountInput(props: { | ||||||
|   return ( |   return ( | ||||||
|     <> |     <> | ||||||
|       <Col className={className}> |       <Col className={className}> | ||||||
|         <label className="font-sm md:font-lg"> |         <label className="font-sm md:font-lg relative"> | ||||||
|           <span className={clsx('text-greyscale-4 absolute ml-2 mt-[9px]')}> |           <span className="text-greyscale-4 absolute top-1/2 my-auto ml-2 -translate-y-1/2"> | ||||||
|             {label} |             {label} | ||||||
|           </span> |           </span> | ||||||
|           <input |           <input | ||||||
|  |  | ||||||
|  | @ -46,6 +46,7 @@ export function ContractCard(props: { | ||||||
|   hideGroupLink?: boolean |   hideGroupLink?: boolean | ||||||
|   trackingPostfix?: string |   trackingPostfix?: string | ||||||
|   noLinkAvatar?: boolean |   noLinkAvatar?: boolean | ||||||
|  |   newTab?: boolean | ||||||
| }) { | }) { | ||||||
|   const { |   const { | ||||||
|     showTime, |     showTime, | ||||||
|  | @ -56,6 +57,7 @@ export function ContractCard(props: { | ||||||
|     hideGroupLink, |     hideGroupLink, | ||||||
|     trackingPostfix, |     trackingPostfix, | ||||||
|     noLinkAvatar, |     noLinkAvatar, | ||||||
|  |     newTab, | ||||||
|   } = props |   } = props | ||||||
|   const contract = useContractWithPreload(props.contract) ?? props.contract |   const contract = useContractWithPreload(props.contract) ?? props.contract | ||||||
|   const { question, outcomeType } = contract |   const { question, outcomeType } = contract | ||||||
|  | @ -189,6 +191,7 @@ export function ContractCard(props: { | ||||||
|               } |               } | ||||||
|             )} |             )} | ||||||
|             className="absolute top-0 left-0 right-0 bottom-0" |             className="absolute top-0 left-0 right-0 bottom-0" | ||||||
|  |             target={newTab ? '_blank' : '_self'} | ||||||
|           /> |           /> | ||||||
|         </Link> |         </Link> | ||||||
|       )} |       )} | ||||||
|  | @ -211,7 +214,9 @@ export function BinaryResolutionOrChance(props: { | ||||||
|   const probChanged = before !== after |   const probChanged = before !== after | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <Col className={clsx(large ? 'text-4xl' : 'text-3xl', className)}> |     <Col | ||||||
|  |       className={clsx('items-end', large ? 'text-4xl' : 'text-3xl', className)} | ||||||
|  |     > | ||||||
|       {resolution ? ( |       {resolution ? ( | ||||||
|         <> |         <> | ||||||
|           <div |           <div | ||||||
|  |  | ||||||
|  | @ -114,11 +114,7 @@ const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => { | ||||||
|         <ContractDetails contract={contract} /> |         <ContractDetails contract={contract} /> | ||||||
|         <Row className="justify-between gap-4"> |         <Row className="justify-between gap-4"> | ||||||
|           <OverviewQuestion text={contract.question} /> |           <OverviewQuestion text={contract.question} /> | ||||||
|           <BinaryResolutionOrChance |           <BinaryResolutionOrChance contract={contract} large /> | ||||||
|             className="flex items-end" |  | ||||||
|             contract={contract} |  | ||||||
|             large |  | ||||||
|           /> |  | ||||||
|         </Row> |         </Row> | ||||||
|       </Col> |       </Col> | ||||||
|       <SizedContractChart |       <SizedContractChart | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import { BetInline } from 'web/components/bet-inline' | ||||||
| import { Button } from 'web/components/button' | import { Button } from 'web/components/button' | ||||||
| import { | import { | ||||||
|   BinaryResolutionOrChance, |   BinaryResolutionOrChance, | ||||||
|  |   ContractCard, | ||||||
|   FreeResponseResolutionOrChance, |   FreeResponseResolutionOrChance, | ||||||
|   NumericResolutionOrExpectation, |   NumericResolutionOrExpectation, | ||||||
|   PseudoNumericResolutionOrExpectation, |   PseudoNumericResolutionOrExpectation, | ||||||
|  | @ -64,10 +65,13 @@ export default function ContractEmbedPage(props: { | ||||||
|   return <ContractEmbed contract={contract} bets={bets} /> |   return <ContractEmbed contract={contract} bets={bets} /> | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { | interface EmbedProps { | ||||||
|   const { contract, bets } = props |   contract: Contract | ||||||
|   const { question, outcomeType } = contract |   bets: Bet[] | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
|  | export function ContractEmbed(props: EmbedProps) { | ||||||
|  |   const { contract } = props | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     track('view market embed', { |     track('view market embed', { | ||||||
|       slug: contract.slug, |       slug: contract.slug, | ||||||
|  | @ -77,6 +81,27 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { | ||||||
|     }) |     }) | ||||||
|   }, [contract.creatorId, contract.id, contract.slug]) |   }, [contract.creatorId, contract.id, contract.slug]) | ||||||
| 
 | 
 | ||||||
|  |   // return (height < 250px) ? Card : SmolView
 | ||||||
|  |   return ( | ||||||
|  |     <> | ||||||
|  |       <div className="contents [@media(min-height:250px)]:hidden"> | ||||||
|  |         <ContractCard | ||||||
|  |           contract={contract} | ||||||
|  |           className="h-screen" | ||||||
|  |           noLinkAvatar | ||||||
|  |           newTab | ||||||
|  |         /> | ||||||
|  |       </div> | ||||||
|  |       <div className="hidden [@media(min-height:250px)]:contents"> | ||||||
|  |         <ContractSmolView {...props} /> | ||||||
|  |       </div> | ||||||
|  |     </> | ||||||
|  |   ) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function ContractSmolView({ contract, bets }: EmbedProps) { | ||||||
|  |   const { question, outcomeType } = contract | ||||||
|  | 
 | ||||||
|   const isBinary = outcomeType === 'BINARY' |   const isBinary = outcomeType === 'BINARY' | ||||||
|   const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC' |   const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user