Skip to content

Commit

Permalink
Fix after testing
Browse files Browse the repository at this point in the history
- add mobile version of transfer info modal
  • Loading branch information
samchuk-vlad committed Jan 15, 2024
1 parent 9a8147f commit 4a32992
Show file tree
Hide file tree
Showing 11 changed files with 566 additions and 45 deletions.
13 changes: 10 additions & 3 deletions src/assets/icons/received-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/assets/icons/sent-big.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/components/txHistory/Index.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

.IconBox
svg
height: auto
width: auto
height: 25px
width: 24px

.AllEvents
&:global(.ant-menu-item-selected)
Expand All @@ -45,7 +45,7 @@

.TxHistoryActionBlock
position: sticky
z-index: 10
z-index: 9
top: 64px
background-color: #fff
border-radius: inherit
Expand Down
14 changes: 12 additions & 2 deletions src/components/txHistory/filter/ListFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import SelectbleDropdown, {
import { MenuItem } from '@/components/utils/Dropdowns/types'
import styles from '../Index.module.sass'
import { LabelWithIcon } from '@/components/table/balancesTable/utils'
import { useState } from 'react'
import { useResponsiveSize } from '@/components/responsive'

type ListFilterProps = {
menus: MenuItem[]
filters: string[]
setFilters: (filter: string[]) => void
label: string
labelImage: React.ReactNode
scrollPosition?: number
}

const ListFilter = ({ filters, setFilters, menus, label, labelImage }: ListFilterProps) => {
const ListFilter = ({ filters, setFilters, menus, label, labelImage, scrollPosition }: ListFilterProps) => {
const [ visible, setVisible ] = useState(false)
const { isMobile } = useResponsiveSize()

const onChange = (values: string[], kind: DropdownActionKind) => {
const newValue = values.find((x) => !filters.includes(x))

Expand All @@ -23,18 +29,22 @@ const ListFilter = ({ filters, setFilters, menus, label, labelImage }: ListFilte
setFilters(values.filter((x) => x !== 'all'))
} else if (kind === 'select' && isAll) {
setFilters([ 'all' ])
setVisible(false)
} else if (kind === 'deselect' && values.length < 1) {
setFilters([ 'all' ])
} else {
setFilters(values)
}

window.scrollTo(0, 0)

window.scrollTo(0, isMobile ? scrollPosition || 0 : 0)
}

return (
<>
<SelectbleDropdown
visible={visible}
setVisible={setVisible}
menu={menus}
defaultValue={filters[0]}
onChange={onChange}
Expand Down
11 changes: 7 additions & 4 deletions src/components/txHistory/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getTxHistory } from '@/api/txHistory'
import { TransferRow } from './transactions/Transfer'
import { Transaction } from './types'
import CustomDataList from './CustomDataList'
import { useCallback, useEffect, useState } from 'react'
import { useCallback, useEffect, useRef, useState } from 'react'
import useGetInitialTxHistoryData from './useGetTxHistory'
import { Button, Tooltip } from 'antd'
import { SubDate, isEmptyArray } from '@subsocial/utils'
Expand Down Expand Up @@ -64,6 +64,7 @@ const TxHistoryLayout = ({ addresses }: TxHistoryLayoutProps) => {
const address = addresses[0]
const [ refresh, setRefresh ] = useState(false)
const { isMobile } = useResponsiveSize()
const historySection = useRef(null)

const { initialData, lastUpdateDate } = useGetInitialTxHistoryData({
address,
Expand All @@ -84,6 +85,7 @@ const TxHistoryLayout = ({ addresses }: TxHistoryLayoutProps) => {
)
}


const dataLoading = isEmptyArray(initialData.txs) && !initialData.actualData

const List = useCallback(() => {
Expand Down Expand Up @@ -126,7 +128,7 @@ const TxHistoryLayout = ({ addresses }: TxHistoryLayoutProps) => {
])

return (
<div className={styles.HistoryBlock}>
<div ref={historySection} className={styles.HistoryBlock}>
<div className={styles.TxHistoryActionBlock}>
<div className={styles.TxHistoryButtons}>
<div className={styles.LeftPart}>
Expand All @@ -143,6 +145,7 @@ const TxHistoryLayout = ({ addresses }: TxHistoryLayoutProps) => {
setFilters={setEvents}
label={'Events'}
labelImage={<EventsIcon />}
scrollPosition={(historySection.current as any)?.offsetTop - 180}
/>
</div>
<div className={styles.RightPart}>
Expand All @@ -162,8 +165,8 @@ const TxHistoryLayout = ({ addresses }: TxHistoryLayoutProps) => {
</div>
</div>
{isMobile && (
<div className='bs-mt-2 FontNormal'>
<span>Last update: </span>
<div className='bs-mt-2 d-flex align-items-center FontNormal'>
<span className='bs-mr-2'>Last update: </span>
<LastUpdate lastUpdateDate={lastUpdateDate} refresh={refresh} />
</div>
)}
Expand Down
150 changes: 150 additions & 0 deletions src/components/txHistory/transactions/MobileTransferModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import FloatingModal from '@/components/utils/FloatingModal'
import styles from './Transactions.module.sass'
import dayjs from 'dayjs'
import { Button } from 'antd'
import { RiArrowRightUpLine } from 'react-icons/ri'
import { useCurrentAccount } from '@/components/providers/MyExtensionAccountsContext'
import { AccountPreview, AvatarOrSkeleton } from '@/components/table/utils'
import { CopyAddress } from '../../homePage/address-views/utils/index'
import { toShortAddress } from '../../utils/index'
import Link from 'next/link'

type TransferInfo = {
icon: string
address: string
balance: React.ReactNode
totalBalance: React.ReactNode
txKind: string
timestamp: string
extrinsicHash: string
networkName: string
subscanUrl: string
}

type MobileTransferModalProps = {
open: boolean
setOpen: (open: boolean) => void
transferInfo: TransferInfo
}

const MobileTransferModal = ({
open,
setOpen,
transferInfo,
}: MobileTransferModalProps) => {
const {
icon,
address: recipientAddress,
balance,
totalBalance,
txKind,
timestamp,
extrinsicHash,
networkName,
subscanUrl,
} = transferInfo

const currentAddresses = useCurrentAccount()

const currentAddress = currentAddresses?.[0]

const date = dayjs(timestamp).format('MMM DD, YYYY [at] HH:mm:ss ')

const isRecieved = txKind === 'TRANSFER_TO'

return (
<FloatingModal
position='bottom'
open={open}
setOpen={setOpen}
className={'bg-white bs-p-3 FontNormal text-center'}
>
<div className={styles.ModalContent}>
<div className={styles.TxContent}>
<div className={styles[`Tokens-${isRecieved ? 'Recieved' : 'Send'}`]}>
{isRecieved ? '+' : '-'}
{balance}
</div>
<div className={styles.BalanceInDollar}>{totalBalance}</div>
<div className={styles.SenderBlock}>
<div>
<span className={styles.GrayLabel}>Sender</span>
<span>
<Link
href={'/[address]'}
as={`/${currentAddress}`}
className='text-black'
target='_blank'
rel='noreferrer'
>
<AccountPreview
withAddress={false}
account={currentAddress}
nameClassName={styles.EllipsisPreview}
/>
</Link>
</span>
</div>
<div>
<span className={styles.GrayLabel}>Network</span>
<span>
<AvatarOrSkeleton
icon={icon}
size={24}
className='align-items-start flex-shrink-none'
/>
<span className='ml-2 font-weight-semibold'>{networkName}</span>
</span>
</div>
</div>
<div className={styles.TextBlock}>
<span className={styles.GrayLabel}>Recipient</span>
<span>
<Link
href={'/[address]'}
as={`/${recipientAddress}`}
className='text-black'
target='_blank'
rel='noreferrer'
>
<AccountPreview
withAddress={false}
account={recipientAddress}
nameClassName={styles.EllipsisPreview}
/>
</Link>
</span>
</div>
<div className={styles.TextBlock}>
<span className={styles.GrayLabel}>Transaction ID</span>
<span className='font-weight-semibold'>
<CopyAddress
address={extrinsicHash}
iconVisibility={true}
className='text-black'
message='Extrinsic hash copied'
>
<span>{toShortAddress(extrinsicHash, 8)}</span>
</CopyAddress>
</span>
</div>
<div className={styles.Date}>{date}</div>
</div>

<Button
href={subscanUrl}
target={'_blank'}
type='primary'
ghost
size={'large'}
>
<span className='d-flex align-items-center justify-content-center'>
View on explorer <RiArrowRightUpLine className='ml-2' />
</span>
</Button>
</div>
</FloatingModal>
)
}

export default MobileTransferModal
75 changes: 75 additions & 0 deletions src/components/txHistory/transactions/Transactions.module.sass
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,81 @@
bottom: -1px
right: -2px

.ModalContent
display: flex
flex-direction: column
gap: $space_normal

justify-content: space-between
height: 100%

.TxContent
display: flex
flex-direction: column
gap: $space_normal

margin-top: $space_normal

.SenderBlock
display: flex
flex-direction: column
align-items: center
gap: $space_normal

background: #F8FAFC
border-radius: 10px
padding: $space_normal

div
width: 100%
display: flex
justify-content: space-between
gap: $space_mini

.GrayLabel
color: #888

.TextBlock
width: 100%
display: flex
justify-content: space-between
gap: $space_mini

background: #F8FAFC
border-radius: 10px
padding: $space_normal

.Tokens-Send
color: #000
font-size: $font_big
line-height: 25.144px
font-weight: 600

.Tokens-Recieved
color: #16A34A
font-size: $font_big
line-height: 25.144px
font-weight: 600

.BalanceInDollar
font-size: $font_normal
color: #64748B
line-height: 25.144px

.Date
color: #64748B
line-height: 25.144px
margin-top: $space_tiny

.EllipsisPreview
max-width: 168px
display: block
white-space: nowrap
overflow: hidden
text-overflow: ellipsis

font-weight: 600

@media ( max-width: $max_mobile_width )
.TransferRow
display: flex
Expand Down
Loading

0 comments on commit 4a32992

Please sign in to comment.