-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Strategies): add landing page (#1466)
* feat(Strategies): add landing page * fix: code review
- Loading branch information
1 parent
f2a13c8
commit ec96157
Showing
11 changed files
with
217 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { theme } from '@/component-library'; | ||
const StyledStrategiesLayout = styled.div` | ||
|
||
const StyledList = styled.div` | ||
display: grid; | ||
gap: ${theme.spacing.spacing6}; | ||
@media (min-width: 80em) { | ||
grid-template-columns: 1fr 1fr; | ||
grid-auto-flow: row dense; | ||
grid-auto-rows: 1fr; | ||
grid-template-columns: repeat(1, minmax(0, 1fr)); | ||
gap: ${theme.spacing.spacing4}; | ||
@media ${theme.breakpoints.up('sm')} { | ||
grid-template-columns: repeat(2, minmax(0, 1fr)); | ||
} | ||
@media ${theme.breakpoints.up('lg')} { | ||
grid-template-columns: repeat(3, minmax(0, 1fr)); | ||
} | ||
@media ${theme.breakpoints.up('xl')} { | ||
grid-template-columns: repeat(4, minmax(0, 1fr)); | ||
} | ||
padding: ${theme.spacing.spacing6}; | ||
`; | ||
|
||
export { StyledStrategiesLayout }; | ||
export { StyledList }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/pages/Strategies/components/StrategyCard/StrategyCard.style.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { Flex, P, theme } from '@/component-library'; | ||
|
||
const StyledEarningCard = styled(Flex)` | ||
width: 100%; | ||
background-color: var(--color-list-secondary-bg); | ||
padding: ${theme.spacing.spacing3}; | ||
border-radius: ${theme.rounded.md}; | ||
`; | ||
|
||
const StyledEarnSection = styled(P)` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
export { StyledEarningCard, StyledEarnSection }; |
60 changes: 60 additions & 0 deletions
60
src/pages/Strategies/components/StrategyCard/StrategyCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { ReactNode } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { formatPercentage } from '@/common/utils/utils'; | ||
import { Card, CardProps, CoinIcon, Flex, H1, P, Strong } from '@/component-library'; | ||
import { StrategyData, StrategyRisk } from '@/types/strategies'; | ||
|
||
import { StrategyTag } from '../StrategyTag'; | ||
import { StyledEarningCard, StyledEarnSection } from './StrategyCard.style'; | ||
|
||
type Props = { | ||
title: ReactNode; | ||
description: ReactNode; | ||
} & StrategyData; | ||
|
||
type InheritAttrs = Omit<CardProps, keyof Props>; | ||
|
||
type StrategyCardProps = Props & InheritAttrs; | ||
|
||
const StrategyCard = ({ | ||
interestType, | ||
interestPercentage, | ||
currency, | ||
description, | ||
risk, | ||
title, | ||
...props | ||
}: StrategyCardProps): JSX.Element => { | ||
const { t } = useTranslation(); | ||
|
||
const interestTypeLabel = interestType === 'apr' ? t('apr') : t('apy'); | ||
const interestPercentageLable = formatPercentage(interestPercentage.toNumber()); | ||
|
||
return ( | ||
<Card {...props} alignItems='center' gap='spacing4'> | ||
<Flex alignSelf='flex-start' gap='spacing1'> | ||
<StrategyTag variant='risk' risk={risk} /> | ||
{(risk === StrategyRisk.LOW || risk === StrategyRisk.MEDIUM) && <StrategyTag variant='passive-income' />} | ||
</Flex> | ||
<CoinIcon size='xl2' ticker={currency.ticker} /> | ||
<H1 weight='bold' size='base' align='center' rows={1}> | ||
{title} | ||
</H1> | ||
<StyledEarningCard justifyContent='center'> | ||
<StyledEarnSection size='xs' align='center'> | ||
Earn up to | ||
<Strong size='base'> | ||
{interestPercentageLable} {interestTypeLabel} | ||
</Strong> | ||
</StyledEarnSection> | ||
</StyledEarningCard> | ||
<P color='tertiary' size='xs' align='center'> | ||
{description} | ||
</P> | ||
</Card> | ||
); | ||
}; | ||
|
||
export { StrategyCard }; | ||
export type { StrategyCardProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type { StrategyCardProps } from './StrategyCard'; | ||
export { StrategyCard } from './StrategyCard'; |
11 changes: 11 additions & 0 deletions
11
src/pages/Strategies/components/StrategyTag/StrategyTag.style.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { Span, theme } from '@/component-library'; | ||
|
||
const StyledTag = styled(Span)` | ||
border: ${theme.border.default}; | ||
border-radius: ${theme.rounded.full}; | ||
padding: ${theme.spacing.spacing2}; | ||
`; | ||
|
||
export { StyledTag }; |
44 changes: 44 additions & 0 deletions
44
src/pages/Strategies/components/StrategyTag/StrategyTag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { SpanProps, TextProps } from '@/component-library/Text'; | ||
import { StrategyRisk } from '@/types/strategies'; | ||
|
||
import { StyledTag } from './StrategyTag.style'; | ||
|
||
const content: Record<StrategyRisk, { color: string; label: string }> = { | ||
low: { | ||
color: 'success', | ||
label: 'Low Risk' | ||
}, | ||
medium: { | ||
color: 'warning', | ||
label: 'Medium Risk' | ||
}, | ||
high: { | ||
color: 'error', | ||
label: 'High Risk' | ||
} | ||
}; | ||
|
||
const getContent = (risk: StrategyRisk) => content[risk]; | ||
|
||
type Props = { | ||
variant: 'risk' | 'passive-income'; | ||
risk?: StrategyRisk; | ||
}; | ||
|
||
type InheritAttrs = Omit<SpanProps, keyof Props>; | ||
|
||
type StrategyTagProps = Props & InheritAttrs; | ||
|
||
const StrategyTag = ({ variant, risk, ...props }: StrategyTagProps): JSX.Element => { | ||
const { color, label } = | ||
variant === 'risk' && risk ? getContent(risk) : { label: 'Passive Income', color: undefined }; | ||
|
||
return ( | ||
<StyledTag color={color as TextProps['color']} size='xs' {...props}> | ||
{label} | ||
</StyledTag> | ||
); | ||
}; | ||
|
||
export { StrategyTag }; | ||
export type { StrategyTagProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type { StrategyTagProps } from './StrategyTag'; | ||
export { StrategyTag } from './StrategyTag'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { StrategyCard } from './StrategyCard'; | ||
export { StrategyForm } from './StrategyForm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { CurrencyExt } from '@interlay/interbtc-api'; | ||
import Big from 'big.js'; | ||
|
||
enum StrategyRisk { | ||
LOW = 'low', | ||
MEDIUM = 'medium', | ||
HIGH = 'high' | ||
} | ||
|
||
type StrategyData = { | ||
interestType: 'apy' | 'apr'; | ||
interestPercentage: Big; | ||
risk: StrategyRisk; | ||
currency: CurrencyExt; | ||
}; | ||
|
||
export { StrategyRisk }; | ||
export type { StrategyData }; |
ec96157
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-kintsugi-testnet – ./
interbtc-ui.vercel.app
interbtc-ui-kintsugi-testnet-interlay.vercel.app
interbtc-ui-kintsugi-testnet-git-master-interlay.vercel.app
kintnet.interlay.io
ec96157
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
interbtc-ui-interlay-testnet – ./
interbtc-ui-interlay-testnet-git-master-interlay.vercel.app
interbtc-ui-interlay-testnet-interlay.vercel.app
interbtc-ui-interlay-testnet.vercel.app
testnet.interlay.io