From e21a99f007234a124317e60a56700b9c1f0c0c1d Mon Sep 17 00:00:00 2001 From: dappbeast Date: Sat, 13 May 2023 14:33:57 +0900 Subject: [PATCH] feat: move positions to top of trade page, add collapse chart in advanced mode, move announcements below trade form --- .../components/common/MarketLabel/index.tsx | 2 +- .../common/PositionsTable/index.tsx | 1 + app/src/constants/announcements.ts | 2 +- app/src/constants/layout.ts | 2 +- .../TradeAnnouncementHeaderCard/index.tsx | 16 +- .../TradeMarketDropdownSpotPrice.tsx | 2 +- .../trade/TradePositionsCard/index.tsx | 97 +++---- .../containers/trade/TradePriceCard/index.tsx | 58 ++-- .../hooks/local_storage/useTraderSettings.ts | 2 + .../page_helpers/PositionPageHelper/index.tsx | 11 +- .../TradeHistoryPageHelper/index.tsx | 5 +- .../page_helpers/TradePageHelper/index.tsx | 256 ++++++++---------- .../page_helpers/common/Page/PageDesktop.tsx | 4 +- .../page_helpers/common/Page/PageMobile.tsx | 24 +- ui/components/Button/index.tsx | 3 - ui/components/List/ListItem.tsx | 2 +- 16 files changed, 218 insertions(+), 269 deletions(-) diff --git a/app/src/components/common/MarketLabel/index.tsx b/app/src/components/common/MarketLabel/index.tsx index b42b1084..748caeb9 100644 --- a/app/src/components/common/MarketLabel/index.tsx +++ b/app/src/components/common/MarketLabel/index.tsx @@ -18,7 +18,7 @@ export default function MarketLabel({ market, ...marginProps }: Props) { - {getMarketDisplayName(market)} + {getMarketDisplayName(market)} {market.name} diff --git a/app/src/components/common/PositionsTable/index.tsx b/app/src/components/common/PositionsTable/index.tsx index 4c4e7fa3..05080401 100644 --- a/app/src/components/common/PositionsTable/index.tsx +++ b/app/src/components/common/PositionsTable/index.tsx @@ -172,6 +172,7 @@ const PositionsTable = ({ positions, onClick, pageSize, ...styleProps }: Props) e.stopPropagation() setIsOpen(true) }} + variant="light" isOpen={isOpen} onClose={() => setIsOpen(false)} icon={IconType.MoreHorizontal} diff --git a/app/src/constants/announcements.ts b/app/src/constants/announcements.ts index 9da42ec7..bb8463fb 100644 --- a/app/src/constants/announcements.ts +++ b/app/src/constants/announcements.ts @@ -17,7 +17,7 @@ export type Announcement = { const ANNOUNCEMENTS: Announcement[] = [ { - id: 'arb-airdrop-5', + id: 'arbitrum-airdrop', title: '400k $ARB Airdrop', description: 'The Lyra DAO is airdropping 400k $ARB to traders and LPs over 8 weeks.', cta: { diff --git a/app/src/constants/layout.ts b/app/src/constants/layout.ts index b2a807c2..aa2e816c 100644 --- a/app/src/constants/layout.ts +++ b/app/src/constants/layout.ts @@ -11,7 +11,7 @@ export const VAULTS_CHART_HEIGHT = [120, 250] export const VAULTS_INDEX_CHART_HEIGHT = [120, 250] export const TRADE_CARD_MIN_WIDTH = 360 -export const TRADE_CARD_MIN_HEIGHT = 400 +export const TRADE_CARD_MIN_HEIGHT = 380 export const TRADE_CHAIN_STAT_COL_WIDTH = 90 export const TRADE_CHAIN_PRICE_COL_WIDTH = 110 diff --git a/app/src/containers/trade/TradeAnnouncementHeaderCard/index.tsx b/app/src/containers/trade/TradeAnnouncementHeaderCard/index.tsx index 6ddbfb2f..823044de 100644 --- a/app/src/containers/trade/TradeAnnouncementHeaderCard/index.tsx +++ b/app/src/containers/trade/TradeAnnouncementHeaderCard/index.tsx @@ -69,15 +69,15 @@ export default function TradeAnnouncementHeaderCard({ blockTimestamp }: Props) { } return displayedAnnouncement ? ( - + - + {displayedAnnouncement.graphic ? ( @@ -85,10 +85,10 @@ export default function TradeAnnouncementHeaderCard({ blockTimestamp }: Props) { ) : null} - + {displayedAnnouncement.title} - + diff --git a/app/src/containers/trade/TradeMarketDropdown/TradeMarketDropdownSpotPrice.tsx b/app/src/containers/trade/TradeMarketDropdown/TradeMarketDropdownSpotPrice.tsx index 137fe80e..c4d30da8 100644 --- a/app/src/containers/trade/TradeMarketDropdown/TradeMarketDropdownSpotPrice.tsx +++ b/app/src/containers/trade/TradeMarketDropdown/TradeMarketDropdownSpotPrice.tsx @@ -24,7 +24,7 @@ const TradeMarketDropdownSpotPrice = withSuspense( const color = change >= 0 ? 'primaryText' : 'errorText' return ( - {formatUSD(latestPrice)} + {formatUSD(latestPrice)} {formatPercentage(change)} diff --git a/app/src/containers/trade/TradePositionsCard/index.tsx b/app/src/containers/trade/TradePositionsCard/index.tsx index 6671c5f2..b6db8997 100644 --- a/app/src/containers/trade/TradePositionsCard/index.tsx +++ b/app/src/containers/trade/TradePositionsCard/index.tsx @@ -1,80 +1,61 @@ import Box from '@lyra/ui/components/Box' -import ToggleButton from '@lyra/ui/components/Button/ToggleButton' -import ToggleButtonItem from '@lyra/ui/components/Button/ToggleButtonItem' -import Card from '@lyra/ui/components/Card' +import Button from '@lyra/ui/components/Button' import CardSection from '@lyra/ui/components/Card/CardSection' import Flex from '@lyra/ui/components/Flex' +import { IconType } from '@lyra/ui/components/Icon' import Text from '@lyra/ui/components/Text' import { Position } from '@lyrafinance/lyra-js' -import React, { useState } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import PositionsTable from '@/app/components/common/PositionsTable' import { PageId } from '@/app/constants/pages' import getPagePath from '@/app/utils/getPagePath' -import TradeEventHistoryTable from './TradeEventHistoryTable' -import TradePositionHistoryTable from './TradePositionHistoryTable' - type Props = { openPositions: Position[] } -type PositionTableState = 'closed' | 'trades' | 'open' - -const POSITION_TABS: { id: PositionTableState; label: string }[] = [ - { id: 'open', label: 'Open' }, - { id: 'closed', label: 'Closed' }, - { id: 'trades', label: 'Trades' }, -] - const TradePositionsCard = ({ openPositions }: Props) => { - const [selectedItem, setSelectedItem] = useState('open') const navigate = useNavigate() return ( - - - - - {POSITION_TABS.map(item => ( - setSelectedItem(id)} - /> - ))} - + <> + + + Open Positions +