chore(trading): vega icons for withrawals table and wallet dropdown (#4203)
This commit is contained in:
parent
d3df339696
commit
ebc058bcbe
@ -1,4 +1,4 @@
|
|||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import CopyToClipboard from 'react-copy-to-clipboard';
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { truncateByChars } from '@vegaprotocol/utils';
|
import { truncateByChars } from '@vegaprotocol/utils';
|
||||||
@ -12,9 +12,10 @@ import {
|
|||||||
DropdownMenuRadioGroup,
|
DropdownMenuRadioGroup,
|
||||||
DropdownMenuRadioItem,
|
DropdownMenuRadioItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
Icon,
|
|
||||||
Drawer,
|
Drawer,
|
||||||
DropdownMenuSeparator,
|
DropdownMenuSeparator,
|
||||||
|
VegaIcon,
|
||||||
|
VegaIconNames,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import type { PubKey } from '@vegaprotocol/wallet';
|
import type { PubKey } from '@vegaprotocol/wallet';
|
||||||
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
||||||
@ -249,14 +250,14 @@ const KeypairItem = ({ pk }: { pk: PubKey }) => {
|
|||||||
{truncateByChars(pk.publicKey)}
|
{truncateByChars(pk.publicKey)}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span className="inline-flex items-center gap-1">
|
||||||
<CopyToClipboard text={pk.publicKey} onCopy={() => setCopied(true)}>
|
<CopyToClipboard text={pk.publicKey} onCopy={() => setCopied(true)}>
|
||||||
<button
|
<button
|
||||||
data-testid="copy-vega-public-key"
|
data-testid="copy-vega-public-key"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<span className="sr-only">{t('Copy')}</span>
|
<span className="sr-only">{t('Copy')}</span>
|
||||||
<Icon name="duplicate" className="mr-2" />
|
<VegaIcon name={VegaIconNames.COPY} />
|
||||||
</button>
|
</button>
|
||||||
</CopyToClipboard>
|
</CopyToClipboard>
|
||||||
{copied && (
|
{copied && (
|
||||||
@ -278,34 +279,20 @@ const KeypairListItem = ({
|
|||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
onSelectItem: (pk: string) => void;
|
onSelectItem: (pk: string) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useCopyTimeout();
|
||||||
useEffect(() => {
|
|
||||||
// eslint-disable-next-line
|
|
||||||
let timeout: any;
|
|
||||||
|
|
||||||
if (copied) {
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
setCopied(false);
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
};
|
|
||||||
}, [copied]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex flex-col w-full ml-4 mr-2 mb-4"
|
className="flex flex-col w-full ml-4 mr-2 mb-4"
|
||||||
data-testid={`key-${pk.publicKey}-mobile`}
|
data-testid={`key-${pk.publicKey}-mobile`}
|
||||||
>
|
>
|
||||||
<span className="mr-2">
|
<span className="flex gap-2 items-center mr-2">
|
||||||
<button onClick={() => onSelectItem(pk.publicKey)}>
|
<button onClick={() => onSelectItem(pk.publicKey)}>
|
||||||
<span className="uppercase">{pk.name}</span>
|
<span className="uppercase">{pk.name}</span>
|
||||||
</button>
|
</button>
|
||||||
{isActive && <Icon name="tick" className="ml-2" />}
|
{isActive && <VegaIcon name={VegaIconNames.TICK} />}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-neutral-500 dark:text-neutral-400">
|
<span className="flex gap-2 items-center">
|
||||||
{truncateByChars(pk.publicKey)}{' '}
|
{truncateByChars(pk.publicKey)}{' '}
|
||||||
<CopyToClipboard text={pk.publicKey} onCopy={() => setCopied(true)}>
|
<CopyToClipboard text={pk.publicKey} onCopy={() => setCopied(true)}>
|
||||||
<button
|
<button
|
||||||
@ -313,7 +300,7 @@ const KeypairListItem = ({
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
<span className="sr-only">{t('Copy')}</span>
|
<span className="sr-only">{t('Copy')}</span>
|
||||||
<Icon name="duplicate" className="mr-2" />
|
<VegaIcon name={VegaIconNames.COPY} />
|
||||||
</button>
|
</button>
|
||||||
</CopyToClipboard>
|
</CopyToClipboard>
|
||||||
{copied && (
|
{copied && (
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { Tooltip } from '../tooltip';
|
import { Tooltip } from '../tooltip';
|
||||||
import CopyToClipboard from 'react-copy-to-clipboard';
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
||||||
|
import { useCopyTimeout } from '@vegaprotocol/react-helpers';
|
||||||
|
|
||||||
export const TOOLTIP_TIMEOUT = 800;
|
export const TOOLTIP_TIMEOUT = 800;
|
||||||
|
|
||||||
@ -11,22 +11,7 @@ export interface CopyWithTooltipProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function CopyWithTooltip({ children, text }: CopyWithTooltipProps) {
|
export function CopyWithTooltip({ children, text }: CopyWithTooltipProps) {
|
||||||
const [copied, setCopied] = useState(false);
|
const [copied, setCopied] = useCopyTimeout();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// eslint-disable-next-line
|
|
||||||
let timeout: any;
|
|
||||||
|
|
||||||
if (copied) {
|
|
||||||
timeout = setTimeout(() => {
|
|
||||||
setCopied(false);
|
|
||||||
}, TOOLTIP_TIMEOUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
};
|
|
||||||
}, [copied]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CopyToClipboard text={text} onCopy={() => setCopied(true)}>
|
<CopyToClipboard text={text} onCopy={() => setCopied(true)}>
|
||||||
|
@ -3,7 +3,7 @@ import * as DialogPrimitives from '@radix-ui/react-dialog';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { getIntentBorder } from '../../utils/intent';
|
import { getIntentBorder } from '../../utils/intent';
|
||||||
import { Icon } from '../icon';
|
import { VegaIcon, VegaIconNames } from '../icon';
|
||||||
|
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import type { Intent } from '../../utils/intent';
|
import type { Intent } from '../../utils/intent';
|
||||||
@ -77,7 +77,7 @@ export function Dialog({
|
|||||||
className="absolute p-2 top-0 right-0 md:top-2 md:right-2"
|
className="absolute p-2 top-0 right-0 md:top-2 md:right-2"
|
||||||
data-testid="dialog-close"
|
data-testid="dialog-close"
|
||||||
>
|
>
|
||||||
<Icon name="cross" />
|
<VegaIcon name={VegaIconNames.CROSS} />
|
||||||
</DialogPrimitives.Close>
|
</DialogPrimitives.Close>
|
||||||
)}
|
)}
|
||||||
<div className="flex gap-4 max-w-full">
|
<div className="flex gap-4 max-w-full">
|
||||||
|
@ -3,7 +3,6 @@ import classNames from 'classnames';
|
|||||||
import type { ComponentProps, ReactNode } from 'react';
|
import type { ComponentProps, ReactNode } from 'react';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
import { VegaIcon, VegaIconNames } from '../icon';
|
import { VegaIcon, VegaIconNames } from '../icon';
|
||||||
import { Icon } from '../icon';
|
|
||||||
import { useCopyTimeout } from '@vegaprotocol/react-helpers';
|
import { useCopyTimeout } from '@vegaprotocol/react-helpers';
|
||||||
import CopyToClipboard from 'react-copy-to-clipboard';
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
@ -140,7 +139,7 @@ export const DropdownMenuItemIndicator = forwardRef<
|
|||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
className="flex-end"
|
className="flex-end"
|
||||||
>
|
>
|
||||||
<Icon name="tick" />
|
<VegaIcon name={VegaIconNames.TICK} />
|
||||||
</DropdownMenuPrimitive.ItemIndicator>
|
</DropdownMenuPrimitive.ItemIndicator>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
export const IconTick = ({ size = 16 }: { size: number }) => {
|
||||||
|
return (
|
||||||
|
<svg width={size} height={size} viewBox="0 0 16 16">
|
||||||
|
<path d="M6 11.2505L13.6252 3.62523L14.3748 4.37477L6 12.7495L1.62523 8.37477L2.37476 7.62523L6 11.2505Z" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
};
|
@ -18,6 +18,7 @@ import { IconCross } from './svg-icons/icon-cross';
|
|||||||
import { IconKebab } from './svg-icons/icon-kebab';
|
import { IconKebab } from './svg-icons/icon-kebab';
|
||||||
import { IconArrowDown } from './svg-icons/icon-arrow-down';
|
import { IconArrowDown } from './svg-icons/icon-arrow-down';
|
||||||
import { IconChevronDown } from './svg-icons/icon-chevron-down';
|
import { IconChevronDown } from './svg-icons/icon-chevron-down';
|
||||||
|
import { IconTick } from './svg-icons/icon-tick';
|
||||||
|
|
||||||
export enum VegaIconNames {
|
export enum VegaIconNames {
|
||||||
BREAKDOWN = 'breakdown',
|
BREAKDOWN = 'breakdown',
|
||||||
@ -40,6 +41,7 @@ export enum VegaIconNames {
|
|||||||
TREND_UP = 'trend-up',
|
TREND_UP = 'trend-up',
|
||||||
CROSS = 'cross',
|
CROSS = 'cross',
|
||||||
KEBAB = 'kebab',
|
KEBAB = 'kebab',
|
||||||
|
TICK = 'tick',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VegaIconNameMap: Record<
|
export const VegaIconNameMap: Record<
|
||||||
@ -66,4 +68,5 @@ export const VegaIconNameMap: Record<
|
|||||||
'trend-up': IconTrendUp,
|
'trend-up': IconTrendUp,
|
||||||
cross: IconCross,
|
cross: IconCross,
|
||||||
kebab: IconKebab,
|
kebab: IconKebab,
|
||||||
|
tick: IconTick,
|
||||||
};
|
};
|
||||||
|
@ -3,7 +3,6 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
CopyWithTooltip,
|
CopyWithTooltip,
|
||||||
Dialog,
|
Dialog,
|
||||||
Icon,
|
|
||||||
KeyValueTable,
|
KeyValueTable,
|
||||||
KeyValueTableRow,
|
KeyValueTableRow,
|
||||||
Splash,
|
Splash,
|
||||||
@ -32,7 +31,7 @@ export const WithdrawalApprovalDialog = ({
|
|||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
title={t('Save withdrawal details')}
|
title={t('Save withdrawal details')}
|
||||||
icon={<Icon name="info-sign"></Icon>}
|
icon={<VegaIcon name={VegaIconNames.BREAKDOWN} size={16} />}
|
||||||
open={open}
|
open={open}
|
||||||
onChange={(isOpen) => onChange(isOpen)}
|
onChange={(isOpen) => onChange(isOpen)}
|
||||||
onCloseAutoFocus={(e) => {
|
onCloseAutoFocus={(e) => {
|
||||||
|
@ -15,7 +15,6 @@ import {
|
|||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
Icon,
|
|
||||||
VegaIcon,
|
VegaIcon,
|
||||||
VegaIconNames,
|
VegaIconNames,
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
@ -193,9 +192,8 @@ export const CompleteCell = ({ data, complete }: CompleteCellProps) => {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span>
|
<VegaIcon name={VegaIconNames.BREAKDOWN} size={16} />
|
||||||
<Icon name="info-sign" size={4} /> {t('View withdrawal details')}
|
{t('View withdrawal details')}
|
||||||
</span>
|
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
Loading…
Reference in New Issue
Block a user