Files
supabase/apps/studio/components/ui/PasswordStrengthBar.tsx
T
Jonathan Summers-MuirandJoshen Lim 330ae6e407 [Dashboard] Chore/refactor new project form (#26997)
* init layouts in project settings

* Update general.tsx

* update gap

* Update Scaffold.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* spacing issues

* now added a enabled switch

* Revert "now added a enabled switch"

This reverts commit f22050302a.

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* revert

* Update project-postgrest-config-update-mutation.ts

* add bottom padding

* init changes

* Update PostgrestConfig.tsx

* Update [slug].tsx

* Update PostgrestConfig.tsx

* fix

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* Pull updates, resolve conflicts

* remove staging/local specific logic.

• stopped provider Select from flashing
•

* Update [slug].tsx

* split up region query

* Update [slug].tsx

* Update [slug].tsx

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-06-06 19:32:10 +08:00

53 lines
1.6 KiB
TypeScript

import { PASSWORD_STRENGTH_COLOR, PASSWORD_STRENGTH_PERCENTAGE } from 'lib/constants'
interface Props {
passwordStrengthScore: number
passwordStrengthMessage: string
password: string
generateStrongPassword: () => void
}
const PasswordStrengthBar = ({
passwordStrengthScore = 0,
passwordStrengthMessage = '',
password = '',
generateStrongPassword,
}: Props) => {
return (
<>
{password && (
<div
aria-valuemax={100}
aria-valuemin={0}
aria-valuenow={(PASSWORD_STRENGTH_PERCENTAGE as any)[passwordStrengthScore]}
aria-valuetext={(PASSWORD_STRENGTH_PERCENTAGE as any)[passwordStrengthScore]}
role="progressbar"
className="mb-2 overflow-hidden transition-all border rounded bg-200 w-full"
>
<div
style={{
width: (PASSWORD_STRENGTH_PERCENTAGE as any)[passwordStrengthScore],
}}
className={`relative h-1 w-full ${
(PASSWORD_STRENGTH_COLOR as any)[passwordStrengthScore]
} transition-all duration-500 ease-out shadow-inner`}
></div>
</div>
)}
<p>
{passwordStrengthMessage
? passwordStrengthMessage
: 'This is the password to your postgres database, so it must be strong and hard to guess.'}{' '}
<span
className="text-foreground opacity-50 underline hover:opacity-100 transition cursor-pointer"
onClick={generateStrongPassword}
>
Generate a password
</span>
</p>
</>
)
}
export default PasswordStrengthBar