Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenhoaidanh committed Oct 5, 2023
1 parent a345834 commit 7368e0d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/SelectV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function Select({
})

const updateCallback = useCallback(() => {
update && update()
update?.()
}, [update])

useInterval(updateCallback, showMenu ? 100 : null)
Expand Down
24 changes: 22 additions & 2 deletions src/pages/MyEarnings/MultipleChainSelectV2/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChainId } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { rgba } from 'polished'
import { ReactNode, useState } from 'react'
import { ReactNode, useEffect, useRef, useState } from 'react'
import { Box, Flex, Text } from 'rebass'
import styled, { CSSProperties } from 'styled-components'

Expand Down Expand Up @@ -78,6 +78,20 @@ const MultipleChainSelect: React.FC<MultipleChainSelectProps> = ({ className, st
}
}

useEffect(() => {
setLocalSelectedChains(selectedChains)
// eslint-disable-next-line
}, [selectedChains.length])

const selectAllRef = useRef<HTMLInputElement>(null)
useEffect(() => {
if (!selectAllRef.current) {
return
}
selectAllRef.current.indeterminate =
0 < localSelectedChains.length && localSelectedChains.length < networkList.length
}, [localSelectedChains, networkList.length])

return (
<Select
className={className}
Expand Down Expand Up @@ -146,7 +160,13 @@ const MultipleChainSelect: React.FC<MultipleChainSelectProps> = ({ className, st
padding: '10px 18px',
}}
>
<Checkbox type="checkbox" id="checkAllChain" checked={isAllSelected} onChange={onChangeChain} />
<Checkbox
ref={selectAllRef}
type="checkbox"
id="checkAllChain"
checked={isAllSelected}
onChange={onChangeChain}
/>

<Flex width="20px" alignItems="center" justifyContent="center">
<LogoKyber width="14px" height="auto" color={theme.primary} />
Expand Down
7 changes: 6 additions & 1 deletion src/pages/TrueSightV2/components/TokenFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ const SelectGroup = styled.div`
width: 100%;
height: 100%;
padding-right: 150px;
overflow-x: scroll;
scroll-snap-type: x mandatory;
> * {
scroll-snap-align: start;
}
`}
`

Expand Down Expand Up @@ -219,7 +224,7 @@ export default function TokenFilter({

return (
<StyledWrapper>
<SelectGroup style={{ overflowX: 'scroll' }}>
<SelectGroup>
{showLoading ? (
new Array(isWatchlistTab ? 5 : 4)
.fill(0)
Expand Down

0 comments on commit 7368e0d

Please sign in to comment.