vega-frontend-monorepo/apps/trading/components/header/header.tsx
PeteWilliams 549e0e004d
Chore/design updates (#1305)
* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* chore: design updates

* fix: fix lint tests

* chore: fixes ag grid invisible header seperators

* fix: fixing conflicts

* fix: fixing conflicts

* chore: fix header spacing

* chore: fix dropdown hover colour

* fix: formatting change to pass test
2022-09-12 14:05:39 +01:00

57 lines
1.5 KiB
TypeScript

import { Tooltip } from '@vegaprotocol/ui-toolkit';
import type { ReactElement, ReactNode } from 'react';
import { Children } from 'react';
import { cloneElement } from 'react';
interface TradeMarketHeaderProps {
title: ReactNode;
children: ReactElement[];
}
export const Header = ({ title, children }: TradeMarketHeaderProps) => {
return (
<header className="w-screen xl:px-4 pt-4 border-b border-neutral-300 dark:border-neutral-600">
<div className="xl:flex xl:gap-4 items-start">
<div className="px-4 mb-2">{title}</div>
<div
data-testid="market-summary"
className="flex flex-nowrap items-start xl:flex-1 w-full overflow-x-auto text-xs "
>
{Children.map(children, (child, index) => {
return cloneElement(child, {
id: `header-stat-${index}`,
});
})}
</div>
</div>
</header>
);
};
export const HeaderStat = ({
children,
heading,
id,
description,
}: {
children: ReactNode;
heading: string;
id?: string;
description?: string | ReactNode;
}) => {
const itemClass =
'min-w-min w-[120px] whitespace-nowrap pb-3 px-4 border-l border-neutral-300 dark:border-neutral-600';
const itemHeading = 'text-neutral-400';
return (
<div className={itemClass}>
<Tooltip description={description}>
<div id={id} className={itemHeading}>
{heading}
</div>
</Tooltip>
<div aria-labelledby={id}>{children}</div>
</div>
);
};