move trading views to react helpers
This commit is contained in:
parent
eed2f08bc9
commit
351cd77f84
@ -1,8 +1,8 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||||
import { useState, ReactNode } from 'react';
|
import { useState, ReactNode } from 'react';
|
||||||
|
import { TradingView, TradingViews } from '@vegaprotocol/react-helpers';
|
||||||
import { Market_market } from './__generated__/Market';
|
import { Market_market } from './__generated__/Market';
|
||||||
import { View, Views } from './trading-components';
|
|
||||||
import { GridTab, GridTabs } from './grid-tabs';
|
import { GridTab, GridTabs } from './grid-tabs';
|
||||||
|
|
||||||
interface TradeGridProps {
|
interface TradeGridProps {
|
||||||
@ -22,10 +22,10 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
<h1>Market: {market.name}</h1>
|
<h1>Market: {market.name}</h1>
|
||||||
</header>
|
</header>
|
||||||
<TradeGridChild className="col-start-1 col-end-2">
|
<TradeGridChild className="col-start-1 col-end-2">
|
||||||
<Views.chart />
|
<TradingViews.chart />
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
<TradeGridChild className="row-start-1 row-end-3">
|
<TradeGridChild className="row-start-1 row-end-3">
|
||||||
<Views.ticket />
|
<TradingViews.ticket />
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
<TradeGridChild className="row-start-1 row-end-3">
|
<TradeGridChild className="row-start-1 row-end-3">
|
||||||
<GridTabs group="trade">
|
<GridTabs group="trade">
|
||||||
@ -33,20 +33,20 @@ export const TradeGrid = ({ market }: TradeGridProps) => {
|
|||||||
<pre>{JSON.stringify(market.trades, null, 2)}</pre>
|
<pre>{JSON.stringify(market.trades, null, 2)}</pre>
|
||||||
</GridTab>
|
</GridTab>
|
||||||
<GridTab name="orderbook">
|
<GridTab name="orderbook">
|
||||||
<Views.orderbook />
|
<TradingViews.orderbook />
|
||||||
</GridTab>
|
</GridTab>
|
||||||
</GridTabs>
|
</GridTabs>
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
<TradeGridChild className="col-span-3">
|
<TradeGridChild className="col-span-3">
|
||||||
<GridTabs group="portfolio">
|
<GridTabs group="portfolio">
|
||||||
<GridTab name="orders">
|
<GridTab name="orders">
|
||||||
<Views.orders />
|
<TradingViews.orders />
|
||||||
</GridTab>
|
</GridTab>
|
||||||
<GridTab name="positions">
|
<GridTab name="positions">
|
||||||
<Views.positions />
|
<TradingViews.positions />
|
||||||
</GridTab>
|
</GridTab>
|
||||||
<GridTab name="collateral">
|
<GridTab name="collateral">
|
||||||
<Views.collateral />
|
<TradingViews.collateral />
|
||||||
</GridTab>
|
</GridTab>
|
||||||
</GridTabs>
|
</GridTabs>
|
||||||
</TradeGridChild>
|
</TradeGridChild>
|
||||||
@ -79,10 +79,10 @@ interface TradePanelsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const TradePanels = ({ market }: TradePanelsProps) => {
|
export const TradePanels = ({ market }: TradePanelsProps) => {
|
||||||
const [view, setView] = useState<View>('chart');
|
const [view, setView] = useState<TradingView>('chart');
|
||||||
|
|
||||||
const renderView = () => {
|
const renderView = () => {
|
||||||
const Component = Views[view];
|
const Component = TradingViews[view];
|
||||||
|
|
||||||
if (!Component) {
|
if (!Component) {
|
||||||
throw new Error(`No component for view: ${view}`);
|
throw new Error(`No component for view: ${view}`);
|
||||||
@ -104,7 +104,7 @@ export const TradePanels = ({ market }: TradePanelsProps) => {
|
|||||||
</AutoSizer>
|
</AutoSizer>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-nowrap gap-2 bg-neutral-200 border-neutral-200 border-t overflow-x-auto">
|
<div className="flex flex-nowrap gap-2 bg-neutral-200 border-neutral-200 border-t overflow-x-auto">
|
||||||
{Object.keys(Views).map((key: View) => {
|
{Object.keys(TradingViews).map((key: TradingView) => {
|
||||||
const className = classNames(
|
const className = classNames(
|
||||||
'p-8',
|
'p-8',
|
||||||
'border-t',
|
'border-t',
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from './lib/react-helpers';
|
export * from './lib/react-helpers';
|
||||||
|
export * from './lib/trading';
|
||||||
|
@ -5,9 +5,9 @@ export const Orders = () => <div>TODO: Orders</div>;
|
|||||||
export const Positions = () => <div>TODO: Positions</div>;
|
export const Positions = () => <div>TODO: Positions</div>;
|
||||||
export const Collateral = () => <div>TODO: Collateral</div>;
|
export const Collateral = () => <div>TODO: Collateral</div>;
|
||||||
|
|
||||||
export type View = keyof typeof Views;
|
export type TradingView = keyof typeof TradingViews;
|
||||||
|
|
||||||
export const Views = {
|
export const TradingViews = {
|
||||||
chart: Chart,
|
chart: Chart,
|
||||||
ticket: Ticket,
|
ticket: Ticket,
|
||||||
orderbook: Orderbook,
|
orderbook: Orderbook,
|
Loading…
Reference in New Issue
Block a user