eye icon for privacy

This commit is contained in:
vivganes 2023-04-08 18:54:45 +05:30
parent 77325be3e2
commit d7b638bff2
4 changed files with 52 additions and 5 deletions

View File

@ -354,5 +354,19 @@
stroke-linejoin="round"
/>
</symbol>
<symbol id="openeye" viewBox="0 0 24 24" fill="none">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.30147 15.5771C4.77832 14.2684 3.6904 12.7726 3.18002 12C3.6904 11.2274 4.77832 9.73158 6.30147 8.42294C7.87402 7.07185 9.81574 6 12 6C14.1843 6 16.1261 7.07185 17.6986 8.42294C19.2218 9.73158 20.3097 11.2274 20.8201 12C20.3097 12.7726 19.2218 14.2684 17.6986 15.5771C16.1261 16.9282 14.1843 18 12 18C9.81574 18 7.87402 16.9282 6.30147 15.5771ZM12 4C9.14754 4 6.75717 5.39462 4.99812 6.90595C3.23268 8.42276 2.00757 10.1376 1.46387 10.9698C1.05306 11.5985 1.05306 12.4015 1.46387 13.0302C2.00757 13.8624 3.23268 15.5772 4.99812 17.0941C6.75717 18.6054 9.14754 20 12 20C14.8525 20 17.2429 18.6054 19.002 17.0941C20.7674 15.5772 21.9925 13.8624 22.5362 13.0302C22.947 12.4015 22.947 11.5985 22.5362 10.9698C21.9925 10.1376 20.7674 8.42276 19.002 6.90595C17.2429 5.39462 14.8525 4 12 4ZM10 12C10 10.8954 10.8955 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14C10.8955 14 10 13.1046 10 12ZM12 8C9.7909 8 8.00004 9.79086 8.00004 12C8.00004 14.2091 9.7909 16 12 16C14.2092 16 16 14.2091 16 12C16 9.79086 14.2092 8 12 8Z"
stroke="currentColor"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"/>
</symbol>
<symbol id="closedeye" viewBox="0 0 24 24" fill="none">
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.7071 5.70711C20.0976 5.31658 20.0976 4.68342 19.7071 4.29289C19.3166 3.90237 18.6834 3.90237 18.2929 4.29289L14.032 8.55382C13.4365 8.20193 12.7418 8 12 8C9.79086 8 8 9.79086 8 12C8 12.7418 8.20193 13.4365 8.55382 14.032L4.29289 18.2929C3.90237 18.6834 3.90237 19.3166 4.29289 19.7071C4.68342 20.0976 5.31658 20.0976 5.70711 19.7071L9.96803 15.4462C10.5635 15.7981 11.2582 16 12 16C14.2091 16 16 14.2091 16 12C16 11.2582 15.7981 10.5635 15.4462 9.96803L19.7071 5.70711ZM12.518 10.0677C12.3528 10.0236 12.1792 10 12 10C10.8954 10 10 10.8954 10 12C10 12.1792 10.0236 12.3528 10.0677 12.518L12.518 10.0677ZM11.482 13.9323L13.9323 11.482C13.9764 11.6472 14 11.8208 14 12C14 13.1046 13.1046 14 12 14C11.8208 14 11.6472 13.9764 11.482 13.9323ZM15.7651 4.8207C14.6287 4.32049 13.3675 4 12 4C9.14754 4 6.75717 5.39462 4.99812 6.90595C3.23268 8.42276 2.00757 10.1376 1.46387 10.9698C1.05306 11.5985 1.05306 12.4015 1.46387 13.0302C1.92276 13.7326 2.86706 15.0637 4.21194 16.3739L5.62626 14.9596C4.4555 13.8229 3.61144 12.6531 3.18002 12C3.6904 11.2274 4.77832 9.73158 6.30147 8.42294C7.87402 7.07185 9.81574 6 12 6C12.7719 6 13.5135 6.13385 14.2193 6.36658L15.7651 4.8207ZM12 18C11.2282 18 10.4866 17.8661 9.78083 17.6334L8.23496 19.1793C9.37136 19.6795 10.6326 20 12 20C14.8525 20 17.2429 18.6054 19.002 17.0941C20.7674 15.5772 21.9925 13.8624 22.5362 13.0302C22.947 12.4015 22.947 11.5985 22.5362 10.9698C22.0773 10.2674 21.133 8.93627 19.7881 7.62611L18.3738 9.04043C19.5446 10.1771 20.3887 11.3469 20.8201 12C20.3097 12.7726 19.2218 14.2684 17.6986 15.5771C16.1261 16.9282 14.1843 18 12 18Z"
stroke="currentColor"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"/>
</symbol>
</defs>
</svg>

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,7 +1,10 @@
import { MouseEventHandler } from "react";
type Props = {
name: string;
size?: number;
className?: string;
onClick?: MouseEventHandler<SVGSVGElement>;
};
const Icon = (props: Props) => {
@ -9,7 +12,7 @@ const Icon = (props: Props) => {
const href = "/icons.svg#" + props.name;
return (
<svg width={size} height={size} className={props.className}>
<svg width={size} height={size} className={props.className} onClick={props.onClick}>
<use href={href} />
</svg>
);

View File

@ -120,6 +120,13 @@
font-size: 16px;
}
.login-container input[type="password"] {
border: none;
background-color: var(--gray-secondary);
padding: 12px 16px;
font-size: 16px;
}
.login-container h1 {
color: var(--font-color);
font-style: normal;

View File

@ -16,6 +16,7 @@ import ZapButton from "Element/ZapButton";
import useImgProxy from "Hooks/useImgProxy";
import messages from "./messages";
import Icon from "Icons/Icon";
interface ArtworkEntry {
name: string;
@ -69,6 +70,8 @@ export default function LoginPage() {
const [key, setKey] = useState("");
const [error, setError] = useState("");
const [art, setArt] = useState<ArtworkEntry>();
const [isMasking, setMasking] = useState(false);
const [suggestMasking, setSuggestMasking] = useState(false);
const { formatMessage } = useIntl();
const { proxy } = useImgProxy();
const hasNip7 = "nostr" in window;
@ -85,6 +88,14 @@ export default function LoginPage() {
proxy(ret.link).then(a => setArt({ ...ret, link: a }));
}, []);
useEffect(() => {
if (key.startsWith("nsec") || key.match(MnemonicRegex)) {
setSuggestMasking(true);
} else {
setSuggestMasking(false);
}
}, [key]);
async function doLogin() {
const insecureMsg = formatMessage({
defaultMessage:
@ -263,6 +274,10 @@ export default function LoginPage() {
);
}
const flipMask = function () {
setMasking(!isMasking);
};
return (
<div className="login">
<div>
@ -279,17 +294,25 @@ export default function LoginPage() {
<div className="flex">
<input
dir="auto"
type={key?.startsWith("nsec") ? "password" : "text"}
type={isMasking ? "password" : "text"}
placeholder={formatMessage(messages.KeyPlaceholder)}
className="f-grow"
onChange={e => setKey(e.target.value)}
/>
<Icon
name={isMasking ? "openeye" : "closedeye"}
size={30}
className="highlight btn-sm pointer"
onClick={flipMask}
/>
</div>
<p className="login-note">
{key?.startsWith("nsec") && (
{suggestMasking && !isMasking && (
<span className="highlight">
We noticed that you are entering a secret key starting with nsec. We are masking your input to protect
your privacy.
<FormattedMessage
defaultMessage="Please mask your input by clicking the eye icon to protect your privacy"
description="Suggestion to mask input"
/>
</span>
)}
</p>