Compare commits
5 Commits
develop
...
fix/toolti
Author | SHA1 | Date | |
---|---|---|---|
|
405d41a26c | ||
|
a0aa0065b6 | ||
|
bb6ecd2c72 | ||
|
de62f09fda | ||
|
6d70b28f30 |
@ -1,27 +1,20 @@
|
|||||||
import { useEffect } from 'react';
|
import { TinyScroll } from '@vegaprotocol/ui-toolkit';
|
||||||
import { titlefy } from '@vegaprotocol/utils';
|
|
||||||
import { ErrorBoundary } from '../../components/error-boundary';
|
import { ErrorBoundary } from '../../components/error-boundary';
|
||||||
import { FeesContainer } from '../../components/fees-container';
|
import { FeesContainer } from '../../components/fees-container';
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
import { usePageTitleStore } from '../../stores';
|
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||||
|
|
||||||
export const Fees = () => {
|
export const Fees = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const title = t('Fees');
|
const title = t('Fees');
|
||||||
const { updateTitle } = usePageTitleStore((store) => ({
|
usePageTitle(title);
|
||||||
updateTitle: store.updateTitle,
|
|
||||||
}));
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
updateTitle(titlefy([title]));
|
|
||||||
}, [updateTitle, title]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary feature="fees">
|
<ErrorBoundary feature="fees">
|
||||||
<div className="container p-4 mx-auto">
|
<TinyScroll className="p-4 max-h-full overflow-auto">
|
||||||
<h1 className="px-4 pb-4 text-2xl">{title}</h1>
|
<h1 className="md:px-4 pb-4 text-2xl">{title}</h1>
|
||||||
<FeesContainer />
|
<FeesContainer />
|
||||||
</div>
|
</TinyScroll>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import React, { useEffect } from 'react';
|
|
||||||
import { titlefy } from '@vegaprotocol/utils';
|
|
||||||
import {
|
import {
|
||||||
LocalStoragePersistTabs as Tabs,
|
LocalStoragePersistTabs as Tabs,
|
||||||
Tab,
|
Tab,
|
||||||
@ -7,7 +5,6 @@ import {
|
|||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import { OpenMarkets } from './open-markets';
|
import { OpenMarkets } from './open-markets';
|
||||||
import { Proposed } from './proposed';
|
import { Proposed } from './proposed';
|
||||||
import { usePageTitleStore } from '../../stores';
|
|
||||||
import { Closed } from './closed';
|
import { Closed } from './closed';
|
||||||
import {
|
import {
|
||||||
DApp,
|
DApp,
|
||||||
@ -17,19 +14,14 @@ import {
|
|||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
import { ErrorBoundary } from '../../components/error-boundary';
|
import { ErrorBoundary } from '../../components/error-boundary';
|
||||||
import { MarketsSettings } from './markets-settings';
|
import { MarketsSettings } from './markets-settings';
|
||||||
|
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||||
|
|
||||||
export const MarketsPage = () => {
|
export const MarketsPage = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const { updateTitle } = usePageTitleStore((store) => ({
|
|
||||||
updateTitle: store.updateTitle,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const governanceLink = useLinks(DApp.Governance);
|
const governanceLink = useLinks(DApp.Governance);
|
||||||
const externalLink = governanceLink(TOKEN_NEW_MARKET_PROPOSAL);
|
const externalLink = governanceLink(TOKEN_NEW_MARKET_PROPOSAL);
|
||||||
|
|
||||||
useEffect(() => {
|
usePageTitle(t('Markets'));
|
||||||
updateTitle(titlefy([t('Markets')]));
|
|
||||||
}, [updateTitle, t]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full pt-0.5 pb-3 px-1.5">
|
<div className="h-full pt-0.5 pb-3 px-1.5">
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { LayoutPriority } from 'allotment';
|
import { LayoutPriority } from 'allotment';
|
||||||
import { titlefy } from '@vegaprotocol/utils';
|
|
||||||
import { useIncompleteWithdrawals } from '@vegaprotocol/withdraws';
|
import { useIncompleteWithdrawals } from '@vegaprotocol/withdraws';
|
||||||
import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit';
|
import { Tab, LocalStoragePersistTabs as Tabs } from '@vegaprotocol/ui-toolkit';
|
||||||
import { usePageTitleStore } from '../../stores';
|
|
||||||
import {
|
import {
|
||||||
AccountsContainer,
|
AccountsContainer,
|
||||||
AccountsSettings,
|
AccountsSettings,
|
||||||
@ -41,6 +39,7 @@ import { WithdrawalsMenu } from '../../components/withdrawals-menu';
|
|||||||
import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id';
|
import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id';
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
import { ErrorBoundary } from '../../components/error-boundary';
|
import { ErrorBoundary } from '../../components/error-boundary';
|
||||||
|
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||||
|
|
||||||
const WithdrawalsIndicator = () => {
|
const WithdrawalsIndicator = () => {
|
||||||
const { ready } = useIncompleteWithdrawals();
|
const { ready } = useIncompleteWithdrawals();
|
||||||
@ -69,14 +68,7 @@ const SidebarViewInitializer = () => {
|
|||||||
|
|
||||||
export const Portfolio = () => {
|
export const Portfolio = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
|
usePageTitle(t('Portfolio'));
|
||||||
const { updateTitle } = usePageTitleStore((store) => ({
|
|
||||||
updateTitle: store.updateTitle,
|
|
||||||
}));
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
updateTitle(titlefy([t('Portfolio')]));
|
|
||||||
}, [updateTitle, t]);
|
|
||||||
|
|
||||||
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'portfolio' });
|
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'portfolio' });
|
||||||
const wrapperClasses = 'p-0.5 h-full max-h-full flex flex-col';
|
const wrapperClasses = 'p-0.5 h-full max-h-full flex flex-col';
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
import { useEffect } from 'react';
|
import { TinyScroll } from '@vegaprotocol/ui-toolkit';
|
||||||
import { titlefy } from '@vegaprotocol/utils';
|
|
||||||
import { useT } from '../../lib/use-t';
|
import { useT } from '../../lib/use-t';
|
||||||
import { RewardsContainer } from '../../components/rewards-container';
|
import { RewardsContainer } from '../../components/rewards-container';
|
||||||
import { usePageTitleStore } from '../../stores';
|
|
||||||
import { ErrorBoundary } from '../../components/error-boundary';
|
import { ErrorBoundary } from '../../components/error-boundary';
|
||||||
import { TinyScroll } from '@vegaprotocol/ui-toolkit';
|
import { usePageTitle } from '../../lib/hooks/use-page-title';
|
||||||
|
|
||||||
export const Rewards = () => {
|
export const Rewards = () => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
const title = t('Rewards');
|
const title = t('Rewards');
|
||||||
const { updateTitle } = usePageTitleStore((store) => ({
|
usePageTitle(title);
|
||||||
updateTitle: store.updateTitle,
|
|
||||||
}));
|
|
||||||
useEffect(() => {
|
|
||||||
updateTitle(titlefy([title]));
|
|
||||||
}, [updateTitle, title]);
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary feature="rewards">
|
<ErrorBoundary feature="rewards">
|
||||||
<TinyScroll className="p-4 max-h-full overflow-auto">
|
<TinyScroll className="p-4 max-h-full overflow-auto">
|
||||||
<h1 className="px-4 pb-4 text-2xl">{title}</h1>
|
<h1 className="md:px-4 pb-4 text-2xl">{title}</h1>
|
||||||
<RewardsContainer />
|
<RewardsContainer />
|
||||||
</TinyScroll>
|
</TinyScroll>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
ExternalLink,
|
ExternalLink,
|
||||||
Intent,
|
Intent,
|
||||||
NotificationBanner,
|
NotificationBanner,
|
||||||
SHORT,
|
|
||||||
} from '@vegaprotocol/ui-toolkit';
|
} from '@vegaprotocol/ui-toolkit';
|
||||||
import type { StoredNextProtocolUpgradeData } from '../lib';
|
import type { StoredNextProtocolUpgradeData } from '../lib';
|
||||||
import {
|
import {
|
||||||
@ -70,7 +69,7 @@ export const ProtocolUpgradeInProgressNotification = () => {
|
|||||||
if (!upgradeInProgress) return null;
|
if (!upgradeInProgress) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NotificationBanner intent={Intent.Danger} className={SHORT}>
|
<NotificationBanner intent={Intent.Danger}>
|
||||||
<div className="uppercase">
|
<div className="uppercase">
|
||||||
{t('The network is being upgraded to {{vegaReleaseTag}}', {
|
{t('The network is being upgraded to {{vegaReleaseTag}}', {
|
||||||
vegaReleaseTag,
|
vegaReleaseTag,
|
||||||
|
@ -4,8 +4,6 @@ import { Intent } from '../../utils/intent';
|
|||||||
import { Icon, VegaIcon, VegaIconNames } from '../icon';
|
import { Icon, VegaIcon, VegaIconNames } from '../icon';
|
||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
|
|
||||||
export const SHORT = '!px-1 !py-1 min-h-fit';
|
|
||||||
|
|
||||||
interface NotificationBannerProps {
|
interface NotificationBannerProps {
|
||||||
intent?: Intent;
|
intent?: Intent;
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
@ -23,7 +21,7 @@ export const NotificationBanner = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'flex items-center border-b px-2',
|
'flex items-center border-b pl-3 pr-2',
|
||||||
'text-xs leading-tight font-normal',
|
'text-xs leading-tight font-normal',
|
||||||
{
|
{
|
||||||
'bg-vega-light-100 dark:bg-vega-dark-100 ': intent === Intent.None,
|
'bg-vega-light-100 dark:bg-vega-dark-100 ': intent === Intent.None,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode, TouchEvent } from 'react';
|
||||||
import React from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Provider,
|
Provider,
|
||||||
Root,
|
Root,
|
||||||
@ -12,10 +12,10 @@ import classNames from 'classnames';
|
|||||||
|
|
||||||
const tooltipContentClasses =
|
const tooltipContentClasses =
|
||||||
'max-w-sm bg-vega-light-100 dark:bg-vega-dark-100 border border-vega-light-200 dark:border-vega-dark-200 px-2 py-1 z-20 rounded text-xs text-black dark:text-white break-word';
|
'max-w-sm bg-vega-light-100 dark:bg-vega-dark-100 border border-vega-light-200 dark:border-vega-dark-200 px-2 py-1 z-20 rounded text-xs text-black dark:text-white break-word';
|
||||||
|
|
||||||
export interface TooltipProps {
|
export interface TooltipProps {
|
||||||
children: React.ReactElement;
|
children: React.ReactElement;
|
||||||
description?: string | ReactNode;
|
description?: string | ReactNode;
|
||||||
open?: boolean;
|
|
||||||
align?: 'start' | 'center' | 'end';
|
align?: 'start' | 'center' | 'end';
|
||||||
side?: 'top' | 'right' | 'bottom' | 'left';
|
side?: 'top' | 'right' | 'bottom' | 'left';
|
||||||
sideOffset?: number;
|
sideOffset?: number;
|
||||||
@ -28,20 +28,50 @@ export const TOOLTIP_TRIGGER_CLASS_NAME = (underline?: boolean) =>
|
|||||||
underline,
|
underline,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const useLongPress = (callback: (e: TouchEvent<HTMLElement>) => void) => {
|
||||||
|
const timer = useRef<number>();
|
||||||
|
|
||||||
|
const onTouchStart = (e: TouchEvent<HTMLElement>) => {
|
||||||
|
e.preventDefault();
|
||||||
|
timer.current = setTimeout(callback, 1000);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (timer.current) {
|
||||||
|
clearInterval(timer.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
onTouchStart,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
// Conditionally rendered tooltip if description content is provided.
|
// Conditionally rendered tooltip if description content is provided.
|
||||||
export const Tooltip = ({
|
export const Tooltip = ({
|
||||||
children,
|
children,
|
||||||
description,
|
description,
|
||||||
open,
|
|
||||||
sideOffset,
|
sideOffset,
|
||||||
align = 'start',
|
align = 'start',
|
||||||
side = 'bottom',
|
side = 'bottom',
|
||||||
underline,
|
underline,
|
||||||
}: TooltipProps) =>
|
}: TooltipProps) => {
|
||||||
description ? (
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const { onTouchStart } = useLongPress(() => {
|
||||||
|
setOpen(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
return description ? (
|
||||||
<Provider delayDuration={200} skipDelayDuration={100}>
|
<Provider delayDuration={200} skipDelayDuration={100}>
|
||||||
<Root open={open}>
|
<Root open={open} onOpenChange={setOpen}>
|
||||||
<Trigger asChild className={TOOLTIP_TRIGGER_CLASS_NAME(underline)}>
|
<Trigger
|
||||||
|
asChild
|
||||||
|
className={TOOLTIP_TRIGGER_CLASS_NAME(underline)}
|
||||||
|
onTouchStart={onTouchStart}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Trigger>
|
</Trigger>
|
||||||
{description && (
|
{description && (
|
||||||
@ -67,6 +97,7 @@ export const Tooltip = ({
|
|||||||
) : (
|
) : (
|
||||||
children
|
children
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const TextChildrenTooltip = ({
|
export const TextChildrenTooltip = ({
|
||||||
children,
|
children,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { NotificationBanner, SHORT } from '../notification-banner';
|
import { NotificationBanner } from '../notification-banner';
|
||||||
import { Intent } from '../../utils/intent';
|
import { Intent } from '../../utils/intent';
|
||||||
import { TradingButton } from '../trading-button';
|
import { TradingButton } from '../trading-button';
|
||||||
import { useT } from '../../use-t';
|
import { useT } from '../../use-t';
|
||||||
@ -23,7 +23,7 @@ export const ViewingAsBanner = ({
|
|||||||
}: ViewingAsBannerProps) => {
|
}: ViewingAsBannerProps) => {
|
||||||
const t = useT();
|
const t = useT();
|
||||||
return (
|
return (
|
||||||
<NotificationBanner intent={Intent.None} className={SHORT}>
|
<NotificationBanner>
|
||||||
<div className="flex items-baseline justify-between">
|
<div className="flex items-baseline justify-between">
|
||||||
<span data-testid="view-banner">
|
<span data-testid="view-banner">
|
||||||
{t('Viewing as Vega user: {{pubKey}}', {
|
{t('Viewing as Vega user: {{pubKey}}', {
|
||||||
|
Loading…
Reference in New Issue
Block a user