From 58bf009a8a3d5103d83e2fb7ee48b9e0fa86be85 Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 24 Sep 2024 10:12:38 +0200 Subject: [PATCH] Issuer details and bug fixes --- .../Charts/PoolPerformanceChart.tsx | 10 ++++-- .../src/components/Charts/PriceChart.tsx | 23 +++++++------ .../InvestRedeem/InvestRedeemDrawer.tsx | 10 +++--- .../src/components/IssuerSection.tsx | 33 ++++++++++++++++--- centrifuge-app/src/components/PoolList.tsx | 21 +++++++----- centrifuge-js/src/modules/pools.ts | 1 - fabric/.storybook/preview.jsx | 4 --- fabric/src/components/TextInput/index.tsx | 2 +- fabric/src/theme/tokens/theme.ts | 2 +- 9 files changed, 66 insertions(+), 40 deletions(-) diff --git a/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx b/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx index 5beb7254fb..d1702e70e3 100644 --- a/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx +++ b/centrifuge-app/src/components/Charts/PoolPerformanceChart.tsx @@ -432,14 +432,12 @@ function CustomLegend({ color: 'textGold', label: 'Junior APY', value: formatPercentage(data.juniorAPY ?? 0), - type: 'singleTrancheTokenPrice', show: true, }, { color: 'textPrimary', label: 'Senior APY', value: formatPercentage(data.seniorAPY ?? 0), - type: 'singleTrancheTokenPrice', show: !!data.seniorAPY, }, ] @@ -461,7 +459,13 @@ function CustomLegend({ - + {item.type ? ( + + ) : ( + + {item.label} + + )} {item.value} diff --git a/centrifuge-app/src/components/Charts/PriceChart.tsx b/centrifuge-app/src/components/Charts/PriceChart.tsx index 48dde0ce78..65b1d10513 100644 --- a/centrifuge-app/src/components/Charts/PriceChart.tsx +++ b/centrifuge-app/src/components/Charts/PriceChart.tsx @@ -1,4 +1,4 @@ -import { Box, Select, Shelf, Stack, Text } from '@centrifuge/fabric' +import { Box, Select, Shelf, Stack, StatusChip, Text } from '@centrifuge/fabric' import React from 'react' import { Area, AreaChart, CartesianGrid, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts' import { useTheme } from 'styled-components' @@ -34,10 +34,12 @@ export const PriceChart = ({ data, currency, filter, setFilter }: PriceChartProp )} {priceDifference && ( - - {' '} - {priceDifference.gte(0) ? '+' : ''} {priceDifference.mul(100).toFixed(2)}% - + + + {' '} + {priceDifference.gte(0) ? '+' : ''} {priceDifference.mul(100).toFixed(2)}% + + )} {filter && setFilter && ( @@ -50,6 +52,7 @@ export const PriceChart = ({ data, currency, filter, setFilter }: PriceChartProp ]} onChange={(option) => setFilter(option.target.value as FilterOptions)} defaultValue={filter} + hideBorder /> )} @@ -57,9 +60,9 @@ export const PriceChart = ({ data, currency, filter, setFilter }: PriceChartProp - - - + + + } /> @@ -102,7 +105,7 @@ export const PriceChart = ({ data, currency, filter, setFilter }: PriceChartProp fill="url(#colorPrice)" name="Price" activeDot={{ fill: '#908f8f' }} - stroke="#908f8f" + stroke={theme.colors.textGold} /> diff --git a/centrifuge-app/src/components/InvestRedeem/InvestRedeemDrawer.tsx b/centrifuge-app/src/components/InvestRedeem/InvestRedeemDrawer.tsx index 1b222a8e54..a82ce8a813 100644 --- a/centrifuge-app/src/components/InvestRedeem/InvestRedeemDrawer.tsx +++ b/centrifuge-app/src/components/InvestRedeem/InvestRedeemDrawer.tsx @@ -1,4 +1,4 @@ -import { Box, Drawer, Stack, Text } from '@centrifuge/fabric' +import { Drawer, Stack, Text } from '@centrifuge/fabric' import * as React from 'react' import { useDailyPoolStates, usePool } from '../../utils/usePools' import { FilterOptions, PriceChart } from '../Charts/PriceChart' @@ -24,13 +24,11 @@ export function InvestRedeemDrawer({ - + - Price + Performance - - - + diff --git a/centrifuge-app/src/components/IssuerSection.tsx b/centrifuge-app/src/components/IssuerSection.tsx index 3065559866..1388461e02 100644 --- a/centrifuge-app/src/components/IssuerSection.tsx +++ b/centrifuge-app/src/components/IssuerSection.tsx @@ -15,6 +15,7 @@ import { import * as React from 'react' import { useLocation } from 'react-router' import styled from 'styled-components' +import { formatPercentage } from '../utils/formatting' import { ExecutiveSummaryDialog } from './Dialogs/ExecutiveSummaryDialog' import { LabelValueStack } from './LabelValueStack' import { AnchorPillButton, PillButton } from './PillButton' @@ -113,6 +114,12 @@ export function IssuerDetails({ metadata }: IssuerSectionProps) { onClick: () => setIsDialogOpen(true), }, ] + + const formatCamelCase = (text: string | undefined) => { + if (!text) return + return text.replace(/([A-Z])/g, ' $1').replace(/^./, (str) => str.toUpperCase()) + } + return ( @@ -127,11 +134,27 @@ export function IssuerDetails({ metadata }: IssuerSectionProps) { )} - - {metadata?.pool?.name} - - {metadata?.pool?.issuer.description} - + + + {metadata?.pool?.issuer.name} + + {metadata?.pool?.issuer.description} + + + {metadata?.pool?.issuer?.categories?.length ? ( + + {metadata?.pool?.issuer?.categories.map((category) => ( + + + {formatCamelCase(category.customType) || formatCamelCase(category.type)} + + + {category.type.includes('Rate') ? formatPercentage(category.value) : category.value} + + + ))} + + ) : null} {!metadataIsLoading && archivedPools.length > 0 && ( <> - setShowArchived((show) => !show)} - variant="body2" - > - {showArchived ? 'Hide archived pools' : 'View archived pools >'} - + + setShowArchived((show) => !show)} + variant="body2" + > + {showArchived ? 'Hide archived pools' : 'View archived pools'} + + {!showArchived && } + {showArchived && } )} diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 7518ef8c2a..9dd6e73b51 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -2693,7 +2693,6 @@ export function getPoolsModule(inst: Centrifuge) { : new Perquintill(0), } }) - console.log('🚀 ~ tranches:', tranches) return { ...state, poolState, poolValue, tranches } }) || [], trancheStates, diff --git a/fabric/.storybook/preview.jsx b/fabric/.storybook/preview.jsx index 24da97cb2a..3bfd399ddc 100644 --- a/fabric/.storybook/preview.jsx +++ b/fabric/.storybook/preview.jsx @@ -1,13 +1,9 @@ import * as React from 'react' import { ThemeProvider } from 'styled-components' import { Box, GlobalStyle } from '../src' -import altairDark from '../src/theme/altairDark' -import altairLight from '../src/theme/altairLight' import centrifugeTheme from '../src/theme/centrifugeTheme' const themes = { - altairDark, - altairLight, centrifugeTheme, } diff --git a/fabric/src/components/TextInput/index.tsx b/fabric/src/components/TextInput/index.tsx index b3b95086b0..49d98d7ca2 100644 --- a/fabric/src/components/TextInput/index.tsx +++ b/fabric/src/components/TextInput/index.tsx @@ -54,7 +54,7 @@ export const StyledInputBox = styled(Shelf)<{ hideBorder?: boolean }>` position: relative; background: ${({ theme }) => theme.colors.backgroundPage}; border: ${({ hideBorder, theme }) => (hideBorder ? 'none' : `1px solid ${theme.colors.borderPrimary}`)}; - border-radius: ${({ theme }) => theme.radii.input}px; + border-radius: ${({ hideBorder, theme }) => (hideBorder ? 'none' : `${theme.radii.input}px`)}; &::before { content: ''; diff --git a/fabric/src/theme/tokens/theme.ts b/fabric/src/theme/tokens/theme.ts index 593c03e477..ebb7bf98a0 100644 --- a/fabric/src/theme/tokens/theme.ts +++ b/fabric/src/theme/tokens/theme.ts @@ -102,7 +102,7 @@ const colors = { backgroundButtonInvertedHover: grayScale[100], backgroundButtonInvertedPressed: grayScale[100], backgroundButtonInvertedDisabled: grayScale[100], - textButtonInverted: grayScale[600], + textButtonInverted: black, textButtonInvertedFocus: grayScale[600], textButtonInvertedHover: grayScale[600], textButtonInvertedPressed: grayScale[600],