vega-frontend-monorepo/libs/ui-toolkit/src/components/dialog/dialog.tsx
m.ray 9ab6337e42
Feat/305 add console v2 first view screen (#424)
* [#305] add initial landing dialog on markets page and fix some typos

* [#305] market-list utils and generate schema

* [#305] initial styling of the landing dialog and add arrows

* [#305] routing to markets and add hover and market list tests

* [#305] fix z-index on dialog overlay

* [#305] default market shoulde be oldest market that is currently trading in continuous mode

* [#305] refactor market-list library

* [#305] add arrow unit tests

* Update libs/market-list/src/lib/components/landing/landing-dialog.tsx

Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>

* Update libs/market-list/src/lib/components/landing/select-market-list.tsx

Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>

* Update libs/market-list/src/lib/components/landing/select-market-list.tsx

Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>

* test: fix failing tests from homepage change

* [#305] sort by id after sorting by date

* test: increase timeout for failing tests in CI

* [#305] destructuring all over the place and some code tweaks, arrows and percentage changes

* [#305] update sparkline to show colour

* [#305] fix order of market list

* [#305] stretchedLink class plus a-tag href for navigation - accessibility updates

* [#305] use href only and remove log

* [#305] use bignumber.js for price calculations

* [#305] change to bg-white/50 on dark mode overlay as asked from UX

* [#305] change to bg-white/50 on dark mode overlay as asked from UX

* [#305] toLocaleString fix

* [#305] toLocaleString fix

* [#305] add price-change-cell and use formatNumber

* [#305] add extra test for select market list

* Update apps/trading/specs/index.spec.tsx

Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>

* [#305] use memo, sort by date and id lodash

Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>
Co-authored-by: Joe <joe@vega.xyz>
2022-05-23 13:21:54 +01:00

56 lines
1.7 KiB
TypeScript

import * as DialogPrimitives from '@radix-ui/react-dialog';
import classNames from 'classnames';
import type { ReactNode } from 'react';
import type { Intent } from '../../utils/intent';
import { getIntentShadow } from '../../utils/intent';
import { Icon } from '../icon';
interface DialogProps {
children: ReactNode;
open: boolean;
onChange: (isOpen: boolean) => void;
title?: string;
intent?: Intent;
titleClassNames?: string;
}
export function Dialog({
children,
open,
onChange,
title,
intent,
titleClassNames,
}: DialogProps) {
const contentClasses = classNames(
// Positions the modal in the center of screen
'z-20 fixed w-full md:w-[520px] px-28 py-24 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]',
// Need to apply background and text colors again as content is rendered in a portal
'dark:bg-black dark:text-white-95 bg-white text-black-95',
getIntentShadow(intent)
);
return (
<DialogPrimitives.Root open={open} onOpenChange={(x) => onChange(x)}>
<DialogPrimitives.Portal>
<DialogPrimitives.Overlay className="fixed inset-0 bg-black/50 z-10" />
<DialogPrimitives.Content className={contentClasses}>
<DialogPrimitives.Close
className="p-12 absolute top-0 right-0"
data-testid="dialog-close"
>
<Icon name="cross" />
</DialogPrimitives.Close>
{title && (
<h1
className={`text-h5 text-black-95 dark:text-white-95 mt-0 mb-20 ${titleClassNames}`}
>
{title}
</h1>
)}
{children}
</DialogPrimitives.Content>
</DialogPrimitives.Portal>
</DialogPrimitives.Root>
);
}