Skip to content

Commit d211c0c

Browse files
committed
lock and earn
1 parent 3e075df commit d211c0c

File tree

9 files changed

+556
-8
lines changed

9 files changed

+556
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { LockAndEarnScreen } from 'app/features/account/rewards/lock-and-earn/screen'
2+
import Head from 'next/head'
3+
import { userProtectedGetSSP } from 'utils/userProtected'
4+
import type { NextPageWithLayout } from 'next-app/pages/_app'
5+
import { HomeLayout } from 'app/features/home/layout.web'
6+
import { ButtonOption, TopNav } from 'app/components/TopNav'
7+
import { MobileButtonRowLayout } from 'app/components/MobileButtonRowLayout'
8+
9+
export const Page: NextPageWithLayout = () => {
10+
return (
11+
<>
12+
<Head>
13+
<title>Send | Lock and Earn</title>
14+
</Head>
15+
<LockAndEarnScreen />
16+
</>
17+
)
18+
}
19+
20+
export const getServerSideProps = userProtectedGetSSP()
21+
Page.getLayout = (children) => (
22+
<MobileButtonRowLayout.LockAndEarn>
23+
<HomeLayout TopNav={<TopNav header="Lock and Earn" button={ButtonOption.PROFILE} />}>
24+
{children}
25+
</HomeLayout>
26+
</MobileButtonRowLayout.LockAndEarn>
27+
)
28+
29+
export default Page

packages/app/components/MobileButtonRowLayout.tsx

+53
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { useProfileScreenParams, useRewardsScreenParams } from 'app/routers/para
2323
import { useMonthlyDistributions } from 'app/utils/distributions'
2424
import { DistributionClaimButton } from 'app/features/account/rewards/components/DistributionClaimButton'
2525
import formatAmount from 'app/utils/formatAmount'
26+
import { LockAndEarnButtons } from 'app/features/account/rewards/lock-and-earn/LockAndEarnButtons'
2627

2728
const Row = styled(XStack, {
2829
w: '100%',
@@ -243,8 +244,60 @@ export const ActivityRewards = ({ children, ...props }: XStackProps) => {
243244
)
244245
}
245246

247+
export const LockAndEarn = ({ children, ...props }: XStackProps) => {
248+
const isPwa = usePwa()
249+
const { isLoading } = useUser()
250+
251+
const { direction } = useScrollDirection()
252+
253+
return (
254+
<>
255+
{children}
256+
<AnimatePresence>
257+
{!isLoading && direction !== 'down' && (
258+
<Stack
259+
w={'100%'}
260+
pb={isPwa ? '$1' : '$5'}
261+
px="$4"
262+
$platform-web={{
263+
position: 'fixed',
264+
bottom: 0,
265+
}}
266+
$gtLg={{
267+
display: 'none',
268+
}}
269+
animation="200ms"
270+
opacity={1}
271+
animateOnly={['scale', 'transform', 'opacity']}
272+
enterStyle={{ opacity: 0, scale: 0.9 }}
273+
exitStyle={{ opacity: 0, scale: 0.95 }}
274+
pointerEvents="none"
275+
>
276+
<LinearGradient
277+
h={'150%'}
278+
top={'-50%'}
279+
start={{ x: 0, y: 1 }}
280+
end={{ x: 0, y: 0 }}
281+
locations={[0, 0.33]}
282+
fullscreen
283+
colors={['transparent', '$background']}
284+
$gtLg={{ display: 'none' }}
285+
/>
286+
<Row {...props}>
287+
<Stack w={200}>
288+
<LockAndEarnButtons.OpenButton />
289+
</Stack>
290+
</Row>
291+
</Stack>
292+
)}
293+
</AnimatePresence>
294+
</>
295+
)
296+
}
297+
246298
export const MobileButtonRowLayout = {
247299
Home: Home,
248300
Profile: Profile,
249301
ActivityRewards: ActivityRewards,
302+
LockAndEarn: LockAndEarn,
250303
}

packages/app/components/icons/IconCoin.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { IconEthereum } from './IconEthereum'
33
import { IconSend } from './IconSend'
44
import { IconUSDC } from './IconUSDC'
55
import { IconSPX6900 } from './IconSPX6900'
6+
import type { SizeTokens } from 'tamagui'
67

7-
const coinSymbolToIcons: Record<coin['symbol'], JSX.Element> = {
8-
USDC: <IconUSDC size={'$2.5'} />,
9-
ETH: <IconEthereum size={'$2.5'} />,
10-
SEND: <IconSend size={'$2.5'} />,
11-
SPX: <IconSPX6900 size={'$2.5'} />,
8+
const coinSymbolToIcons: Record<coin['symbol'], (size: SizeTokens) => JSX.Element> = {
9+
USDC: (size) => <IconUSDC size={size} />,
10+
ETH: (size) => <IconEthereum size={size} />,
11+
SEND: (size) => <IconSend size={size} />,
12+
SPX: (size) => <IconSPX6900 size={size} />,
1213
}
1314

14-
export const IconCoin = ({ coin }: { coin: coin }) => {
15-
return coinSymbolToIcons[coin.symbol]
15+
export const IconCoin = ({ coin, size }: { coin: coin; size?: SizeTokens }) => {
16+
return coinSymbolToIcons[coin.symbol]?.(size || '$2.5')
1617
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { ColorTokens } from '@my/ui/types'
2+
import { type IconProps, themed } from '@tamagui/helpers-icon'
3+
import { memo } from 'react'
4+
import { Path, Svg } from 'react-native-svg'
5+
6+
const ExclamationCircle = (props) => {
7+
const { size, color, ...rest } = props
8+
return (
9+
<Svg
10+
color={color as ColorTokens | undefined}
11+
width={size ?? 24}
12+
height={size ?? 24}
13+
viewBox="0 0 17 17"
14+
fill="none"
15+
{...rest}
16+
>
17+
<Path
18+
fill="currentColor"
19+
d="M8.496 12c.21 0 .39-.072.535-.214a.714.714 0 0 0 .219-.532.736.736 0 0 0-.214-.535.714.714 0 0 0-.532-.219.736.736 0 0 0-.535.214.714.714 0 0 0-.219.532c0 .21.071.39.214.535.143.146.32.219.532.219ZM7.75 9h1.5V4h-1.5v5Zm.756 7a7.81 7.81 0 0 1-3.11-.625 8.064 8.064 0 0 1-2.552-1.719 8.065 8.065 0 0 1-1.719-2.551A7.819 7.819 0 0 1 .5 7.99c0-1.104.208-2.14.625-3.105a8.066 8.066 0 0 1 4.27-4.26A7.819 7.819 0 0 1 8.51 0a7.75 7.75 0 0 1 3.105.625 8.082 8.082 0 0 1 4.26 4.265 7.77 7.77 0 0 1 .625 3.104 7.81 7.81 0 0 1-.625 3.11 8.063 8.063 0 0 1-1.719 2.552 8.081 8.081 0 0 1-2.546 1.719A7.77 7.77 0 0 1 8.506 16ZM8.5 14.5c1.806 0 3.34-.632 4.604-1.896C14.368 11.34 15 9.806 15 8s-.632-3.34-1.896-4.604C11.84 2.132 10.306 1.5 8.5 1.5s-3.34.632-4.604 1.896C2.632 4.66 2 6.194 2 8s.632 3.34 1.896 4.604C5.16 13.868 6.694 14.5 8.5 14.5Z"
20+
/>
21+
</Svg>
22+
)
23+
}
24+
const IconExclamationCircle = memo<IconProps>(themed(ExclamationCircle))
25+
export { IconExclamationCircle }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { ColorTokens } from '@my/ui/types'
2+
import { type IconProps, themed } from '@tamagui/helpers-icon'
3+
import { memo } from 'react'
4+
import { Path, Svg } from 'react-native-svg'
5+
6+
const PlusCircle = (props) => {
7+
const { size, color, ...rest } = props
8+
return (
9+
<Svg
10+
fill="none"
11+
viewBox="0 0 24 24"
12+
color={color as ColorTokens | undefined}
13+
width={size ?? 24}
14+
height={size ?? 24}
15+
{...rest}
16+
>
17+
<Path
18+
fill="currentColor"
19+
d="M11 17h2v-4h4v-2h-4V7h-2v4H7v2h4v4Zm1 5a9.873 9.873 0 0 1-3.9-.775 10.274 10.274 0 0 1-3.175-2.15c-.9-.9-1.617-1.958-2.15-3.175A9.873 9.873 0 0 1 2 12c0-1.383.258-2.683.775-3.9a10.275 10.275 0 0 1 2.15-3.175c.9-.9 1.958-1.608 3.175-2.125A9.607 9.607 0 0 1 12 2c1.383 0 2.683.267 3.9.8a9.927 9.927 0 0 1 3.175 2.125c.9.9 1.608 1.958 2.125 3.175.533 1.217.8 2.517.8 3.9a9.607 9.607 0 0 1-.8 3.9 9.927 9.927 0 0 1-2.125 3.175c-.9.9-1.958 1.617-3.175 2.15A9.873 9.873 0 0 1 12 22Zm0-2c2.233 0 4.125-.775 5.675-2.325C19.225 16.125 20 14.233 20 12c0-2.233-.775-4.125-2.325-5.675C16.125 4.775 14.233 4 12 4c-2.233 0-4.125.775-5.675 2.325C4.775 7.875 4 9.767 4 12c0 2.233.775 4.125 2.325 5.675C7.875 19.225 9.767 20 12 20Z"
20+
/>
21+
</Svg>
22+
)
23+
}
24+
const IconPlusCircle = memo<IconProps>(themed(PlusCircle))
25+
export { IconPlusCircle }

packages/app/components/icons/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ export { IconInfoCircle } from './IconInfoCircle'
5757
export { IconLeaderboard } from './IconLeaderboard'
5858
export { IconStarOutline } from './IconStarOutline'
5959
export { IconQuestionCircle } from './IconQuestionCircle'
60+
export { IconPlusCircle } from './IconPlusCircle'
61+
export { IconExclamationCircle } from './IconExclamationCircle'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Button } from '@my/ui'
2+
3+
export const OpenButton = () => (
4+
<Button borderRadius={'$4'} theme={'green'}>
5+
<Button.Text fontWeight={500} ff={'$mono'} tt={'uppercase'}>
6+
Open a new position
7+
</Button.Text>
8+
</Button>
9+
)
10+
11+
export const LockAndEarnButtons = {
12+
OpenButton: OpenButton,
13+
}

0 commit comments

Comments
 (0)