Skip to content

Commit 498142a

Browse files
authored
fix: design feedback part deux (#2332)
1 parent 30b567e commit 498142a

File tree

6 files changed

+99
-27
lines changed

6 files changed

+99
-27
lines changed

apps/namadillo/src/App/Transfer/ShieldedPropertiesTooltip.tsx

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
import { Tooltip } from "@namada/components";
2+
import clsx from "clsx";
23
import { useMemo } from "react";
34
import { BsEye, BsEyeSlash } from "react-icons/bs";
5+
import semiTransparentEye from "./assets/semi-transparent-eye.svg";
6+
import shieldedEye from "./assets/shielded-eye.svg";
7+
import transparentEye from "./assets/transparent-eye.svg";
48
import { isShieldedAddress } from "./common";
59

10+
type TransactionType = "transparent" | "semi-transparent" | "shielded";
11+
612
export const ShieldedPropertiesTooltip = ({
713
sourceAddress,
814
destinationAddress,
915
}: {
1016
sourceAddress: string | undefined;
1117
destinationAddress: string | undefined;
1218
}): JSX.Element => {
19+
const isSourceShielded = isShieldedAddress(sourceAddress ?? "");
20+
const isDestShielded = isShieldedAddress(destinationAddress ?? "");
21+
22+
// Determine transaction type
23+
const transactionType: TransactionType = useMemo(() => {
24+
if (isSourceShielded && isDestShielded) {
25+
return "shielded";
26+
} else if (!isSourceShielded && !isDestShielded) {
27+
return "transparent";
28+
} else {
29+
return "semi-transparent";
30+
}
31+
}, [isSourceShielded, isDestShielded]);
32+
1333
const visible = useMemo((): JSX.Element => {
1434
return (
1535
<span className="flex items-center gap-2">
@@ -28,32 +48,67 @@ export const ShieldedPropertiesTooltip = ({
2848
);
2949
}, []);
3050

31-
const shieldedTransfer =
32-
isShieldedAddress(sourceAddress ?? "") &&
33-
isShieldedAddress(destinationAddress ?? "");
34-
const shieldingTransfer =
35-
isShieldedAddress(destinationAddress ?? "") &&
36-
!isShieldedAddress(sourceAddress ?? "");
51+
// Determine visibility for each property based on transaction type
52+
const senderVisible = transactionType !== "shielded" && !isSourceShielded;
53+
const recipientVisible = transactionType === "transparent" || !isDestShielded;
54+
const assetVisible = transactionType !== "shielded";
55+
const amountVisible = transactionType !== "shielded";
56+
57+
// Transaction type header
58+
const transactionTypeHeader = useMemo(() => {
59+
return (
60+
<div className="flex items-center justify-center gap-2 bg-neutral-800 rounded-sm py-2 px-4">
61+
<span
62+
className={clsx(
63+
"text-sm font-medium",
64+
transactionType === "shielded" && "text-yellow-400"
65+
)}
66+
>
67+
{transactionType === "shielded" ?
68+
"Shielded"
69+
: transactionType === "semi-transparent" ?
70+
"Semi-transparent"
71+
: "Transparent"}
72+
</span>
73+
<img
74+
src={
75+
transactionType === "shielded" ? shieldedEye
76+
: transactionType === "semi-transparent" ?
77+
semiTransparentEye
78+
: transparentEye
79+
}
80+
alt={
81+
transactionType === "shielded" ? "Shielded"
82+
: transactionType === "semi-transparent" ?
83+
"Semi-transparent"
84+
: "Transparent"
85+
}
86+
className="w-4 h-4"
87+
/>
88+
</div>
89+
);
90+
}, [transactionType]);
3791

3892
return (
3993
<Tooltip position="top" className="z-50 rounded-lg -mt-2">
40-
<div className="min-w-[15rem] py-2 space-y-3">
41-
<p className="text-white text-sm font-medium">Transaction Privacy:</p>
94+
<div className="min-w-[18rem] py-3 space-y-3">
95+
{transactionTypeHeader}
96+
4297
<div className="flex w-full items-center justify-between">
4398
<span className="text-neutral-400 text-sm">Sender address</span>
44-
{shieldedTransfer ? hidden : visible}
45-
</div>
46-
<div className="flex w-full items-center justify-between">
47-
<span className="text-neutral-400 text-sm">Recipient address</span>
48-
{shieldingTransfer || shieldedTransfer ? hidden : visible}
99+
{senderVisible ? visible : hidden}
49100
</div>
50101
<div className="flex w-full items-center justify-between">
51102
<span className="text-neutral-400 text-sm">Asset</span>
52-
{shieldedTransfer ? hidden : visible}
103+
{assetVisible ? visible : hidden}
53104
</div>
54105
<div className="flex w-full items-center justify-between">
55106
<span className="text-neutral-400 text-sm">Amount</span>
56-
{shieldedTransfer ? hidden : visible}
107+
{amountVisible ? visible : hidden}
108+
</div>
109+
<div className="flex w-full items-center justify-between">
110+
<span className="text-neutral-400 text-sm">Destination address</span>
111+
{recipientVisible ? visible : hidden}
57112
</div>
58113
</div>
59114
</Tooltip>

apps/namadillo/src/App/Transfer/TransferDestination.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ import { useLocation } from "react-router-dom";
2727
import { Address } from "types";
2828
import namadaShieldedIcon from "./assets/namada-shielded.svg";
2929
import namadaTransparentIcon from "./assets/namada-transparent.svg";
30+
import semiTransparentEye from "./assets/semi-transparent-eye.svg";
3031
import shieldedEye from "./assets/shielded-eye.svg";
32+
import transparentEye from "./assets/transparent-eye.svg";
3133
import { CustomAddressForm } from "./CustomAddressForm";
3234
import { DestinationAddressModal } from "./DestinationAddressModal";
3335
import { SelectedWallet } from "./SelectedWallet";
@@ -124,13 +126,6 @@ export const TransferDestination = ({
124126
undefined
125127
: destinationAddress;
126128

127-
const isShieldedTransfer =
128-
isShieldedNamAddress(sourceAddress ?? "") &&
129-
isShieldedNamAddress(destinationAddress ?? "");
130-
const isShieldingTransfer =
131-
!isShieldedNamAddress(sourceAddress ?? "") &&
132-
isShieldedNamAddress(destinationAddress ?? "");
133-
134129
const sourceWallet =
135130
isNamadaAddress(destinationAddress || "") ? wallets.namada : wallets.keplr;
136131
const addressType =
@@ -147,6 +142,18 @@ export const TransferDestination = ({
147142
return alias ?? "";
148143
return "Custom";
149144
};
145+
// Determine transaction type for eye icon
146+
const isSourceShielded = isShieldedNamAddress(sourceAddress ?? "");
147+
const isDestShielded = isShieldedNamAddress(destinationAddress ?? "");
148+
const transactionType =
149+
isSourceShielded && isDestShielded ? "shielded"
150+
: !isSourceShielded && !isDestShielded ? "transparent"
151+
: "semi-transparent";
152+
153+
const eyeIcon =
154+
transactionType === "shielded" ? shieldedEye
155+
: transactionType === "semi-transparent" ? semiTransparentEye
156+
: transparentEye;
150157

151158
return (
152159
<>
@@ -162,11 +169,11 @@ export const TransferDestination = ({
162169
<div>
163170
<div className="flex justify-between items-center mb-5">
164171
<h4 className="text-neutral-500">Destination</h4>
165-
{(isShieldedTransfer || isShieldingTransfer) && (
172+
{sourceAddress && destinationAddress && (
166173
<div className="relative w-fit group/tooltip ml-auto">
167174
<img
168-
src={shieldedEye}
169-
alt="Shielded Logo"
175+
src={eyeIcon}
176+
alt="Privacy Info"
170177
className="w-5 mb-2 select-none cursor-pointer"
171178
/>
172179
<ShieldedPropertiesTooltip

apps/namadillo/src/App/Transfer/TransferSource.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ export const TransferSource = ({
135135
"text-center [&_input]:text-center [&_input]:text-3xl [&_input]:bg-transparent",
136136
"[&_input]:!border-0 [&_input]:px-0"
137137
)}
138-
disabled={!asset}
139138
value={amount}
140139
onChange={(e) => onChangeAmount?.(e.target.value)}
141140
placeholder="Amount"
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 2 additions & 1 deletion
Loading
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)