feat: increase hit-target for remove button (#5412)

* feat: increase hit-target for remove button

* chore: add conditional back

* update
This commit is contained in:
Mike Grabowski 2022-11-29 22:22:45 +04:00 committed by GitHub
parent b419b85694
commit ce5c0ff453
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 29 deletions

@ -106,11 +106,3 @@ export const collectionName = style([
export const icon = sprinkles({ export const icon = sprinkles({
flexShrink: '0', flexShrink: '0',
}) })
export const removeAssetOverlay = style([
sprinkles({
position: 'absolute',
right: '4',
top: '4',
}),
])

@ -39,6 +39,25 @@ const ReviewButton = styled(ThemeButton)`
padding: 8px; padding: 8px;
width: 50%; width: 50%;
` `
const RemoveAssetOverlay = styled.div`
position: absolute;
display: block;
right: -11px;
top: -11px;
z-index: 1;
transition: 250ms;
width: 45px;
height: 45px;
display: flex;
align-items: center;
justify-content: center;
`
export const RemoveAssetButton = ({ onClick }: { onClick: (e: MouseEvent<HTMLDivElement>) => void }) => (
<RemoveAssetOverlay onClick={onClick}>
<CircularCloseIcon />
</RemoveAssetOverlay>
)
const NoContentContainer = () => ( const NoContentContainer = () => (
<Box position="relative" background="loadingBackground" className={styles.bagRowImage}> <Box position="relative" background="loadingBackground" className={styles.bagRowImage}>
@ -87,7 +106,7 @@ export const BagRow = ({ asset, usdPrice, removeAsset, showRemove, grayscale, is
) )
const handleRemoveClick = useCallback( const handleRemoveClick = useCallback(
(e: MouseEvent<HTMLButtonElement>) => { (e: MouseEvent<HTMLElement>) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
removeAsset([asset]) removeAsset([asset])
@ -99,15 +118,7 @@ export const BagRow = ({ asset, usdPrice, removeAsset, showRemove, grayscale, is
<Link to={getAssetHref(asset)} style={{ textDecoration: 'none' }}> <Link to={getAssetHref(asset)} style={{ textDecoration: 'none' }}>
<Row className={styles.bagRow} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> <Row className={styles.bagRow} onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}>
<Box position="relative" display="flex"> <Box position="relative" display="flex">
<Box {showRemove && isMobile && <RemoveAssetButton onClick={handleRemoveClick} />}
display={showRemove && isMobile ? 'block' : 'none'}
className={styles.removeAssetOverlay}
onClick={handleRemoveClick}
transition="250"
zIndex="1"
>
<CircularCloseIcon />
</Box>
{!noImageAvailable && ( {!noImageAvailable && (
<Box <Box
as="img" as="img"

@ -1,12 +1,12 @@
import { ButtonEmphasis, ButtonSize } from 'components/Button' import { ButtonEmphasis, ButtonSize } from 'components/Button'
import { Box } from 'nft/components/Box' import { Box } from 'nft/components/Box'
import { Column, Row } from 'nft/components/Flex' import { Column, Row } from 'nft/components/Flex'
import { CircularCloseIcon, VerifiedIcon } from 'nft/components/icons' import { VerifiedIcon } from 'nft/components/icons'
import { useIsMobile, useSellAsset } from 'nft/hooks' import { useIsMobile, useSellAsset } from 'nft/hooks'
import { WalletAsset } from 'nft/types' import { WalletAsset } from 'nft/types'
import { useState } from 'react' import { useState } from 'react'
import { RemoveButton } from '../BagRow' import { RemoveAssetButton, RemoveButton } from '../BagRow'
import * as styles from '../BagRow.css' import * as styles from '../BagRow.css'
const ProfileAssetRow = ({ asset }: { asset: WalletAsset }) => { const ProfileAssetRow = ({ asset }: { asset: WalletAsset }) => {
@ -24,15 +24,7 @@ const ProfileAssetRow = ({ asset }: { asset: WalletAsset }) => {
return ( return (
<Row className={styles.bagRow} onMouseEnter={handleHover} onMouseLeave={handleHover}> <Row className={styles.bagRow} onMouseEnter={handleHover} onMouseLeave={handleHover}>
<Box position="relative" display="flex"> <Box position="relative" display="flex">
<Box {isMobile && <RemoveAssetButton onClick={handleRemoveAsset} />}
display={isMobile ? 'block' : 'none'}
className={styles.removeAssetOverlay}
onClick={handleRemoveAsset}
transition="250"
zIndex="1"
>
<CircularCloseIcon />
</Box>
<img src={asset.smallImageUrl} alt={asset.name} className={styles.bagRowImage} /> <img src={asset.smallImageUrl} alt={asset.name} className={styles.bagRowImage} />
</Box> </Box>
<Column overflow="hidden" width="full" color="textPrimary"> <Column overflow="hidden" width="full" color="textPrimary">