Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom watchlist #2236

Merged
merged 78 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
b833068
UI for new custom watchlist
XiaoYhun Aug 21, 2023
2aee781
update custom watchlist for list page
XiaoYhun Aug 22, 2023
8aeae1f
fix warning
XiaoYhun Aug 28, 2023
0fe9a1f
Merge remote-tracking branch 'origin/main' into custom-watchlist
XiaoYhun Sep 13, 2023
376413d
Merge remote-tracking branch 'origin/main' into custom-watchlist
XiaoYhun Sep 18, 2023
3f1bd9c
hide variants in list
XiaoYhun Sep 18, 2023
c28370d
Merge remote-tracking branch 'origin/main' into custom-watchlist
XiaoYhun Sep 26, 2023
f406798
intergrate new watchlist apis
XiaoYhun Sep 28, 2023
ec9577e
Merge remote-tracking branch 'origin/main' into custom-watchlist
XiaoYhun Sep 28, 2023
d34cdd3
fix warning
XiaoYhun Sep 28, 2023
c0b0024
update max limit watchlist
XiaoYhun Sep 29, 2023
045a496
Kyberai filter sort (#2182)
nguyenhoaidanh Sep 29, 2023
93b077e
add watch list filter
nguyenhoaidanh Sep 29, 2023
450867a
fix: lint
nguyenhoaidanh Sep 29, 2023
5ee3fb6
add funding rates + kyberscore delta
XiaoYhun Sep 29, 2023
6cc6bd6
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Sep 29, 2023
8cd1dbd
split watchlist select
nguyenhoaidanh Sep 29, 2023
7ca4c45
api assets
nguyenhoaidanh Sep 29, 2023
0e481fd
reset filter/sort after change tab
nguyenhoaidanh Sep 29, 2023
48c9bb4
add sort to table
nguyenhoaidanh Sep 30, 2023
faf24dd
add default sort params by tab
nguyenhoaidanh Oct 2, 2023
a174589
remove: hardcode watchlist params
nguyenhoaidanh Oct 2, 2023
dca9dc2
update name price 7d
nguyenhoaidanh Oct 2, 2023
a67b083
fix: wrong order score
nguyenhoaidanh Oct 2, 2023
51dd5f6
fix loop api
nguyenhoaidanh Oct 2, 2023
2b74ee3
Merge branch 'watchlist-test' into custom-watchlist
nguyenhoaidanh Oct 2, 2023
13b9e5e
display default sort icon in each tab
nguyenhoaidanh Oct 2, 2023
2bb931d
improve watchlist flow
XiaoYhun Oct 3, 2023
f2ff498
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Oct 3, 2023
a16d8bb
feat: Krystal walletconnect (#2246)
namgold Oct 3, 2023
38e0cc6
refactor
nguyenhoaidanh Oct 3, 2023
6c517d7
Merge branch 'main' into custom-watchlist
nguyenhoaidanh Oct 3, 2023
e061d22
add 2 new tab default sort
XiaoYhun Oct 3, 2023
50b2a49
fix page size wrong param name
XiaoYhun Oct 3, 2023
e511c8a
update default sort
nguyenhoaidanh Oct 3, 2023
f93f005
use kyberScore field
nguyenhoaidanh Oct 3, 2023
8c10ddd
chore: use kyberscore/tag p2
nguyenhoaidanh Oct 3, 2023
4b18f1a
add default field 2 new tabs
nguyenhoaidanh Oct 3, 2023
945fe75
update dropdown like desgin
nguyenhoaidanh Oct 3, 2023
a562fd9
fix: zindex filter vs loading vs token name
nguyenhoaidanh Oct 3, 2023
d9cdd45
fix: can not see select in mobile
nguyenhoaidanh Oct 3, 2023
610d152
update total watchlist
nguyenhoaidanh Oct 3, 2023
8051471
refactor ranking list rendering
XiaoYhun Oct 4, 2023
e289755
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Oct 4, 2023
e177d5c
fix some bugs
XiaoYhun Oct 4, 2023
8fd248b
update default sort funding rate
nguyenhoaidanh Oct 4, 2023
a577cb8
add secondary sort for funding raise
nguyenhoaidanh Oct 4, 2023
05d172d
fix: dont set default arrow sort when init page
nguyenhoaidanh Oct 4, 2023
03d99c0
fix: sort params undefined text
nguyenhoaidanh Oct 4, 2023
d121f4d
update some feedback
nguyenhoaidanh Oct 4, 2023
5143dab
chore: refactor props
nguyenhoaidanh Oct 4, 2023
b312454
fix some small improvements
XiaoYhun Oct 4, 2023
0d8b7e6
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Oct 4, 2023
30d08bf
fix max limit disabled unwatchlist
XiaoYhun Oct 4, 2023
c99aa2f
fix error breaking text line
XiaoYhun Oct 4, 2023
9be75e0
fix looping api
XiaoYhun Oct 4, 2023
40734df
update widget watchlist dropdown
XiaoYhun Oct 4, 2023
288b657
fix: crash when wrong listType + update msg error
nguyenhoaidanh Oct 4, 2023
e3c8e43
invalidate myWatchlist tag on profile change
XiaoYhun Oct 4, 2023
5b200dd
update kyberscore delta logic
XiaoYhun Oct 4, 2023
6d0786e
update kyberscore delta color
XiaoYhun Oct 4, 2023
ab5f0db
small refactor
nguyenhoaidanh Oct 4, 2023
3dc1527
fix small issues
XiaoYhun Oct 5, 2023
06ce2e6
add reset filter btn
nguyenhoaidanh Oct 5, 2023
5ef0e6e
fix comment
XiaoYhun Oct 5, 2023
2d1de78
update new annoucement modal
XiaoYhun Oct 5, 2023
dbbbf7f
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Oct 5, 2023
50d4afc
fix missing button onclick
XiaoYhun Oct 5, 2023
6a8cfa5
temporary skip navigating on banner
XiaoYhun Oct 5, 2023
d5b411a
fix missing image on mobile
XiaoYhun Oct 5, 2023
08db116
Merge branch 'main' into custom-watchlist
XiaoYhun Oct 5, 2023
d3ee9da
update padding
nguyenhoaidanh Oct 5, 2023
d1da0db
add template ids
nguyenhoaidanh Oct 5, 2023
618c455
fix warning
XiaoYhun Oct 5, 2023
1b44968
Merge branch 'custom-watchlist' of https://github.com/KyberNetwork/ky…
XiaoYhun Oct 5, 2023
11bce98
create new select
nguyenhoaidanh Oct 5, 2023
e07216c
css
nguyenhoaidanh Oct 5, 2023
9ba3c40
revert
nguyenhoaidanh Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
NODE_OPTIONS: '--max_old_space_size=4096'
run: yarn build-prod


- name: Docker build and push
uses: docker/build-push-action@v2
with:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 46 additions & 35 deletions src/assets/svg/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Announcement/AnnoucementView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export default function AnnouncementView({
height={height}
width={width}
itemCount={itemCount}
itemSize={isMyInboxTab ? 116 : 126}
itemSize={isMyInboxTab ? 120 : 126}
onItemsRendered={onItemsRendered}
ref={ref}
>
Expand Down
1 change: 1 addition & 0 deletions src/components/Announcement/PrivateAnnoucement/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mapIcon: Partial<{ [type in PrivateAnnouncementType]: ReactNode }> = {
[PrivateAnnouncementType.LIMIT_ORDER]: <LimitOrderIcon />,
[PrivateAnnouncementType.ELASTIC_POOLS]: <LiquidityIcon />,
[PrivateAnnouncementType.KYBER_AI]: <ApeIcon size={18} />,
[PrivateAnnouncementType.KYBER_AI_WATCHLIST]: <ApeIcon size={18} />,
[PrivateAnnouncementType.PRICE_ALERT]: <AlarmIcon style={{ width: 17, height: 17 }} />,
[PrivateAnnouncementType.DIRECT_MESSAGE]: <Bell style={{ width: 17, height: 17 }} />,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Trans } from '@lingui/macro'
import { useNavigate } from 'react-router-dom'
import { Flex, Text } from 'rebass'
import styled from 'styled-components'

import { PrivateAnnouncementProp } from 'components/Announcement/PrivateAnnoucement'
import InboxIcon from 'components/Announcement/PrivateAnnoucement/Icon'
import { Dot, InboxItemRow, InboxItemWrapper, RowItem, Title } from 'components/Announcement/PrivateAnnoucement/styled'
import { AnnouncementTemplateTrendingSoon } from 'components/Announcement/type'
import { AnnouncementTemplateKyberAI } from 'components/Announcement/type'
import DiscoverIcon from 'components/Icons/DiscoverIcon'
import Icon from 'components/Icons/Icon'
import DeltaTokenAmount from 'components/WalletPopup/Transactions/DeltaTokenAmount'
import { TokenLogoWithShadow } from 'components/Logo'
import { APP_PATHS } from 'constants/index'
import useTheme from 'hooks/useTheme'

Expand All @@ -18,12 +19,31 @@ const ItemWrapper = styled.div<{ color: string }>`
gap: 4px;
color: ${({ color }) => color};
`
const TokenDetail = ({
color,
symbol,
logoURL,
fontSize,
}: {
color: string
logoURL: string
symbol: string
fontSize: string
}) => (
<Flex color={color} alignItems={'center'} sx={{ gap: '4px', fontSize }}>
<TokenLogoWithShadow srcs={[logoURL]} size={fontSize} />
{symbol}
</Flex>
)

export const TokenInfo = ({
templateBody,
type,
fontSize = '12px',
}: {
templateBody: AnnouncementTemplateTrendingSoon
templateBody: AnnouncementTemplateKyberAI
type: 'bullish' | 'bearish' | 'trending'
fontSize?: string
}) => {
const theme = useTheme()
const {
Expand All @@ -41,9 +61,12 @@ export const TokenInfo = ({
case 'bullish':
return (
<ItemWrapper color={theme.apr}>
<Icon id="bullish" size={14} /> <Trans>Bullish:</Trans>
<DeltaTokenAmount
amount={null}
<Icon id="bullish" size={14} />{' '}
<Text as="span" fontSize={fontSize}>
<Trans>Bullish:</Trans>
</Text>
<TokenDetail
fontSize={fontSize}
logoURL={bullishTokenLogoURL}
color={theme.text}
symbol={`${bullishTokenSymbol} (${bullishTokenScore})`}
Expand All @@ -53,9 +76,12 @@ export const TokenInfo = ({
case 'bearish':
return (
<ItemWrapper color={theme.red}>
<Icon id="bearish" size={12} /> <Trans>Bearish:</Trans>
<DeltaTokenAmount
amount={null}
<Icon id="bearish" size={12} />{' '}
<Text as="span" fontSize={fontSize}>
<Trans>Bearish:</Trans>
</Text>
<TokenDetail
fontSize={fontSize}
logoURL={bearishTokenLogoURL}
color={theme.text}
symbol={`${bearishTokenSymbol} (${bearishTokenScore})`}
Expand All @@ -65,9 +91,12 @@ export const TokenInfo = ({
case 'trending':
return (
<ItemWrapper color={theme.text}>
<DiscoverIcon size={12} /> <Trans>Trending Soon:</Trans>
<DeltaTokenAmount
amount={null}
<DiscoverIcon size={12} />{' '}
<Text as="span" fontSize={fontSize}>
<Trans>Trending Soon:</Trans>
</Text>
<TokenDetail
fontSize={fontSize}
logoURL={trendingSoonTokenLogoURL}
color={theme.text}
symbol={`${trendingSoonTokenSymbol} (${trendingSoonTokenScore})`}
Expand All @@ -83,7 +112,7 @@ function InboxItemBridge({
style,
time,
title,
}: PrivateAnnouncementProp<AnnouncementTemplateTrendingSoon>) {
}: PrivateAnnouncementProp<AnnouncementTemplateKyberAI>) {
const { templateBody, isRead, templateType } = announcement

const navigate = useNavigate()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { useNavigate } from 'react-router-dom'
import { Text } from 'rebass'
import styled from 'styled-components'

import { PrivateAnnouncementProp } from 'components/Announcement/PrivateAnnoucement'
import InboxIcon from 'components/Announcement/PrivateAnnoucement/Icon'
import { Dot, InboxItemRow, InboxItemWrapper, RowItem, Title } from 'components/Announcement/PrivateAnnoucement/styled'
import { AnnouncementTemplateKyberAIWatchlist, TokenInfoWatchlist } from 'components/Announcement/type'
import Column from 'components/Column'
import { TokenLogoWithShadow } from 'components/Logo'
import { APP_PATHS } from 'constants/index'
import useTheme from 'hooks/useTheme'
import { calculateValueToColor, getTypeByKyberScore } from 'pages/TrueSightV2/utils'
import { formatDisplayNumber } from 'utils/numbers'

const ItemWrapper = styled.div`
display: flex;
align-items: center;
gap: 8px;
`
export const TokenInfo = ({
showPrice = true,
logoSize = '12px',
token,
}: {
showPrice?: boolean
logoSize?: string
token: TokenInfoWatchlist
}) => {
const theme = useTheme()
const { logoURL, symbol, price, priceChange, kyberScore } = token || {}
return (
<ItemWrapper>
<TokenLogoWithShadow srcs={[logoURL]} size={logoSize} />
<Column gap="4px" fontSize={logoSize}>
<Text color={theme.text}>
{symbol}{' '}
<Text as="span" color={calculateValueToColor(+kyberScore, theme)}>
{kyberScore} ({getTypeByKyberScore(+kyberScore)})
</Text>
</Text>
{showPrice && (
<Text>
<Text as="span" color={theme.text}>
{formatDisplayNumber(price, { style: 'currency', significantDigits: 4 })}
</Text>{' '}
<Text as="span" color={+priceChange > 0 ? theme.apr : theme.red}>
({+priceChange > 0 && '+'}
{formatDisplayNumber(+priceChange / 100, { style: 'percent', fractionDigits: 2, allowNegative: true })})
</Text>
</Text>
)}
</Column>
</ItemWrapper>
)
}

function InboxItemBridge({
announcement,
onRead,
style,
time,
title,
}: PrivateAnnouncementProp<AnnouncementTemplateKyberAIWatchlist>) {
const { templateBody, isRead, templateType } = announcement
const { assets = [] } = templateBody || {}
const [token1, token2, token3] = assets

const navigate = useNavigate()
const onClick = () => {
navigate(APP_PATHS.KYBERAI_RANKINGS)
onRead(announcement, 'kyberAI_watchlist')
}

return (
<InboxItemWrapper isRead={isRead} onClick={onClick} style={{ ...style, paddingTop: '8px', gap: '6px' }}>
<InboxItemRow>
<RowItem>
<InboxIcon type={templateType} />
<Title isRead={isRead}>{title}</Title>
{!isRead && <Dot />}
</RowItem>
</InboxItemRow>

<InboxItemRow>
{token1 && <TokenInfo token={token1} />}
{token2 && <TokenInfo token={token2} />}
</InboxItemRow>

<InboxItemRow style={{ alignItems: 'center' }}>
{token3 ? <TokenInfo token={token3} /> : <div />}
{time}
</InboxItemRow>
</InboxItemWrapper>
)
}
export default InboxItemBridge
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { useNavigate } from 'react-router-dom'
import { Flex } from 'rebass'

import InboxIcon from 'components/Announcement/PrivateAnnoucement/Icon'
import { TokenInfo } from 'components/Announcement/PrivateAnnoucement/InboxItemTrendingSoon'
import { TokenInfo } from 'components/Announcement/PrivateAnnoucement/InboxItemKyberAI'
import { PrivateAnnouncementPropCenter } from 'components/Announcement/PrivateAnnoucement/NotificationCenter'
import { AnnouncementTemplateTrendingSoon } from 'components/Announcement/type'
import { AnnouncementTemplateKyberAI } from 'components/Announcement/type'
import { APP_PATHS } from 'constants/index'
import useTheme from 'hooks/useTheme'
import { formatTime } from 'utils/time'
Expand All @@ -15,7 +15,7 @@ import { Desc, Time, Title, Wrapper } from './styled'
export default function AnnouncementItem({
announcement,
title,
}: PrivateAnnouncementPropCenter<AnnouncementTemplateTrendingSoon>) {
}: PrivateAnnouncementPropCenter<AnnouncementTemplateKyberAI>) {
const { sentAt, templateType, templateBody } = announcement
const theme = useTheme()
const navigate = useNavigate()
Expand All @@ -32,10 +32,10 @@ export default function AnnouncementItem({
</Flex>
</Flex>
<Desc style={{ gap: 6, flexWrap: 'wrap', color: theme.subText }}>
<Trans>Here are our top tokens by KyberAI</Trans>
<TokenInfo templateBody={templateBody} type="bullish" />,
<TokenInfo templateBody={templateBody} type="bearish" />,
<TokenInfo templateBody={templateBody} type="trending" />
<Trans>Here are our top tokens by KyberAI:</Trans>
<TokenInfo templateBody={templateBody} type="bullish" fontSize="14px" />,
<TokenInfo templateBody={templateBody} type="bearish" fontSize="14px" />,
<TokenInfo templateBody={templateBody} type="trending" fontSize="14px" />
</Desc>
</Wrapper>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Trans } from '@lingui/macro'
import { Fragment, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { Flex } from 'rebass'
import styled from 'styled-components'

import { ReactComponent as DropdownSVG } from 'assets/svg/down.svg'
import InboxIcon from 'components/Announcement/PrivateAnnoucement/Icon'
import { TokenInfo } from 'components/Announcement/PrivateAnnoucement/InboxItemKyberAIWatchList'
import { PrivateAnnouncementPropCenter } from 'components/Announcement/PrivateAnnoucement/NotificationCenter'
import { AnnouncementTemplateKyberAIWatchlist } from 'components/Announcement/type'
import { APP_PATHS } from 'constants/index'
import useTheme from 'hooks/useTheme'
import { formatTime } from 'utils/time'

import { ArrowWrapper, Desc, Time, Title, Wrapper } from './styled'

const Detail = styled.div`
display: grid;
width: 100%;
grid-template-columns: 1fr 1fr;
gap: 12px;
`

export default function AnnouncementItem({
announcement,
title,
}: PrivateAnnouncementPropCenter<AnnouncementTemplateKyberAIWatchlist>) {
const { sentAt, templateType, templateBody } = announcement
const { assets = [] } = templateBody || {}
const theme = useTheme()
const navigate = useNavigate()
const [expand, setExpand] = useState(false)
const slice = 3
const minimalAssets = assets.slice(0, slice)

return (
<Wrapper onClick={() => setExpand(!expand)}>
<Flex justifyContent="space-between" width="100%">
<Title onClick={() => navigate(APP_PATHS.KYBERAI_RANKINGS)}>
<InboxIcon type={templateType} />
{title}
</Title>
<Flex alignItems={'center'}>
<Time>{formatTime(sentAt)} </Time>
<ArrowWrapper data-expanded={expand}>
<DropdownSVG />
</ArrowWrapper>
</Flex>
</Flex>
<Desc style={{ gap: 6, flexWrap: 'wrap', color: theme.subText }}>
<Trans>Here is an update on the tokens in your watchlist:</Trans>
{!expand &&
minimalAssets.map((token, i) => (
<Fragment key={i}>
<TokenInfo token={token} showPrice={false} key={i} logoSize={'14px'} />
{i === minimalAssets.length - 1 ? (minimalAssets.length < slice ? '' : ', ...') : ', '}
</Fragment>
))}
</Desc>
{expand && (
<Detail>
{assets.map((token, i) => (
<TokenInfo token={token} key={i} showPrice logoSize={'14px'} />
))}
</Detail>
)}
</Wrapper>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,7 @@ import { NETWORKS_INFO } from 'constants/networks'
import useTheme from 'hooks/useTheme'
import { formatTime } from 'utils/time'

import { Desc, Time, Title, Wrapper } from './styled'

const ArrowWrapper = styled.div`
width: 20px;
height: 20px;
color: ${({ theme }) => theme.subText};
display: flex;
justify-content: center;
align-items: center;
svg {
transition: all 150ms ease-in-out;
}
&[data-expanded='true'] {
svg {
transform: rotate(180deg);
}
}
`
import { ArrowWrapper, Desc, Time, Title, Wrapper } from './styled'

const Detail = styled(Desc)`
flex-direction: column;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import { AnnouncementTemplate, PrivateAnnouncement, PrivateAnnouncementType } fr

import Bridge from './Bridge'
import CrossChain from './CrossChain'
import KyberAI from './KyberAI'
import KyberAIWatchlist from './KyberAIWatchlist'
import LimitOrder from './LimitOrder'
import PoolPosition from './PoolPosition'
import PriceAlert from './PriceAlert'
import PrivateMessage from './PrivateMessage'
import TrendingSoon from './TrendingSoon'

export type PrivateAnnouncementPropCenter<T extends AnnouncementTemplate = AnnouncementTemplate> = {
announcement: PrivateAnnouncement<T>
Expand All @@ -24,7 +25,8 @@ const ANNOUNCEMENT_MAP_IN_CENTER = {
[PrivateAnnouncementType.LIMIT_ORDER]: LimitOrder,
[PrivateAnnouncementType.BRIDGE_ASSET]: Bridge,
[PrivateAnnouncementType.CROSS_CHAIN]: CrossChain,
[PrivateAnnouncementType.KYBER_AI]: TrendingSoon,
[PrivateAnnouncementType.KYBER_AI]: KyberAI,
[PrivateAnnouncementType.KYBER_AI_WATCHLIST]: KyberAIWatchlist,
[PrivateAnnouncementType.PRICE_ALERT]: PriceAlert,
[PrivateAnnouncementType.DIRECT_MESSAGE]: PrivateMessage,
} as PrivateAnnouncementCenterMap
Expand Down
Loading
Loading