import { Typography, useTheme } from "@mui/material"; import { t } from "i18next"; import React, { useMemo } from "react"; import { estimatePasswordStrength } from "../utils/password"; interface PasswordStrengthHintProps { password: string; } export const PasswordStrengthHint: React.FC = ({ password, }) => { const passwordStrength = useMemo( () => estimatePasswordStrength(password), [password], ); const theme = useTheme(); const color = passwordStrength == "weak" ? theme.vars.palette.critical.main : passwordStrength == "moderate" ? theme.vars.palette.warning.main : theme.vars.palette.accent.main; return ( {password ? t("passphrase_strength", { context: passwordStrength }) : /* empty space + white-space: pre to prevent layout shift. */ " "} ); };