Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add "show password" button next to password fields

thecodrrb6a7dab4a01f
diff --git a/apps/web/src/components/dialogs/password-dialog.js b/apps/web/src/components/dialogs/password-dialog.js
index a00b1c2dd..6bcda4775 100644
--- a/apps/web/src/components/dialogs/password-dialog.js
+++ b/apps/web/src/components/dialogs/password-dialog.js
@@ -127,7 +127,7 @@ function getDialogData(type) {
title: "Change Vault Password",
subtitle:
"All locked notes will be re-encrypted with the new password.",
- icon: Icon.Password,
+ icon: Icon.Unlock,
positiveButtonText: "Change password",
};
default:
diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.js
index 7dd8798d4..ee30c1a6f 100644
--- a/apps/web/src/components/field/index.js
+++ b/apps/web/src/components/field/index.js
@@ -1,6 +1,7 @@
-import React from "react";
-import { Flex } from "rebass";
+import React, { useState } from "react";
+import { Flex, Box } from "rebass";
import { Input, Label } from "@rebass/forms";
+import * as Icon from "../icons";
function Field(props) {
const {
@@ -13,23 +14,58 @@ function Field(props) {
autoFocus,
autoComplete,
} = props;
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
+
return (
<Flex sx={sx} flexDirection="column">
- <Label htmlFor={id} sx={{ fontSize: "title" }}>
+ <Label
+ htmlFor={id}
+ sx={{
+ fontSize: "subtitle",
+ fontWeight: "bold",
+ color: "text",
+ }}
+ >
{label}
</Label>
{/* <Label htmlFor={id} sx={{ fontSize: "body", color: "gray" }} mb={1}>
Hello I am secondary
</Label> */}
- <Input
- autoFocus={autoFocus}
- required={required}
- name={name}
- id={id}
- autoComplete={autoComplete}
- type={type || "text"}
- mt={1}
- />
+ <Flex mt={1} sx={{ position: "relative" }}>
+ <Input
+ autoFocus={autoFocus}
+ required={required}
+ name={name}
+ id={id}
+ autoComplete={autoComplete}
+ type={type || "text"}
+ />
+ {type === "password" && (
+ <Flex
+ onClick={() => {
+ const input = document.getElementById(id);
+ input.type = isPasswordVisible ? "password" : "text";
+ setIsPasswordVisible((s) => !s);
+ }}
+ variant="rowCenter"
+ sx={{
+ position: "absolute",
+ right: 0,
+ top: 0,
+ bottom: 0,
+ px: 1,
+ borderRadius: "default",
+ ":hover": { bg: "border" },
+ }}
+ >
+ {isPasswordVisible ? (
+ <Icon.PasswordVisible />
+ ) : (
+ <Icon.PasswordInvisible />
+ )}
+ </Flex>
+ )}
+ </Flex>
</Flex>
);
}
diff --git a/apps/web/src/components/icons/index.js b/apps/web/src/components/icons/index.js
index 6f8eb57e4..5c399f2bd 100644
--- a/apps/web/src/components/icons/index.js
+++ b/apps/web/src/components/icons/index.js
@@ -125,4 +125,5 @@ export const ChevronUp = createIcon(Icons.mdiChevronUp);
export const SortAsc = createIcon(Icons.mdiSortAscending);
export const SortDesc = createIcon(Icons.mdiSortDescending);
-export const Password = createIcon(Icons.mdiFormTextboxPassword);
+export const PasswordInvisible = createIcon(Icons.mdiEye);
+export const PasswordVisible = createIcon(Icons.mdiEyeOff);
diff --git a/apps/web/src/theme/variants/input.js b/apps/web/src/theme/variants/input.js
index 6189406c7..367b28887 100644
--- a/apps/web/src/theme/variants/input.js
+++ b/apps/web/src/theme/variants/input.js
@@ -11,9 +11,13 @@ export default InputFactory;
class Default {
constructor() {
return {
- borderRadius: "default",
- border: "2px solid",
- borderColor: "border",
+ border: "none",
+ borderRadius: 0,
+ p: 0,
+ py: 1,
+
+ borderBottom: "1px solid",
+ borderBottomColor: "border",
fontFamily: "body",
fontWeight: "body",
fontSize: "input",
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 941d6211e..5761ce2b6 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -16,7 +16,6 @@ import dayjs from "dayjs";
import { showRecoveryKeyDialog } from "../components/dialogs/recoverykeydialog";
import { showBuyDialog } from "../components/dialogs/buy-dialog";
import Vault from "../common/vault";
-import { showToast } from "../utils/toast";
function importBackup() {
return new Promise((resolve, reject) => {