Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
8e2307cb
Unverified
Commit
8e2307cb
authored
Nov 15, 2022
by
aballerr
Committed by
GitHub
Nov 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: updating bag to not remove nfts on click (#5224)
* updating bag to not remove nfts on click
parent
5978d1ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
17 deletions
+26
-17
Bag.tsx
src/components/NavBar/Bag.tsx
+3
-14
BagHeader.tsx
src/nft/components/bag/BagHeader.tsx
+23
-3
No files found.
src/components/NavBar/Bag.tsx
View file @
8e2307cb
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
)
...
...
src/nft/components/bag/BagHeader.tsx
View file @
8e2307cb
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
>
</>
</>
)
}
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment