diff --git a/src/components/TopLevelModals/index.tsx b/src/components/TopLevelModals/index.tsx index 99f7755c52..7d6d372c97 100644 --- a/src/components/TopLevelModals/index.tsx +++ b/src/components/TopLevelModals/index.tsx @@ -2,9 +2,12 @@ import { useWeb3React } from '@web3-react/core' import AddressClaimModal from 'components/claim/AddressClaimModal' import ConnectedAccountBlocked from 'components/ConnectedAccountBlocked' import useAccountRiskCheck from 'hooks/useAccountRiskCheck' +import { lazy } from 'react' import { useModalIsOpen, useToggleModal } from 'state/application/hooks' import { ApplicationModal } from 'state/application/reducer' +const Cart = lazy(() => import('nft/components/sell/modal/ListingTag')) + export default function TopLevelModals() { const addressClaimOpen = useModalIsOpen(ApplicationModal.ADDRESS_CLAIM) const addressClaimToggle = useToggleModal(ApplicationModal.ADDRESS_CLAIM) @@ -18,6 +21,7 @@ export default function TopLevelModals() { <> + ) } diff --git a/src/nft/components/sell/modal/ListingTag.css.ts b/src/nft/components/sell/modal/ListingTag.css.ts new file mode 100644 index 0000000000..a83979cc24 --- /dev/null +++ b/src/nft/components/sell/modal/ListingTag.css.ts @@ -0,0 +1,52 @@ +import { style } from '@vanilla-extract/css' +import { breakpoints, sprinkles } from 'nft/css/sprinkles.css' + +export const tagContainer = style([ + sprinkles({ + borderRadius: '20', + borderWidth: '1px', + borderStyle: 'solid', + borderColor: 'medGray', + }), + { + '@media': { + [`screen and (max-width: ${breakpoints.md}px)`]: { + borderRadius: '0', + }, + }, + }, +]) + +export const tagAssets = style([ + sprinkles({ + maxHeight: 'inherit', + }), + { + '@media': { + [`screen and (min-width: ${breakpoints.md}px)`]: { + maxHeight: '55vh', + }, + }, + '::-webkit-scrollbar': { display: 'none' }, + scrollbarWidth: 'none', + }, +]) + +export const closeIcon = style({ + transform: 'rotate(90deg)', + float: 'right', + paddingTop: '1px', +}) + +export const orderButton = style([ + sprinkles({ + width: 'full', + paddingY: '12', + paddingX: '0', + }), + { + ':hover': { + boxShadow: 'none', + }, + }, +]) diff --git a/src/nft/components/sell/modal/ListingTag.tsx b/src/nft/components/sell/modal/ListingTag.tsx new file mode 100644 index 0000000000..05961aed6f --- /dev/null +++ b/src/nft/components/sell/modal/ListingTag.tsx @@ -0,0 +1,120 @@ +import Loader from 'components/Loader' +import { Box } from 'nft/components/Box' +import { Column } from 'nft/components/Flex' +import { CloseDropDownIcon } from 'nft/components/icons' +import { bodySmall, buttonMedium, headlineSmall } from 'nft/css/common.css' +import { useBag, useIsMobile, useSellAsset, useSellPageState } from 'nft/hooks' +import { SellPageStateType } from 'nft/types' +import { lazy, Suspense } from 'react' +import { useLocation } from 'react-router-dom' + +import * as styles from './ListingTag.css' + +const CartSellAssetRow = lazy(() => import('./TagAssetRow')) + +const Cart = () => { + const { pathname } = useLocation() + const isNFTSellPage = pathname.startsWith('/nfts/sell') + const sellAssets = useSellAsset((state) => state.sellAssets) + const setSellPageState = useSellPageState((state) => state.setSellPageState) + const sellPageState = useSellPageState((state) => state.state) + const toggleCart = useBag((state) => state.toggleBag) + const isMobile = useIsMobile() + const bagExpanded = useBag((s) => s.bagExpanded) + + return ( + + }> + + {sellPageState === SellPageStateType.LISTING ? null : ( + <> + + + {sellAssets.length + ? sellAssets.map((asset, index) => ) + : null} + + + { + isMobile && toggleCart() + setSellPageState(SellPageStateType.LISTING) + }} + > + Continue + + + + )} + + + + ) +} + +const BagHeader = ({ bagQuantity }: { bagQuantity: number }) => { + const toggleCart = useBag((state) => state.toggleBag) + const resetSellAssets = useSellAsset((state) => state.reset) + const isMobile = useIsMobile() + return ( + + {isMobile ? ( + + + + ) : null} + + {'Selected items'} + + {bagQuantity > 0 ? ( + + {bagQuantity} {bagQuantity === 1 ? 'NFT' : 'NFTs'} + + • + + + Remove all + + + ) : null} + + ) +} + +export default Cart diff --git a/src/nft/components/sell/modal/TagAssetRow.css.ts b/src/nft/components/sell/modal/TagAssetRow.css.ts new file mode 100644 index 0000000000..9c9c1d6ff5 --- /dev/null +++ b/src/nft/components/sell/modal/TagAssetRow.css.ts @@ -0,0 +1,82 @@ +import { style } from '@vanilla-extract/css' +import { sprinkles } from 'nft/css/sprinkles.css' + +export const tagAssetImage = style([ + sprinkles({ + borderRadius: '8', + height: '52', + width: '52', + marginRight: '12', + marginLeft: '8', + cursor: 'pointer', + }), + { + boxSizing: 'border-box', + }, +]) + +export const tagAssetName = style([ + sprinkles({ + fontWeight: 'medium', + overflow: 'hidden', + marginRight: 'auto', + marginTop: '4', + textOverflow: 'ellipsis', + whiteSpace: 'nowrap', + }), +]) + +export const tagAssetCollectionName = style([ + sprinkles({ + fontWeight: 'normal', + overflow: 'hidden', + textOverflow: 'ellipsis', + whiteSpace: 'nowrap', + }), + { + maxWidth: '65%', + }, +]) + +export const tagAssetRowBottom = style([ + sprinkles({ + width: 'full', + display: 'flex', + flexWrap: 'nowrap', + marginRight: '4', + }), + { + marginTop: '-10px', + }, +]) + +export const removeAsset = style([ + sprinkles({ + position: 'absolute', + cursor: 'pointer', + }), + { + bottom: '-12px', + left: '22px', + }, +]) + +export const removeIcon = style([ + sprinkles({ + width: '32', + }), +]) + +export const tagAssetInfo = style([ + sprinkles({ + fontSize: '14', + color: 'blackBlue', + display: 'flex', + flexWrap: 'wrap', + width: 'full', + overflowX: 'hidden', + }), + { + lineHeight: '17px', + }, +]) diff --git a/src/nft/components/sell/modal/TagAssetRow.tsx b/src/nft/components/sell/modal/TagAssetRow.tsx new file mode 100644 index 0000000000..1fa9864111 --- /dev/null +++ b/src/nft/components/sell/modal/TagAssetRow.tsx @@ -0,0 +1,43 @@ +import { Box } from 'nft/components/Box' +import { bodySmall, subheadSmall } from 'nft/css/common.css' +import { useSellAsset } from 'nft/hooks' +import { WalletAsset } from 'nft/types' +import { useEffect, useRef, useState } from 'react' + +import * as styles from './TagAssetRow.css' + +const CartSellAssetRow = ({ asset }: { asset: WalletAsset }) => { + const removeAsset = useSellAsset((state) => state.removeSellAsset) + const [hovered, setHovered] = useState(false) + const handleHover = () => setHovered(!hovered) + const assetRowRef = useRef() + + useEffect(() => { + if (hovered && assetRowRef.current && assetRowRef.current.matches(':hover') === false) setHovered(false) + }, [hovered]) + + return ( + + { + removeAsset(asset) + }} + > + + Remove item + + {asset.name} + + + {asset.name || `#${asset.tokenId}`} + + {asset.collection?.name} + + + + ) +} + +export default CartSellAssetRow