Skip to content

Commit

Permalink
feat(finproms): added infor for investment risk
Browse files Browse the repository at this point in the history
  • Loading branch information
milan-bc committed Apr 9, 2024
1 parent 4f52412 commit cd4a5d6
Show file tree
Hide file tree
Showing 8 changed files with 1,119 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"buttons.manage": "Manage",
"buttons.next": "Next",
"buttons.ok": "OK",
"buttons.read_more": "Read more",
"buttons.read_less": "Read less",
"buttons.preview_swap": "Preview Swap",
"buttons.receive": "Receive",
"buttons.remove": "Remove",
Expand Down Expand Up @@ -1532,6 +1534,7 @@
"scenes.borrow.warning.safe": "Your collateralization ratio is <span class=\"green600\">{currentRatio}</span>, no action needed at this time.",
"scenes.borrow.warning.unsafe": "Your collateralization ratio is below {unsafeRatio}. Your loan is in danger of being liquidated.",
"scenes.buysell.exchangecheckout.rate": "The rate offered by your region's exchange partner. May include fees.",
"scenes.coin.investement_risk.title": "Investment risk",
"scenes.exchange.blockchain": "Exchange",
"scenes.exchange.changeinput": "Change Input",
"scenes.exchange.confirm.oopsheader": "Oops! Something went wrong.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const CoinPage: CoinPageComponent = ({

<ChartWrapper>{chart}</ChartWrapper>
</Flex>

{about}
{activity}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import styled, { css } from 'styled-components'

export const ListContainer = styled.div<{
isCollapsed: boolean
}>`
overflow: hidden;
transition: max-height 0.3s ease;
${({ isCollapsed }) =>
isCollapsed
? css`
max-height: 40px;
`
: css`
max-height: 200px;
`}
`

export const ListItem = styled.li`
list-style: none;
overflow: hidden;
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { useState } from 'react'
import { FormattedMessage } from 'react-intl'
import { Button as ConstellationButton } from '@blockchain-com/constellation'

import { Button, Text } from 'blockchain-info-components'

import { ListContainer } from './Lines.styles'

type Props = {
lines: string[]
}

export const Lines = ({ lines }: Props) => {
const [isCollapsed, setIsCollapsed] = useState(true)

const toggleCollapse = () => {
setIsCollapsed(!isCollapsed)
}

return (
<div>
<ListContainer isCollapsed={isCollapsed}>
<ul className={`list ${isCollapsed ? 'collapsed' : 'expanded'}`}>
{lines.map((line) => (
<li key={line}>
<Text size='14px' weight={500} color='grey900' lineHeight='150%'>
{line}
</Text>
</li>
))}
</ul>
</ListContainer>
<ConstellationButton
type='button'
variant='minimal'
onClick={toggleCollapse}
data-e2e='toggle-button'
size='small'
text={
isCollapsed ? (
<FormattedMessage defaultMessage='Read more' id='buttons.read_more' />
) : (
<FormattedMessage defaultMessage='Read less' id='buttons.read_less' />
)
}
/>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import styled from 'styled-components'

export const MainWrapper = styled.div<{
expanded: boolean
}>`
margin: 20px 0 30px 0;
display: flex;
flex-direction: column;
border: 1px solid ${(props) => props.theme.grey100};
border-radius: 16px;
overflow: hidden;
transition: max-height 0.3s ease;
max-height: ${({ expanded }) => (expanded ? '800px' : '50px')};
`

export const ContentWrapper = styled.div`
display: flex;
padding: 16px;
flex-direction: column;
gap: 8px;
border-bottom: 1px solid ${(props) => props.theme.grey100};
&:last-child {
border-bottom: none;
}
`

export const Title = styled.div`
padding: 16px;
display: flex;
justify-content: space-between;
border-bottom: 1px solid ${(props) => props.theme.grey100};
`

export const Arrow = styled.div`
cursor: pointer;
transition: transform 0.3s ease;
`

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { useState } from 'react'
import { FormattedMessage } from 'react-intl'
import {
IconChevronDown,
IconChevronDownV2,
IconChevronUp,
IconChevronUpV2,
PaletteColors
} from '@blockchain-com/constellation'

import { AllCoinsType, Text } from 'blockchain-info-components'

import data from './data.json'
import { Lines } from './Lines'
import { Arrow, ContentWrapper, MainWrapper, Title } from './RiskInvestment.styles'

type Props = {
coin: AllCoinsType
}

export const RiskInvestment = (props: Props) => {
const { coin } = props
const [isExpanded, setIsExpanded] = useState(false)

const toggleExpanded = () => {
setIsExpanded((prevExpanded) => !prevExpanded)
}

const coinData = data.find((d) => d.coin === coin)

if (!coinData) {
return null
}

return (
<MainWrapper expanded={isExpanded}>
<Title>
<Text size='16px' weight={600} color='grey900'>
<FormattedMessage
defaultMessage='Investment risk'
id='scenes.coin.investement_risk.title'
/>
</Text>
<Arrow onClick={toggleExpanded}>
{isExpanded ? (
<IconChevronUpV2 label='up' size='small' />
) : (
<IconChevronDownV2 label='down' size='small' />
)}
</Arrow>
</Title>
{coinData.sections.map((section) => (
<ContentWrapper key={coin + section.title}>
<Text size='14px' weight={600} color='grey900'>
{section.title}
</Text>
<Text size='14px' weight={500} color='grey900'>
{section.description}
</Text>
<Lines lines={section.lines} />
</ContentWrapper>
))}
</MainWrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { media } from 'services/styles'
import CoinIntroduction from './CoinIntroduction'
import CoinPerformance from './CoinPerformance'
import RecurringBuys from './RecurringBuys'
import { RiskInvestment } from './RiskInvestment'
import { getData } from './selectors'
import TransactionFilters from './TransactionFilters'
import TransactionList from './TransactionList'
Expand Down Expand Up @@ -147,6 +148,7 @@ class TransactionsContainer extends React.PureComponent<Props> {
currency,
hasTxResults,
interestEligible,
isCustodialCoin,
isGoldTier,
isInvited,
isSearchEntered,
Expand Down Expand Up @@ -319,6 +321,7 @@ class TransactionsContainer extends React.PureComponent<Props> {
sourceType={sourceType}
/>
))}
{isCustodialCoin && <RiskInvestment coin={coin} />}
</LazyLoadContainer>
</SceneWrapper>
)
Expand All @@ -338,22 +341,23 @@ const mapDispatchToProps = (dispatch: Dispatch, ownProps: OwnProps) => {
miscActions: bindActionCreators(actions.core.data.misc, dispatch),
recurringBuyActions: bindActionCreators(actions.components.recurringBuy, dispatch)
}
const isCustodialCoin = selectors.core.data.coins.getCustodialCoins().includes(coin)

if (selectors.core.data.coins.getErc20Coins().includes(coin)) {
return {
...baseActions,
fetchData: () => dispatch(actions.core.data.eth.fetchErc20Data(coin)),
initTxs: () => dispatch(actions.components.ethTransactions.initializedErc20(coin)),
isCustodialCoin,
loadMoreTxs: () => dispatch(actions.components.ethTransactions.loadMoreErc20(coin))
}
}
if (
selectors.core.data.coins.getCustodialCoins().includes(coin) ||
selectors.core.data.coins.getDynamicSelfCustodyCoins().includes(coin)
) {
if (isCustodialCoin || selectors.core.data.coins.getDynamicSelfCustodyCoins().includes(coin)) {
return {
...baseActions,
fetchData: () => {},
initTxs: () => dispatch(actions.components.coinTransactions.initialized(coin)),
isCustodialCoin,
loadMoreTxs: () => dispatch(actions.components.coinTransactions.loadMore(coin))
}
}
Expand All @@ -364,6 +368,7 @@ const mapDispatchToProps = (dispatch: Dispatch, ownProps: OwnProps) => {
fetchData: () => {},
initTxs: () =>
dispatch(actions.components.fiatTransactions.initialized(coin as WalletFiatType)),
isCustodialCoin,
loadMoreTxs: () =>
dispatch(actions.components.fiatTransactions.loadMore(coin as WalletFiatType))
}
Expand All @@ -372,6 +377,7 @@ const mapDispatchToProps = (dispatch: Dispatch, ownProps: OwnProps) => {
...baseActions,
fetchData: () => dispatch(actions.core.data[toLower(coin)].fetchData()),
initTxs: () => dispatch(actions.components[`${toLower(coin)}Transactions`].initialized()),
isCustodialCoin,
loadMoreTxs: () => dispatch(actions.components[`${toLower(coin)}Transactions`].loadMore()),
setAddressArchived: (address) => dispatch(actions.core.wallet.setAddressArchived(address, true))
}
Expand Down

0 comments on commit cd4a5d6

Please sign in to comment.