Skip to content

Commit

Permalink
fix: PasswordStrength polish followup (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker authored Dec 22, 2024
1 parent 1bccc82 commit 9c9a59b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/components/app/PasswordStrength/PasswordStrength.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Banner, Label } from "@/components/common";
import { composeTailwindRenderProps } from "@/components/utils";
import { useEffect, useState } from "react";
import {
Meter as AriaMeter,
type MeterProps as AriaMeterProps,
Expand Down Expand Up @@ -69,12 +70,32 @@ export function PasswordStrength({
}

const StrengthLabel = ({ label }: { label: string }) => {
const [displayLabel, setDisplayLabel] = useState("");

// Reveal characters one by one
useEffect(() => {
const chars = label.split("");
let currentLabel = "";

const intervalId = setInterval(() => {
if (chars.length === 0) {
clearInterval(intervalId);
return;
}

currentLabel = chars.pop() + currentLabel;
setDisplayLabel(currentLabel);
}, 75);

return () => clearInterval(intervalId);
}, [label]);

const characters = useRandomReveal({
isPlaying: true,
duration: 0.7,
characters: label,
characters: displayLabel,
revealEasing: "linear",
revealDuration: 0.2,
revealDuration: 0.3,
updateInterval: 0.045,
});

Expand Down

0 comments on commit 9c9a59b

Please sign in to comment.