Commit 8e2307cb authored by aballerr's avatar aballerr Committed by GitHub

fix: updating bag to not remove nfts on click (#5224)

* updating bag to not remove nfts on click
parent 5978d1ec
import { NavIcon } from 'components/NavBar/NavIcon' import { NavIcon } from 'components/NavBar/NavIcon'
import { BagIcon, HundredsOverflowIcon } from 'nft/components/icons' import { BagIcon, HundredsOverflowIcon } from 'nft/components/icons'
import { useBag, useSellAsset } from 'nft/hooks' import { useBag } from 'nft/hooks'
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import shallow from 'zustand/shallow' import shallow from 'zustand/shallow'
...@@ -28,21 +28,10 @@ export const Bag = () => { ...@@ -28,21 +28,10 @@ export const Bag = () => {
({ bagExpanded, setBagExpanded }) => ({ bagExpanded, setBagExpanded }), ({ bagExpanded, setBagExpanded }) => ({ bagExpanded, setBagExpanded }),
shallow shallow
) )
const { isSellMode, resetSellAssets, setIsSellMode } = useSellAsset(
({ isSellMode, reset, setIsSellMode }) => ({
isSellMode,
resetSellAssets: reset,
setIsSellMode,
}),
shallow
)
const handleIconClick = useCallback(() => { const handleIconClick = useCallback(() => {
if (isSellMode && bagExpanded) {
resetSellAssets()
setIsSellMode(false)
}
setBagExpanded({ bagExpanded: !bagExpanded }) setBagExpanded({ bagExpanded: !bagExpanded })
}, [bagExpanded, isSellMode, resetSellAssets, setBagExpanded, setIsSellMode]) }, [bagExpanded, setBagExpanded])
useEffect(() => { useEffect(() => {
setBagQuantity(itemsInBag.length) setBagQuantity(itemsInBag.length)
......
import { Trans } from '@lingui/macro' import { Trans } from '@lingui/macro'
import { OpacityHoverState } from 'components/Common' import { OpacityHoverState } from 'components/Common'
import { BagCloseIcon } from 'nft/components/icons' import { BagCloseIcon } from 'nft/components/icons'
import { useMemo } from 'react'
import styled from 'styled-components/macro' import styled from 'styled-components/macro'
import { ButtonText, ThemedText } from 'theme' import { ButtonText, ThemedText } from 'theme'
...@@ -10,6 +11,10 @@ const ClearButton = styled(ButtonText)` ...@@ -10,6 +11,10 @@ const ClearButton = styled(ButtonText)`
font-weight: 600; font-weight: 600;
font-size: 14px; font-size: 14px;
line-height: 16px; line-height: 16px;
:active {
text-decoration: none;
}
` `
const IconWrapper = styled.button` const IconWrapper = styled.button`
...@@ -28,15 +33,17 @@ const IconWrapper = styled.button` ...@@ -28,15 +33,17 @@ const IconWrapper = styled.button`
${OpacityHoverState} ${OpacityHoverState}
` `
const CounterDot = styled.div` const CounterDot = styled.div<{ sizing: string }>`
align-items: center; align-items: center;
background-color: ${({ theme }) => theme.accentAction}; background-color: ${({ theme }) => theme.accentAction};
border-radius: 100px; border-radius: 100px;
font-weight: bold;
color: ${({ theme }) => theme.accentTextLightPrimary}; color: ${({ theme }) => theme.accentTextLightPrimary};
display: flex; display: flex;
font-size: 10px; font-size: 10px;
justify-content: center; justify-content: center;
min-width: 20px; min-width: ${({ sizing }) => sizing};
min-height: ${({ sizing }) => sizing};
padding: 4px 6px; padding: 4px 6px;
` `
const Wrapper = styled.div` const Wrapper = styled.div`
...@@ -55,13 +62,26 @@ interface BagHeaderProps { ...@@ -55,13 +62,26 @@ interface BagHeaderProps {
isProfilePage: boolean isProfilePage: boolean
} }
const BASE_SIZING = 14
const INCREMENTAL_SIZING = 6
const getCircleSizing = (numberOfAssets: number): string => {
const numberOfCharacters = numberOfAssets.toString().length
// each digit adds 6px worth of width (approximately), so I set the height and width to be 6px larger for each digit added
// 1 digit => 14 + 6, 2 digit 14 + 12, etc.
return `${BASE_SIZING + INCREMENTAL_SIZING * numberOfCharacters}px`
}
export const BagHeader = ({ numberOfAssets, closeBag, resetFlow, isProfilePage }: BagHeaderProps) => { export const BagHeader = ({ numberOfAssets, closeBag, resetFlow, isProfilePage }: BagHeaderProps) => {
const sizing = useMemo(() => getCircleSizing(numberOfAssets), [numberOfAssets])
return ( return (
<Wrapper> <Wrapper>
<ThemedText.HeadlineSmall>{isProfilePage ? <Trans>Sell</Trans> : <Trans>Bag</Trans>}</ThemedText.HeadlineSmall> <ThemedText.HeadlineSmall>{isProfilePage ? <Trans>Sell</Trans> : <Trans>Bag</Trans>}</ThemedText.HeadlineSmall>
{numberOfAssets > 0 && ( {numberOfAssets > 0 && (
<> <>
<CounterDot>{numberOfAssets}</CounterDot> <CounterDot sizing={sizing}>{numberOfAssets}</CounterDot>
<ClearButton onClick={resetFlow}>Clear all</ClearButton> <ClearButton onClick={resetFlow}>Clear all</ClearButton>
</> </>
)} )}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment