From 7368e0d0e64319b28445653047d27ee47ca48683 Mon Sep 17 00:00:00 2001 From: Danh Date: Thu, 5 Oct 2023 23:47:23 +0700 Subject: [PATCH 1/6] refactor --- src/components/SelectV2.tsx | 2 +- .../MultipleChainSelectV2/index.tsx | 24 +++++++++++++++++-- .../components/TokenFilter/index.tsx | 7 +++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/components/SelectV2.tsx b/src/components/SelectV2.tsx index 60e8d4ae92..e3c80c182b 100644 --- a/src/components/SelectV2.tsx +++ b/src/components/SelectV2.tsx @@ -159,7 +159,7 @@ function Select({ }) const updateCallback = useCallback(() => { - update && update() + update?.() }, [update]) useInterval(updateCallback, showMenu ? 100 : null) diff --git a/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx b/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx index 3b9b3f6bc9..49200680b6 100644 --- a/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx +++ b/src/pages/MyEarnings/MultipleChainSelectV2/index.tsx @@ -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' @@ -78,6 +78,20 @@ const MultipleChainSelect: React.FC = ({ className, st } } + useEffect(() => { + setLocalSelectedChains(selectedChains) + // eslint-disable-next-line + }, [selectedChains.length]) + + const selectAllRef = useRef(null) + useEffect(() => { + if (!selectAllRef.current) { + return + } + selectAllRef.current.indeterminate = + 0 < localSelectedChains.length && localSelectedChains.length < networkList.length + }, [localSelectedChains, networkList.length]) + return ( } options={options} + optionStyle={{ padding: 0 }} optionRender={item => { const network = Number(item?.value) as ChainId const config = NETWORKS_INFO[network] const isComingSoon = comingSoonList.includes(network) const isSelected = isComingSoon ? false : localSelectedChains.includes(network) const handleClick = (e: any) => { - if (isComingSoon) return e.stopPropagation() + if (isComingSoon) return if (isSelected) { setLocalSelectedChains(localSelectedChains.filter(chain => chain !== network)) } else { @@ -116,9 +132,8 @@ const MultipleChainSelect: React.FC = ({ className, st return ( = ({ className, st cursor: isComingSoon ? 'not-allowed' : 'pointer', userSelect: 'none', opacity: isComingSoon ? 0.6 : 1, + width: '100%', + padding: '10px 18px', }} > - - {config.name} - + ) @@ -153,11 +160,13 @@ const MultipleChainSelect: React.FC = ({ className, st return ( <> e.stopPropagation()} sx={{ alignItems: 'center', gap: '8px', padding: '10px 18px', + cursor: 'pointer', }} > = ({ className, st - + + {menu} + - + + { diff --git a/src/pages/TrueSightV2/components/TokenFilter/index.tsx b/src/pages/TrueSightV2/components/TokenFilter/index.tsx index b67c552753..6c8c4c27ef 100644 --- a/src/pages/TrueSightV2/components/TokenFilter/index.tsx +++ b/src/pages/TrueSightV2/components/TokenFilter/index.tsx @@ -174,6 +174,7 @@ export default function TokenFilter({ return { allChainIds, listSelects, chainFilter } }, [data]) + // chains when f5, from url const defaultChains = useMemo( () => getChainsFromSlugs(filter[chainFilter?.queryKey]?.split(',')), [filter, chainFilter], @@ -268,7 +269,12 @@ export default function TokenFilter({ )} - + { + setSelectChains(allChainIds) + onResetFilterSort() + }} + > {!upToSmall && Reset} From 8af43ba5d505da43a6636c93a652b73c3b4a9e09 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 6 Oct 2023 00:32:57 +0700 Subject: [PATCH 3/6] chore typo --- src/pages/TrueSightV2/components/TokenOverview.tsx | 2 +- .../components/shareContent/TokenAnalysisListShareContent.tsx | 2 +- src/pages/TrueSightV2/components/table/index.tsx | 4 ++-- src/pages/TrueSightV2/hooks/useRenderRankingList.tsx | 4 ++-- src/pages/TrueSightV2/pages/TokenAnalysisList.tsx | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/TrueSightV2/components/TokenOverview.tsx b/src/pages/TrueSightV2/components/TokenOverview.tsx index 6704b2187c..7f6530bd10 100644 --- a/src/pages/TrueSightV2/components/TokenOverview.tsx +++ b/src/pages/TrueSightV2/components/TokenOverview.tsx @@ -659,7 +659,7 @@ export const TokenOverview = ({ data, isLoading }: { data?: IAssetOverview; isLo isOpen={showShare} onClose={() => setShowShare(false)} content={mobileMode => } - title="Kyberscore" + title="KyberScore" onShareClick={social => mixpanelHandler(MIXPANEL_TYPE.KYBERAI_SHARE_TOKEN_CLICK, { token_name: data?.symbol?.toUpperCase(), diff --git a/src/pages/TrueSightV2/components/shareContent/TokenAnalysisListShareContent.tsx b/src/pages/TrueSightV2/components/shareContent/TokenAnalysisListShareContent.tsx index 3ddc233314..3f902a72f4 100644 --- a/src/pages/TrueSightV2/components/shareContent/TokenAnalysisListShareContent.tsx +++ b/src/pages/TrueSightV2/components/shareContent/TokenAnalysisListShareContent.tsx @@ -21,7 +21,7 @@ const mapTypeTitle = { [KyberAIListType.TRENDING_SOON]: t`Trending Soon Tokens`, [KyberAIListType.TRENDING]: t`Top Trending Tokens`, [KyberAIListType.FUNDING_RATE]: t`Funding Rates`, - [KyberAIListType.KYBERSWAP_DELTA]: t`Kyberscore Delta`, + [KyberAIListType.KYBERSWAP_DELTA]: t`KyberScore Delta`, } export default function TokenAnalysisListShareContent({ diff --git a/src/pages/TrueSightV2/components/table/index.tsx b/src/pages/TrueSightV2/components/table/index.tsx index f013cbc168..89fc194608 100644 --- a/src/pages/TrueSightV2/components/table/index.tsx +++ b/src/pages/TrueSightV2/components/table/index.tsx @@ -728,7 +728,7 @@ export const WidgetTable = ({ Token - Kyberscore + KyberScore Price | 24 Change @@ -1061,7 +1061,7 @@ export const TokenListInShareModalTable = ({ {!mobileMode && ( - Kyberscore + KyberScore )} diff --git a/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx b/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx index aec0a0a3bf..b4be1713a2 100644 --- a/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx +++ b/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx @@ -253,7 +253,7 @@ const renderByColumnType: Record< delay={200} > - Kyberscore + KyberScore @@ -398,7 +398,7 @@ const renderByColumnType: Record< tableHeader: ({ sortInfo, onChangeSort }) => ( onChangeSort?.(SORT_FIELD.KYBER_SCORE_DELTA)}> - Kyberscore Delta + KyberScore Delta diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index c9cd5bd42e..14f342330e 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -295,7 +295,7 @@ const tokenTypeList: { }, { type: KyberAIListType.KYBERSWAP_DELTA, - title: t`Kyberscore Delta`, + title: t`KyberScore Delta`, icon: 'bearish', tooltip: theme => ( From 98c7eaed5f0d110cb0634b7bf207c067b67ae1c5 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 6 Oct 2023 09:31:39 +0700 Subject: [PATCH 4/6] env --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index e19ada6545..3e5a39a3df 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -114,7 +114,7 @@ jobs: VITE_TAG: ${{ needs.prepare.outputs.image_tag }} CURRENT_BRANCH: ${{ needs.prepare.outputs.current_branch }} NODE_OPTIONS: '--max_old_space_size=4096' - run: yarn build-prod + run: yarn build-dev - name: Docker build and push From 936ba38154e4823aa3d15d7d1c98ba6099d66566 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 6 Oct 2023 10:05:00 +0700 Subject: [PATCH 5/6] css --- src/components/SelectV2.tsx | 2 +- src/hooks/useOnClickOutside.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/SelectV2.tsx b/src/components/SelectV2.tsx index 36bbab6504..ea18a5b388 100644 --- a/src/components/SelectV2.tsx +++ b/src/components/SelectV2.tsx @@ -22,7 +22,6 @@ const SelectWrapper = styled.div` padding: 12px; :hover { filter: brightness(1.2); - z-index: 10; } ` @@ -57,6 +56,7 @@ const SelectedWrap = styled.div` overflow: hidden; text-overflow: ellipsis; flex: 1; + user-select: none; ` export type SelectOption = { value?: string | number; label: ReactNode; onSelect?: () => void } diff --git a/src/hooks/useOnClickOutside.tsx b/src/hooks/useOnClickOutside.tsx index c2e36f9218..e11b3985f2 100644 --- a/src/hooks/useOnClickOutside.tsx +++ b/src/hooks/useOnClickOutside.tsx @@ -19,7 +19,7 @@ export function useOnClickOutside( if (nodes.some(node => node.current?.contains(e.target as Node) ?? false)) { return } - if (handlerRef.current) handlerRef.current() + handlerRef.current?.() } document.addEventListener(isMobile ? 'touchstart' : 'mousedown', handleClickOutside) From f13a8691e7bd232b67cba0f78f01d5f4a057cd53 Mon Sep 17 00:00:00 2001 From: Danh Date: Fri, 6 Oct 2023 10:26:14 +0700 Subject: [PATCH 6/6] revert env --- .github/workflows/pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 3e5a39a3df..e19ada6545 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -114,7 +114,7 @@ jobs: VITE_TAG: ${{ needs.prepare.outputs.image_tag }} CURRENT_BRANCH: ${{ needs.prepare.outputs.current_branch }} NODE_OPTIONS: '--max_old_space_size=4096' - run: yarn build-dev + run: yarn build-prod - name: Docker build and push