Skip to content

Commit

Permalink
fix: remove obsolete button (#2053)
Browse files Browse the repository at this point in the history
* remove futures markets button and clean unused code

* futures markets table now sortable by market

* remote obsolete futures market button from overview dashboard page

* Sort futures market table by market on mobile

* replace old obsolete Futures Markets Button by a subheader

* fix lint warning

---------

Co-authored-by: platschi <platschi@posteo.org>
  • Loading branch information
Flocqst and platschi authored Mar 2, 2023
1 parent 9fedec0 commit 8007b7b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const FuturesMarketsTable: FC = () => {
);
},
width: 190,
sortable: true,
},
{
Header: (
Expand Down Expand Up @@ -305,6 +306,7 @@ const FuturesMarketsTable: FC = () => {
);
},
width: 145,
sortable: true,
},
{
Header: () => (
Expand Down
32 changes: 2 additions & 30 deletions sections/dashboard/Markets/Markets.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
import { FC, useState, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { FC, useState } from 'react';

import TabButton from 'components/Button/TabButton';
import { DesktopOnlyView } from 'components/Media';
import { TabPanel } from 'components/Tab';

import FuturesMarketsTable from '../FuturesMarketsTable';
import { TabButtonsContainer } from '../History/History';

export enum MarketsTab {
FUTURES = 'futures',
SPOT = 'spot',
}

const Markets: FC = () => {
const { t } = useTranslation();

const [activeMarketsTab, setActiveMarketsTab] = useState<MarketsTab>(MarketsTab.FUTURES);

const MARKETS_TABS = useMemo(
() => [
{
name: MarketsTab.FUTURES,
label: t('dashboard.overview.markets-tabs.futures'),
active: activeMarketsTab === MarketsTab.FUTURES,
onClick: () => {
setActiveMarketsTab(MarketsTab.FUTURES);
},
},
],
[activeMarketsTab, t]
);
const [activeMarketsTab] = useState<MarketsTab>(MarketsTab.FUTURES);

return (
<>
<DesktopOnlyView>
<TabButtonsContainer>
{MARKETS_TABS.map(({ name, label, active, onClick }) => (
<TabButton key={name} title={label} active={active} onClick={onClick} />
))}
</TabButtonsContainer>
</DesktopOnlyView>

<TabPanel name={MarketsTab.FUTURES} activeTab={activeMarketsTab}>
<FuturesMarketsTable />
</TabPanel>
Expand Down
30 changes: 11 additions & 19 deletions sections/dashboard/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TabButton from 'components/Button/TabButton';
import { DesktopOnlyView, MobileOrTabletView } from 'components/Media';
import FuturesIcon from 'components/Nav/FuturesIcon';
import { TabPanel } from 'components/Tab';
import * as Text from 'components/Text';
import { ETH_ADDRESS, ETH_COINGECKO_ADDRESS } from 'constants/currency';
import Connector from 'containers/Connector';
import { FuturesAccountTypes } from 'queries/futures/types';
Expand Down Expand Up @@ -47,7 +48,7 @@ const Overview: FC = () => {
const [activePositionsTab, setActivePositionsTab] = useState<PositionsTab>(
PositionsTab.ISOLATED_MARGIN
);
const [activeMarketsTab, setActiveMarketsTab] = useState<MarketsTab>(MarketsTab.FUTURES);
const [activeMarketsTab] = useState<MarketsTab>(MarketsTab.FUTURES);

const { network, synthsMap } = Connector.useContainer();

Expand Down Expand Up @@ -158,18 +159,6 @@ const Overview: FC = () => {
setActivePositionsTab,
]);

const MARKETS_TABS = useMemo(
() => [
{
name: MarketsTab.FUTURES,
label: t('dashboard.overview.markets-tabs.futures'),
active: activeMarketsTab === MarketsTab.FUTURES,
onClick: () => setActiveMarketsTab(MarketsTab.FUTURES),
},
],
[activeMarketsTab, setActiveMarketsTab, t]
);

return (
<>
<DesktopOnlyView>
Expand Down Expand Up @@ -198,12 +187,7 @@ const Overview: FC = () => {
<TabPanel name={PositionsTab.SPOT} activeTab={activePositionsTab}>
<SynthBalancesTable exchangeTokens={exchangeTokens} />
</TabPanel>

<TabButtonsContainer>
{MARKETS_TABS.map(({ name, label, active, onClick }) => (
<TabButton key={name} title={label} active={active} onClick={onClick} />
))}
</TabButtonsContainer>
<SubHeading>{t('dashboard.overview.markets-tabs.futures')}</SubHeading>
<TabPanel name={MarketsTab.FUTURES} activeTab={activeMarketsTab}>
<FuturesMarketsTable />
</TabPanel>
Expand All @@ -227,4 +211,12 @@ const TabButtonsContainer = styled.div`
}
`;

const SubHeading = styled(Text.Heading).attrs({ variant: 'h4' })`
font-family: ${(props) => props.theme.fonts.bold};
font-size: 16px;
margin-top: 20px;
font-variant: all-small-caps;
color: ${(props) => props.theme.colors.selectedTheme.yellow};
`;

export default Overview;

1 comment on commit 8007b7b

@vercel
Copy link

@vercel vercel bot commented on 8007b7b Mar 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kwenta-storybook – ./

kwenta-storybook-kwenta.vercel.app
kwenta-storybook-git-perps-v2-dev-kwenta.vercel.app

Please sign in to comment.