Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Dec 13, 2024
1 parent 881c9dd commit 15fba02
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 47 deletions.
9 changes: 9 additions & 0 deletions centrifuge-app/src/assets/images/prime_page_image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
106 changes: 61 additions & 45 deletions centrifuge-app/src/pages/Prime/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { CurrencyBalance, addressToHex } from '@centrifuge/centrifuge-js'
import { useCentrifugeUtils, useGetNetworkName } from '@centrifuge/centrifuge-react'
import { AnchorButton, Box, IconExternalLink, Shelf, Text, TextWithPlaceholder } from '@centrifuge/fabric'
import { Box, Grid, IconExternalLink, IconGlobe, Shelf, Text, TextWithPlaceholder } from '@centrifuge/fabric'
import { useTheme } from 'styled-components'
import { AnchorTextLink } from '../../../src/components/TextLink'
import primePageImage from '../../assets/images/prime_page_image.svg'
import { Column, DataTable, FilterableTableHeader, SortableTableHeader } from '../../components/DataTable'
import { LayoutSection } from '../../components/LayoutBase/LayoutSection'
import { formatDate } from '../../utils/date'
Expand All @@ -15,29 +18,59 @@ export default function PrimePage() {
}

function Prime() {
const theme = useTheme()
return (
<>
<LayoutSection backgroundColor="backgroundSecondary" alignItems="flex-start" pt={5} pb={3}>
<Text variant="heading1">Centrifuge Prime</Text>
<Box maxWidth={800}>
<Text variant="body1">
Centrifuge Prime was built to meet the needs of large decentralized organizations and protocols. Through
Centrifuge Prime, DeFi native organizations can integrate with the largest financial markets in the world
and take advantage of real yields from real economic activity - all onchain. Assets tailored to your needs,
processes adapted to your governance, and all through decentralized rails.
</Text>
</Box>
<Box bleedX={2} bleedY={1}>
<AnchorButton
href="https://centrifuge.io/prime/"
target="_blank"
iconRight={IconExternalLink}
variant="tertiary"
<LayoutSection alignItems="flex-start" pt={3} pb={3}>
<Box display="flex" alignItems="center">
<Box
backgroundColor="backgroundSecondary"
borderRadius={28}
height={40}
width={40}
border={`6px solid ${theme.colors.backgroundLight}`}
display="flex"
justifyContent="center"
alignItems="center"
padding="10px"
>
Go to website
</AnchorButton>
<IconGlobe size={20} />
</Box>
<Text variant="heading1" style={{ marginLeft: 8 }}>
Centrifuge Prime
</Text>
</Box>
<Grid
gridTemplateColumns={['1fr', '1fr 1fr']}
gap={6}
mt={2}
padding="0px 50px"
style={{ placeItems: 'center' }}
>
<Box>
<Text variant="body1" style={{ lineHeight: '25.6px' }}>
Centrifuge Prime was built to meet the needs of large decentralized organizations and protocols. Through
Centrifuge Prime, DeFi native organizations can integrate with the largest financial markets in the world
and take advantage of real yields from real economic activity - all onchain. Assets tailored to your
needs, processes adapted to your governance, and all through decentralized rails.
</Text>
<Box display="flex" alignItems="center" mt={4}>
<AnchorTextLink
href="https://centrifuge.io/prime/"
target="_blank"
style={{ textDecoration: 'none', marginRight: 8 }}
>
Go to website
</AnchorTextLink>
<IconExternalLink size={20} />
</Box>
</Box>
<Box>
<Box as="img" src={primePageImage} />
</Box>
</Grid>
</LayoutSection>
<Box borderBottom={`1px solid ${theme.colors.borderPrimary}`} pb={3} />
<DaoPortfoliosTable />
</>
)
Expand Down Expand Up @@ -134,30 +167,6 @@ function DaoPortfoliosTable() {
trancheBalances[trancheId] = { balance, tokenPrice }
}
})
// const trancheBalances = !!account
// ? Object.fromEntries(
// account.trancheBalances.nodes.map((tranche: any) => {
// const pool = pools?.find((p) => p.id === tranche.poolId)
// const decimals = pool?.currency.decimals ?? 18
// const tokenPrice = pool?.tranches.find((t) => tranche.trancheId.endsWith(t.id))?.tokenPrice?.toFloat() ?? 1
// let balance = new CurrencyBalance(
// new BN(tranche.claimableTrancheTokens).add(new BN(tranche.pendingRedeemTrancheTokens)),
// decimals
// ).toFloat()

// const subqueryCurrencies = account?.currencyBalances.nodes.filter(
// (b: any) => b.currency.trancheId && b.currency.trancheId === tranche.trancheId
// )
// if (subqueryCurrencies.length) {
// balance += subqueryCurrencies.reduce(
// (acc: number, cur: any) => acc + new CurrencyBalance(cur.amount, decimals).toFloat(),
// 0
// )
// }
// return [tranche.trancheId.split('-')[1], { balance, tokenPrice }]
// })
// )
// : {}
const totalValue = Object.values(trancheBalances)?.reduce(
(acc, { balance, tokenPrice }) => acc + balance * tokenPrice,
0
Expand All @@ -184,6 +193,7 @@ function DaoPortfoliosTable() {
<Text>{row.name}</Text>
</Shelf>
),
width: '2fr',
},
{
align: 'left',
Expand All @@ -196,15 +206,18 @@ function DaoPortfoliosTable() {
/>
),
cell: (row: Row) => <Text>{getNetworkName(row.network)}</Text>,
width: '2fr',
},
{
align: 'left',
header: <SortableTableHeader label="Portfolio value" />,
cell: (row: Row) => (
<TextWithPlaceholder isLoading={isSubqueryLoading}>
{row.value != null && formatBalance(row.value, 'USD')}
</TextWithPlaceholder>
),
sortKey: 'value',
width: '2fr',
},
{
align: 'left',
Expand All @@ -219,14 +232,17 @@ function DaoPortfoliosTable() {
]

return (
<LayoutSection title="DAO portfolios">
<Box mt={2} px={4}>
<Text variant="heading4" style={{ marginBottom: 12 }}>
Portfolios
</Text>
<DataTable
columns={columns}
data={filters.data}
defaultSortKey="value"
defaultSortOrder="desc"
onRowClicked={(row: Row) => `/prime/${row.slug}`}
/>
</LayoutSection>
</Box>
)
}
2 changes: 1 addition & 1 deletion fabric/src/theme/tokens/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export const black = '#252B34'
export const gold = '#FFC012'

export const grayScale = {
10: '#cfcfcf33',
10: '#F9FAFB',
50: '#F6F6F6',
100: '#E7E7E7',
300: '#CFCFCF',
Expand Down
1 change: 1 addition & 0 deletions fabric/src/theme/tokens/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const colors = {
backgroundInput: 'white',
backgroundThumbnail: grayScale[500],
backgroundInverted: grayScale[800],
backgroundLight: grayScale[10],

borderPrimary: grayScale[100],
borderSecondary: 'rgba(207, 207, 207, 0.50)',
Expand Down
3 changes: 2 additions & 1 deletion fabric/src/theme/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type BackgroundColorName = `background${
| 'Thumbnail'
| 'AccentPrimary'
| 'AccentSecondary'
| 'Inverted'}`
| 'Inverted'
| 'Light'}`
type ButtonColorName =
| `${'background' | 'text' | 'border'}Button${'Primary' | 'Secondary' | 'Tertiary' | 'Inverted'}${
| ''
Expand Down

0 comments on commit 15fba02

Please sign in to comment.