Skip to content

Commit

Permalink
Assets feedback (#2541)
Browse files Browse the repository at this point in the history
* Change market price decimal from 2 to 4

* Add toggle to show/hide repaid assets

* Fix bug on wallet button
  • Loading branch information
kattylucy authored Nov 19, 2024
1 parent 7de804f commit cbc95e2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
18 changes: 15 additions & 3 deletions centrifuge-app/src/components/LoanList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
AnchorButton,
Box,
Button,
Checkbox,
IconDownload,
Pagination,
PaginationContainer,
Expand Down Expand Up @@ -63,6 +64,7 @@ export function LoanList({ loans, snapshots }: Props) {
const templateIds = poolMetadata?.loanTemplates?.map((s) => s.id) ?? []
const templateId = templateIds.at(-1)
const { data: templateMetadata } = useMetadata<LoanTemplate>(templateId)
const [showRepaid, setShowRepaid] = React.useState(false)

const additionalColumns: Column[] =
templateMetadata?.keyAttributes?.map((key, index) => {
Expand Down Expand Up @@ -193,7 +195,7 @@ export function LoanList({ loans, snapshots }: Props) {
{
align: 'left',
header: <SortableTableHeader label="Market price" />,
cell: (l: Row) => formatBalance(l.marketPrice ?? 0, pool.currency, 2, 0),
cell: (l: Row) => formatBalance(l.marketPrice ?? 0, pool.currency, 4, 0),
sortKey: 'marketPrice',
},
]),
Expand Down Expand Up @@ -268,7 +270,17 @@ export function LoanList({ loans, snapshots }: Props) {
<>
<Box pt={1} pb={2} paddingX={1} display="flex" justifyContent="space-between" alignItems="center">
<Text variant="heading4">{rows.filter((row) => !row.marketValue?.isZero()).length} ongoing assets</Text>
<Box display="flex">
<Box display="flex" alignItems="center">
<Box mr={2}>
<Checkbox
label={
<Text color="textSecondary" variant="body2">
Show repaid assets
</Text>
}
onChange={(e) => setShowRepaid(!showRepaid)}
/>
</Box>
<Button
variant="inverted"
style={{ marginRight: 12 }}
Expand All @@ -295,7 +307,7 @@ export function LoanList({ loans, snapshots }: Props) {
<LoadBoundary>
<Box overflow="auto">
<DataTable
data={rows}
data={showRepaid ? rows : rows.filter((row) => !row?.marketValue?.isZero())}
columns={columns}
onRowClicked={(row) => `${basePath}/${poolId}/assets/${row.id}`}
pageSize={20}
Expand Down
8 changes: 6 additions & 2 deletions centrifuge-react/src/components/WalletMenu/ConnectButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { WalletButton } from '@centrifuge/fabric'
import { WalletButton, WalletButtonProps } from '@centrifuge/fabric'
import * as React from 'react'
import { useWallet } from '../WalletProvider'

export function ConnectButton({ label = 'Connect wallet', ...rest }) {
type Props = WalletButtonProps & {
label?: string
}

export function ConnectButton({ label = 'Connect wallet', ...rest }: Props) {
const { showNetworks, pendingConnect } = useWallet()

return (
Expand Down
1 change: 1 addition & 0 deletions centrifuge-react/src/components/WalletMenu/WalletMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function ConnectedMenu({ menuItems }: WalletMenuProps) {
? substrate.selectedAccount?.name
: undefined
}
displayAddress={formattedAddress}
address={address}
balance={balance ? formatBalanceAbbreviated(balance, symbol) : undefined}
icon={
Expand Down
6 changes: 3 additions & 3 deletions fabric/src/components/Button/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function WalletButton({
loadingMessage={loadingMessage}
active={active}
>
{alias ? (
{alias && address ? (
<Box position="relative" flex="1 1 auto">
<Shelf position="absolute" top="0" bottom="0" left="0" width="100%" m="auto" height="30px">
<Text
Expand All @@ -92,10 +92,10 @@ export function WalletButton({
fontWeight={500}
style={{ margin: address ? 0 : 'auto' }}
>
{alias || connectLabel}
{displayAddress ? truncate(displayAddress) : connectLabel}
</Text>
)}
{alias && balance && (
{address && balance && (
<Text variant="body3" color="textInverted" style={{ marginLeft: 'auto' }}>
{balance}
</Text>
Expand Down
23 changes: 23 additions & 0 deletions fabric/src/components/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ const StyledCheckbox = styled.input`
align-self: center;
margin: -20px 0;
cursor: pointer;
appearance: none;
border: 2px solid ${({ theme }) => theme.colors.borderPrimary};
border-radius: 4px;
background-color: ${({ theme }) => theme.colors.backgroundPrimary};
transition: background-color 0.2s ease, border-color 0.2s ease;
&:checked {
background-color: ${({ theme }) => theme.colors.textGold};
border-color: ${({ theme }) => theme.colors.textGold};
}
&:checked::after {
content: '';
display: block;
width: 6px;
height: 10px;
border: solid ${({ theme }) => theme.colors.backgroundPrimary};
border-width: 0 2px 2px 0;
transform: rotate(45deg);
position: absolute;
top: 3px;
left: 6px;
}
&:focus-visible + span {
display: block;
Expand Down

0 comments on commit cbc95e2

Please sign in to comment.