Skip to content

Commit fdf064e

Browse files
authored
Unify all tooltip styling (#1683)
1 parent 7201421 commit fdf064e

File tree

17 files changed

+154
-343
lines changed

17 files changed

+154
-343
lines changed

apps/hyperdrive-trading/src/ui/base/components/LabelValue.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { InformationCircleIcon } from "@heroicons/react/24/outline";
22
import classNames from "classnames";
33
import { ReactNode } from "react";
4+
import { Tooltip } from "src/ui/base/components/Tooltip/Tooltip";
45

56
export function LabelValue({
67
size = "medium",
@@ -29,25 +30,20 @@ export function LabelValue({
2930
"text-sm": size === "small",
3031
})}
3132
>
32-
<div
33-
className={classNames(
34-
"flex items-center text-neutral-content before:bg-base-100",
35-
{
36-
"group daisy-tooltip cursor-help": tooltipContent,
37-
"daisy-tooltip-top": tooltipPosition === "top",
38-
"daisy-tooltip-bottom": tooltipPosition === "bottom",
39-
"daisy-tooltip-left": tooltipPosition === "left",
40-
"daisy-tooltip-right": tooltipPosition === "right",
33+
{tooltipContent ? (
34+
<Tooltip
35+
position={tooltipPosition}
36+
className={classNames("group text-left text-neutral-content", {
4137
"before:w-64": tooltipSize === "small",
42-
},
43-
)}
44-
data-tip={tooltipContent}
45-
>
46-
{label}
47-
{tooltipContent ? (
38+
})}
39+
tooltip={tooltipContent}
40+
>
41+
{label}
4842
<InformationCircleIcon className="ml-1.5 w-5 opacity-50 transition duration-150 ease-in-out group-hover:opacity-100 lg:inline-block" />
49-
) : null}
50-
</div>
43+
</Tooltip>
44+
) : (
45+
<div className="text-neutral-content">{label}</div>
46+
)}
5147
<div>{value}</div>
5248
</div>
5349
);

apps/hyperdrive-trading/src/ui/base/components/MultiStat.tsx

Lines changed: 0 additions & 98 deletions
This file was deleted.

apps/hyperdrive-trading/src/ui/base/components/PrimaryStat.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { InformationCircleIcon } from "@heroicons/react/24/outline";
22
import classNames from "classnames";
33
import { ReactNode } from "react";
44
import Skeleton from "react-loading-skeleton";
5+
import { Tooltip } from "src/ui/base/components/Tooltip/Tooltip";
56

67
export function PrimaryStat({
78
label,
@@ -36,20 +37,13 @@ export function PrimaryStat({
3637
<div className="flex gap-1">
3738
<p className="max-w-40 text-sm text-neutral-content">{label}</p>
3839
{tooltipContent && (
39-
<div
40-
className={classNames(
41-
"daisy-tooltip daisy-tooltip-top before:border",
42-
{
43-
"daisy-tooltip-top": tooltipPosition === "top",
44-
"daisy-tooltip-bottom": tooltipPosition === "bottom",
45-
"daisy-tooltip-left": tooltipPosition === "left",
46-
"daisy-tooltip-right": tooltipPosition === "right",
47-
},
48-
)}
49-
data-tip={tooltipContent}
40+
<Tooltip
41+
position={tooltipPosition}
42+
tooltip={tooltipContent}
43+
className="before:text-left"
5044
>
5145
<InformationCircleIcon className="size-4 text-neutral-content" />
52-
</div>
46+
</Tooltip>
5347
)}
5448
</div>
5549
<div className={valueContainerClassName}>

apps/hyperdrive-trading/src/ui/base/components/Stat.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

apps/hyperdrive-trading/src/ui/base/components/Tooltip/TextWithTooltip.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import classNames from "classnames";
2+
import { PropsWithChildren, ReactElement } from "react";
3+
4+
interface CellWithTooltipProps extends PropsWithChildren {
5+
className?: string;
6+
tooltip?: string;
7+
position?: "top" | "bottom" | "left" | "right";
8+
}
9+
10+
export function Tooltip({
11+
children,
12+
className,
13+
tooltip,
14+
position = "top",
15+
}: CellWithTooltipProps): ReactElement {
16+
if (!tooltip) {
17+
return <div className={className}>{children}</div>;
18+
}
19+
return (
20+
<div
21+
data-tip={tooltip}
22+
// Future note: use before: to style the text inside the tooltip
23+
className={classNames(
24+
"daisy-tooltip flex cursor-help items-center transition duration-150 ease-in-out before:whitespace-normal before:border before:border-gray-900 before:bg-gray-700 before:px-3 before:py-2 before:shadow-2xl",
25+
{
26+
"daisy-tooltip-top": position === "top",
27+
"daisy-tooltip-bottom": position === "bottom",
28+
"daisy-tooltip-left": position === "left",
29+
"daisy-tooltip-right": position === "right",
30+
},
31+
className,
32+
)}
33+
>
34+
{children}
35+
</div>
36+
);
37+
}

apps/hyperdrive-trading/src/ui/base/components/WarningButton.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

apps/hyperdrive-trading/src/ui/hyperdrive/shorts/OpenShortForm/OpenShortForm.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { getHasEnoughAllowance } from "src/token/getHasEnoughAllowance";
1919
import { getHasEnoughBalance } from "src/token/getHasEnoughBalance";
2020
import { LoadingButton } from "src/ui/base/components/LoadingButton";
2121
import { PrimaryStat } from "src/ui/base/components/PrimaryStat";
22+
import { Tooltip } from "src/ui/base/components/Tooltip/Tooltip";
2223
import { formatBalance } from "src/ui/base/formatting/formatBalance";
2324
import { formatDate } from "src/ui/base/formatting/formatDate";
2425
import { useNumericInput } from "src/ui/base/hooks/useNumericInput";
@@ -495,15 +496,14 @@ export function OpenShortForm({
495496
}
496497
unitClassName="mb-1 font-bold"
497498
subValue={
498-
<div
499-
data-tip={
500-
"Short positions provide the fixed rate to Long positions. Opening a Short is a one-time cost."
501-
}
502-
className="daisy-tooltip daisy-tooltip-top flex cursor-help items-center gap-1 before:border"
499+
<Tooltip
500+
position="top"
501+
tooltip="Short positions provide the fixed rate to Long positions. Opening a Short is a one-time cost."
502+
className="gap-1 before:text-left"
503503
>
504504
What am I paying for?{" "}
505505
<InformationCircleIcon className="size-4 text-neutral-content" />
506-
</div>
506+
</Tooltip>
507507
}
508508
/>
509509
</div>

apps/hyperdrive-trading/src/ui/markets/AssetStack.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getToken,
66
} from "@delvtech/hyperdrive-appconfig";
77
import { ReactElement } from "react";
8+
import { Tooltip } from "src/ui/base/components/Tooltip/Tooltip";
89
import { Address } from "viem";
910

1011
export function AssetStack({
@@ -37,20 +38,20 @@ export function AssetStack({
3738
}
3839
>
3940
{hyperdrive.depositOptions.isBaseTokenDepositEnabled ? (
40-
<div
41-
className="daisy-avatar daisy-tooltip daisy-tooltip-top w-12 overflow-visible bg-[#ffffff] before:bg-base-100"
42-
data-tip={baseToken.symbol}
41+
<Tooltip
42+
className="daisy-avatar w-12 overflow-visible bg-[#ffffff]"
43+
tooltip={baseToken.symbol}
4344
>
4445
<img src={baseToken.iconUrl} className="rounded-full" />
45-
</div>
46+
</Tooltip>
4647
) : null}
4748
{sharesToken && hyperdrive.depositOptions.isShareTokenDepositsEnabled ? (
48-
<div
49-
className="daisy-avatar daisy-tooltip daisy-tooltip-top w-12 overflow-visible before:bg-base-100"
50-
data-tip={sharesToken.symbol}
49+
<Tooltip
50+
className="daisy-avatar w-12 overflow-visible bg-[#ffffff]"
51+
tooltip={sharesToken.symbol}
5152
>
5253
<img src={sharesToken.iconUrl} className="rounded-full bg-base-100" />
53-
</div>
54+
</Tooltip>
5455
) : null}
5556
</div>
5657
);

0 commit comments

Comments
 (0)