Files
spacedrive/interface/components/PasswordMeter.tsx
Oscar Beaumont 2571e3b275 Upgrade rspc TS (#775)
* finally

* should be working?

* fix types

* fix types

* Wouldn't it be nice if Metro would just work

* idk

* try harder Metro

* potentially fix bundling issues

* idk, maybe fix it?

* fix metro

* update podfile.lock

* bruh

* bruhz

* tailwind is drunk again

---------

Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com>
2023-05-04 06:21:42 +00:00

46 lines
1.1 KiB
TypeScript

import clsx from 'clsx';
import { getPasswordStrength } from '@sd/client';
export interface PasswordMeterProps {
password: string;
}
export const PasswordMeter = (props: PasswordMeterProps) => {
const { score, scoreText } = getPasswordStrength(props.password);
return (
<div className="relative">
<h3 className="text-sm">Password strength</h3>
<span
className={clsx(
'absolute right-0 top-0.5 px-1 text-sm font-semibold',
score === 0 && 'text-red-500',
score === 1 && 'text-red-500',
score === 2 && 'text-amber-400',
score === 3 && 'text-lime-500',
score === 4 && 'text-accent'
)}
>
{scoreText}
</span>
<div className="flex grow">
<div className="mt-2 w-full rounded-full bg-app-box/50">
<div
style={{
width: `${score !== 0 ? score * 25 : 12.5}%`
}}
className={clsx(
'h-2 rounded-full transition-all',
score === 0 && 'bg-red-500',
score === 1 && 'bg-red-500',
score === 2 && 'bg-amber-400',
score === 3 && 'bg-lime-500',
score === 4 && 'bg-accent'
)}
/>
</div>
</div>
</div>
);
};