Inga/scroll to top (#965)
- adding scroll to top button for markets, removing predict button at the bottom of comments
This commit is contained in:
parent
1e2df99054
commit
a219680701
|
@ -17,6 +17,7 @@ import { BetSignUpPrompt } from './sign-up-prompt'
|
|||
import { User } from 'web/lib/firebase/users'
|
||||
import { SellRow } from './sell-row'
|
||||
import { useUnfilledBets } from 'web/hooks/use-bets'
|
||||
import { PlayMoneyDisclaimer } from './play-money-disclaimer'
|
||||
|
||||
/** Button that opens BetPanel in a new modal */
|
||||
export default function BetButton(props: {
|
||||
|
@ -85,7 +86,12 @@ export function BinaryMobileBetting(props: { contract: BinaryContract }) {
|
|||
if (user) {
|
||||
return <SignedInBinaryMobileBetting contract={contract} user={user} />
|
||||
} else {
|
||||
return <BetSignUpPrompt className="w-full" />
|
||||
return (
|
||||
<Col className="w-full">
|
||||
<BetSignUpPrompt className="w-full" />
|
||||
<PlayMoneyDisclaimer />
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { InfoBox } from './info-box'
|
|||
export const PlayMoneyDisclaimer = () => (
|
||||
<InfoBox
|
||||
title="Play-money trading"
|
||||
className="mt-4 max-w-md"
|
||||
className="mt-4"
|
||||
text="Mana (M$) is the play-money used by our platform to keep track of your trades. It's completely free for you and your friends to get started!"
|
||||
/>
|
||||
)
|
||||
|
|
47
web/components/scroll-to-top-button.tsx
Normal file
47
web/components/scroll-to-top-button.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { ArrowUpIcon } from '@heroicons/react/solid'
|
||||
import clsx from 'clsx'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Row } from './layout/row'
|
||||
|
||||
export function ScrollToTopButton(props: { className?: string }) {
|
||||
const { className } = props
|
||||
const [visible, setVisible] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const onScroll = () => {
|
||||
if (window.scrollY > 500) {
|
||||
setVisible(true)
|
||||
} else {
|
||||
setVisible(false)
|
||||
}
|
||||
}
|
||||
window.addEventListener('scroll', onScroll, { passive: true })
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('scroll', onScroll)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const scrollToTop = () => {
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
className={clsx(
|
||||
'border-greyscale-2 bg-greyscale-1 hover:bg-greyscale-2 rounded-full border py-2 pr-3 pl-2 text-sm transition-colors',
|
||||
visible ? 'inline' : 'hidden',
|
||||
className
|
||||
)}
|
||||
onClick={scrollToTop}
|
||||
>
|
||||
<Row className="text-greyscale-6 gap-2 align-middle">
|
||||
<ArrowUpIcon className="text-greyscale-4 h-5 w-5" />
|
||||
Scroll to top
|
||||
</Row>
|
||||
</button>
|
||||
)
|
||||
}
|
|
@ -42,12 +42,10 @@ import { ContractsGrid } from 'web/components/contract/contracts-grid'
|
|||
import { Title } from 'web/components/title'
|
||||
import { usePrefetch } from 'web/hooks/use-prefetch'
|
||||
import { useAdmin } from 'web/hooks/use-admin'
|
||||
import { BetSignUpPrompt } from 'web/components/sign-up-prompt'
|
||||
import { PlayMoneyDisclaimer } from 'web/components/play-money-disclaimer'
|
||||
import BetButton from 'web/components/bet-button'
|
||||
import { BetsSummary } from 'web/components/bet-summary'
|
||||
import { listAllComments } from 'web/lib/firebase/comments'
|
||||
import { ContractComment } from 'common/comment'
|
||||
import { ScrollToTopButton } from 'web/components/scroll-to-top-button'
|
||||
|
||||
export const getStaticProps = fromPropz(getStaticPropz)
|
||||
export async function getStaticPropz(props: {
|
||||
|
@ -210,7 +208,6 @@ export function ContractPageContent(
|
|||
{showConfetti && (
|
||||
<FullscreenConfetti recycle={false} numberOfPieces={300} />
|
||||
)}
|
||||
|
||||
{ogCardProps && (
|
||||
<SEO
|
||||
title={question}
|
||||
|
@ -219,7 +216,6 @@ export function ContractPageContent(
|
|||
ogCardProps={ogCardProps}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Col className="w-full justify-between rounded border-0 border-gray-100 bg-white py-6 pl-1 pr-2 sm:px-2 md:px-6 md:py-8">
|
||||
{backToHome && (
|
||||
<button
|
||||
|
@ -276,23 +272,9 @@ export function ContractPageContent(
|
|||
userBets={userBets}
|
||||
comments={comments}
|
||||
/>
|
||||
|
||||
{!user ? (
|
||||
<Col className="mt-4 max-w-sm items-center xl:hidden">
|
||||
<BetSignUpPrompt />
|
||||
<PlayMoneyDisclaimer />
|
||||
</Col>
|
||||
) : (
|
||||
outcomeType === 'BINARY' &&
|
||||
allowTrade && (
|
||||
<BetButton
|
||||
contract={contract as CPMMBinaryContract}
|
||||
className="mb-2 !mt-0 xl:hidden"
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</Col>
|
||||
<RecommendedContractsWidget contract={contract} />
|
||||
<ScrollToTopButton className="fixed bottom-16 right-2 z-20 lg:bottom-2 xl:hidden" />
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user