Skip to content

Commit f4c2191

Browse files
feat: improved formatting of signup sudo password feedback (#346)
* feat: improved formatting of signup sudo password feedback * fix: invite signup password description grammar * feat: use *may because the user could use remember option - on by default * Update frontend/components/onboarding/AccountPassword.tsx Co-authored-by: Rohan Chaturvedi <[email protected]> --------- Co-authored-by: Rohan Chaturvedi <[email protected]>
1 parent 964124e commit f4c2191

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

frontend/app/invite/[invite]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default function Invite({ params }: { params: { invite: string } }) {
8989
icon: <MdOutlinePassword />,
9090
title: 'Set a sudo password',
9191
description:
92-
'This will be used to encrypt your account keys. You will be need to enter this password to perform administrative tasks.',
92+
'This will be used to encrypt your account keys. You may need to enter this password to perform administrative tasks.',
9393
},
9494
{
9595
index: 1,

frontend/app/signup/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const Onboard = () => {
9292
icon: <MdOutlinePassword />,
9393
title: 'Set a sudo password',
9494
description:
95-
'This will be used to encrypt your account keys. You will need to enter this password to unlock your workspace when logging in.',
95+
'This will be used to encrypt your account keys. You may need to enter this password to unlock your workspace when logging in.',
9696
},
9797
{
9898
index: 2,

frontend/components/onboarding/AccountPassword.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, SetStateAction, useEffect, useState } from 'react'
1+
import React, { useEffect, useState } from 'react'
22
import { ZXCVBNResult } from 'zxcvbn'
33
import { FaCheck, FaEye, FaEyeSlash, FaInfo, FaShieldAlt } from 'react-icons/fa'
44
import clsx from 'clsx'
@@ -23,10 +23,10 @@ export const AccountPassword = (props: AccountPasswordProps) => {
2323
const zxcvbn = require('zxcvbn')
2424
const strength = zxcvbn(pw)
2525
setPwStrength(strength)
26-
}, [pw, setPwStrength])
26+
}, [pw])
2727

2828
/**
29-
* Returns a color name based on the current password stength score
29+
* Returns a color name based on the current password strength score
3030
*
3131
* @returns {string}
3232
*/
@@ -50,17 +50,14 @@ export const AccountPassword = (props: AccountPasswordProps) => {
5050
color = 'bg-red-500'
5151
break
5252
}
53-
5453
return color
5554
}
5655

5756
const pwStrengthPercent = (): string => {
58-
let score = '0%'
59-
if (pw) score = `${(pwStrength.score / 4) * 100}%`
60-
return score
57+
return pw ? `${(pwStrength.score / 4) * 100}%` : '0%'
6158
}
6259

63-
const passwordIsStrong = pwStrength?.feedback?.suggestions?.length == 0 || false
60+
const passwordIsStrong = pwStrength?.feedback?.suggestions?.length === 0
6461

6562
return (
6663
<div className="space-y-4 max-w-md mx-auto">
@@ -124,17 +121,28 @@ export const AccountPassword = (props: AccountPasswordProps) => {
124121
}}
125122
></div>
126123
</div>
127-
<div className="flex w-full items-center gap-4 p-3 bg-zinc-200 dark:bg-zinc-800 dark:bg-opacity-60 rounded-b-md text-black/50 dark:text-white/50">
128-
{passwordIsStrong ? <FaCheck /> : <FaInfo />}
129-
{passwordIsStrong ? 'Strong password' : pwStrength?.feedback?.suggestions}
124+
<div className="flex w-full items-start gap-6 p-3 bg-zinc-200 dark:bg-zinc-800 dark:bg-opacity-60 rounded-b-md text-black/50 dark:text-white/50 text-sm">
125+
<div className="mt-1">
126+
{passwordIsStrong ? <FaCheck /> : <FaInfo />}
127+
</div>
128+
<div className="flex-grow">
129+
{passwordIsStrong ? (
130+
'Strong password'
131+
) : (
132+
<ul className="list-disc pl-4">
133+
{pwStrength?.feedback?.suggestions?.map((suggestion, index) => (
134+
<li key={index}>{suggestion}</li>
135+
))}
136+
</ul>
137+
)}
138+
</div>
130139
</div>
131140
</div>
132141

133142
<div className="flex items-center justify-between gap-2 py-2">
134143
<div className="flex items-center gap-2">
135-
{' '}
136144
<FaShieldAlt className="text-emerald-500" />
137-
<span className="text-neutral-500 text-sm">Remember password on this device </span>
145+
<span className="text-neutral-500 text-sm">Remember password on this device</span>
138146
</div>
139147
<ToggleSwitch value={savePassword} onToggle={() => setSavePassword(!savePassword)} />
140148
</div>

0 commit comments

Comments
 (0)