-
Notifications
You must be signed in to change notification settings - Fork 23
[jules] enhance: Add password strength meter to signup #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Devasy
merged 5 commits into
main
from
jules/password-strength-meter-12713428636481219202
Feb 9, 2026
+143
−0
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ccf189c
[jules] enhance: Add password strength meter to signup
google-labs-jules[bot] 3b380e7
Update web/components/ui/PasswordStrength.tsx
Devasy 23e0b2b
Update web/components/ui/PasswordStrength.tsx
Devasy f43533e
[jules] fix: Update password strength criteria to 6 chars and merge main
google-labs-jules[bot] ce54ede
Merge branch 'main' into jules/password-strength-meter-12713428636481…
Devasy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| import React, { useMemo } from 'react'; | ||
| import { useTheme } from '../../contexts/ThemeContext'; | ||
| import { THEMES } from '../../constants'; | ||
| import { Check } from 'lucide-react'; | ||
|
|
||
| interface PasswordStrengthProps { | ||
| password?: string; | ||
| } | ||
|
|
||
| export const PasswordStrength: React.FC<PasswordStrengthProps> = ({ password = '' }) => { | ||
| const { style } = useTheme(); | ||
|
|
||
| const { score, label, metCriteria } = useMemo(() => { | ||
| let s = 0; | ||
| const criteria = { | ||
| length: password.length >= 6, | ||
| hasUpper: /[A-Z]/.test(password), | ||
| hasLower: /[a-z]/.test(password), | ||
| hasNumber: /[0-9]/.test(password), | ||
| hasSpecial: /[^A-Za-z0-9]/.test(password), | ||
| }; | ||
|
|
||
| let l = 'Weak'; | ||
|
|
||
| if (password.length > 0) { | ||
| if (password.length < 6) { | ||
| s = 1; // Very Weak | ||
| l = 'Too Short'; | ||
| } else { | ||
| s = 1; | ||
| // Bonus for length | ||
| if (criteria.length) s++; | ||
|
|
||
| // Bonus for complexity | ||
| const complexity = (criteria.hasUpper ? 1 : 0) + | ||
| (criteria.hasLower ? 1 : 0) + | ||
| (criteria.hasNumber ? 1 : 0) + | ||
| (criteria.hasSpecial ? 1 : 0); | ||
|
|
||
| if (complexity >= 2) s++; | ||
| if (complexity >= 4) s++; // Max bonus | ||
|
|
||
| // Adjust label based on final score | ||
| if (s >= 4) l = 'Strong'; | ||
| else if (s === 3) l = 'Good'; | ||
| else if (s === 2) l = 'Fair'; | ||
| else l = 'Weak'; | ||
| } | ||
| } else { | ||
| l = ''; | ||
| } | ||
|
|
||
| // Normalize score 0-4 | ||
| if (s > 4) s = 4; | ||
|
|
||
| return { score: s, label: l, metCriteria: criteria }; | ||
| }, [password]); | ||
|
|
||
| const getColor = (s: number) => { | ||
| switch (s) { | ||
| case 1: return 'bg-red-500'; | ||
| case 2: return 'bg-orange-500'; | ||
| case 3: return 'bg-yellow-500'; | ||
| case 4: return 'bg-green-500'; | ||
| default: return 'bg-gray-200 dark:bg-zinc-700'; | ||
| } | ||
| }; | ||
|
|
||
| const isNeo = style === THEMES.NEOBRUTALISM; | ||
|
|
||
| if (!password) return null; | ||
|
|
||
| return ( | ||
| <div className="w-full flex flex-col gap-2 mt-2" role="region" aria-label="Password strength indicator"> | ||
Devasy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {/* Strength Bar */} | ||
| <div className="flex w-full gap-1 h-2"> | ||
| {[1, 2, 3, 4].map((level) => ( | ||
| <div | ||
| key={level} | ||
| className={`flex-1 h-full transition-all duration-300 ${ | ||
| score >= level | ||
| ? getColor(score) | ||
| : (isNeo ? 'bg-gray-200 dark:bg-zinc-800' : 'bg-white/10') | ||
| } ${isNeo ? 'border-2 border-black' : 'rounded-full'}`} | ||
| /> | ||
| ))} | ||
| </div> | ||
|
|
||
| {/* Label and Criteria */} | ||
| <div className="flex justify-between items-center h-4"> | ||
| <span className={`text-xs font-bold transition-colors duration-300 ${ | ||
| score === 4 ? 'text-green-600 dark:text-green-400' : | ||
| score === 3 ? 'text-yellow-600 dark:text-yellow-400' : | ||
| score === 2 ? 'text-orange-600 dark:text-orange-400' : | ||
| 'text-red-600 dark:text-red-400' | ||
| } ${isNeo ? 'uppercase tracking-wider' : ''}`}> | ||
| {label} | ||
| </span> | ||
| </div> | ||
|
|
||
| <div className="grid grid-cols-2 gap-y-1 gap-x-4 text-[10px] text-gray-500 dark:text-gray-400 transition-opacity duration-300"> | ||
| <div className={`flex items-center gap-1.5 ${metCriteria.length ? 'text-green-600 dark:text-green-400 font-bold' : ''}`}> | ||
| {metCriteria.length ? <Check size={12} strokeWidth={3} /> : <div className="w-3" />} | ||
| 6+ characters | ||
| </div> | ||
| <div className={`flex items-center gap-1.5 ${(metCriteria.hasUpper && metCriteria.hasLower) ? 'text-green-600 dark:text-green-400 font-bold' : ''}`}> | ||
| {(metCriteria.hasUpper && metCriteria.hasLower) ? <Check size={12} strokeWidth={3} /> : <div className="w-3" />} | ||
| Mixed case | ||
| </div> | ||
| <div className={`flex items-center gap-1.5 ${metCriteria.hasNumber ? 'text-green-600 dark:text-green-400 font-bold' : ''}`}> | ||
| {metCriteria.hasNumber ? <Check size={12} strokeWidth={3} /> : <div className="w-3" />} | ||
| Number | ||
| </div> | ||
| <div className={`flex items-center gap-1.5 ${metCriteria.hasSpecial ? 'text-green-600 dark:text-green-400 font-bold' : ''}`}> | ||
| {metCriteria.hasSpecial ? <Check size={12} strokeWidth={3} /> : <div className="w-3" />} | ||
| Symbol | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Hidden live region for accessibility */} | ||
| <output className="sr-only" aria-live="polite"> | ||
| Password strength: {label}. | ||
| {score < 4 && label ? "Add more characters, numbers, or symbols to strengthen." : ""} | ||
| </output> | ||
| </div> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.