Files
spacedrive/interface/components/PasswordMeter.tsx
Utku ca6ec598d4 Onboarding, Spacedrop & Location Settings Screen & Styled API (#596)
* fix wrong current lib logic

* add delete lib dialog to LibraryGeneralSettings

* add delete lib to mobile LibraryGeneralSettings too

* onboarding screens

* move zxcvbn to @sd/client

* get started screen and bloom

* merge fix

* move generatePassword back to interface

* add useZodForm to mobile and match react-hook-form versions

* new lib screen

* Implement styled api

* create lib screen and some tweaks

* password input

* fix password meter comp

* new library style tweaks

* Fix remove password bug (interface)

* master password screen

* privacy screen

* creating lib screen

* hexagons are cool

* Expo 48

* keyboard handling

* fix P2P on IOS

* fix types

* asset script

* new icons

* Spacedrop screen

* Fix mobile asset imports

* fix import cycle warning

* Edit Location Settings screen and style changes on other setting screens

* fix library creating bug? hopefully lol

* move PasswordMeter to interface

---------

Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
2023-03-17 02:00:02 +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 top-0.5 right-0 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="bg-app-box/50 mt-2 w-full rounded-full">
<div
style={{
width: `${score !== 0 ? score * 25 : 12.5}%`
}}
className={clsx(
'h-2 rounded-full',
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>
);
};