Skip to content

Commit

Permalink
Improve password page (Requirement component)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaffinPX committed Oct 18, 2024
1 parent c58a118 commit e876b57
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/pages/Creation/Import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Import ({ onSubmit }: {
</h1>
</div>
<p className="font-semibold text-center">
Enter mnemonic, theq key of a wallet.
Enter mnemonic, the key of a wallet.
</p>
</div>
<div className="grid grid-cols-3 gap-1">
Expand Down
58 changes: 35 additions & 23 deletions src/pages/Creation/Password.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KeyIcon } from "lucide-react"
import { KeyIcon, XIcon, CheckIcon } from "lucide-react"
import { useState, useMemo } from "react"

enum PasswordErrors {
Expand Down Expand Up @@ -53,32 +53,44 @@ export default function Password ({ onSet }: {
<button className="btn btn-xs" onClick={() => setIsHidden(!isHidden)}>
{isHidden ? "Show" : "Hide"}
</button>
<div className="flex flex-col gap-0.5">
<label>
{errors.has(PasswordErrors.TooShort) ? "❌ " : "βœ… "}
At least 8 characters long.
</label>
<label>
{errors.has(PasswordErrors.UpperCase) ? "❌ " : "βœ… "}
At least one uppercase letter.
</label>
<label>
{errors.has(PasswordErrors.LowerCase) ? "❌ " : "βœ… "}
At least one lowercase letter.
</label>
<label>
{errors.has(PasswordErrors.Number) ? "❌ " : "βœ… "}
At least one number.
</label>
<label>
{errors.has(PasswordErrors.SpecialCharacter) ? "❌ " : "βœ… "}
At least one special character.
</label>
<div className="flex flex-col">
<Requirement
condition={errors.has(PasswordErrors.TooShort)}
label="At least 8 characters long."
/>
<Requirement
condition={errors.has(PasswordErrors.UpperCase)}
label="At least one uppercase letter."
/>
<Requirement
condition={errors.has(PasswordErrors.LowerCase)}
label="At least one lowercase letter."
/>
<Requirement
condition={errors.has(PasswordErrors.Number)}
label="At least one number."
/>
<Requirement
condition={errors.has(PasswordErrors.SpecialCharacter)}
label="At least one special character."
/>
</div>
</div>
<button className="btn btn-primary" disabled={!!errors.size} onClick={() => onSet(password)}>
Continue
</button>
</main>
)
}
}

const Requirement = ({ condition, label }: {
condition: boolean,
label: string
}) => {
return (
<label className={`flex flex-row items-center ${condition ? "text-red-500" : "text-green-500"}`}>
{condition ? <XIcon /> : <CheckIcon />}
{label}
</label>
);
};

0 comments on commit e876b57

Please sign in to comment.