Skip to content
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

feat: added a popup which displays the valid rules of a username while signing up #1312

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
954 changes: 145 additions & 809 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@fortawesome/free-solid-svg-icons": "^6.3.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mui/icons-material": "^5.11.11",
"@mui/material": "^5.13.6",
"@mui/material": "^5.14.20",
"@mui/styles": "^5.13.2",
"emoji-picker-react": "^4.4.10",
"file-saver": "^2.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
--page-over-color: #26282b;
--slide-color: #041c32;
--label-color: #6a656b;
--profile-color: #c8c6c6;
--profile-color: #a9a9a9;
--text-black-only: black;
--text-light: rgba(255, 255, 255, 0.6);
--text-light-black: rgba(0, 0, 0, 0.6);
Expand Down
14 changes: 14 additions & 0 deletions src/pages/Signup/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,19 @@
border: 2px solid green;
}

.username-rules {
color: var(--profile-color);
font-size: 15px;
}

.error-border {
border: 2px solid red !important;
}

.success-border {
border: 2px solid green;
}

.password-container {
display: flex;
justify-content: space-between;
Expand Down Expand Up @@ -92,6 +101,11 @@
color: red;
}

.success{
font-size: 12px;
color: green;
}

.pass-container-both {
display: flex;
flex-direction: column;
Expand Down
42 changes: 37 additions & 5 deletions src/pages/Signup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const SignupScreen = () => {
setUsernameAvailable(true);
} else {
setUsernameAvailable(false);

enqueueSnackbar("Sorry, this username is already in use. Please try another username.", {variant: "error"})
}
};

Expand All @@ -83,10 +85,11 @@ const SignupScreen = () => {
}
});

if (username === "") submitable = false;

if (username !== "") {
submitable = false;
}
if (!usernameAvailable) {
playErrorSound();
playErrorSound();
enqueueSnackbar("Username not available!", {
variant: "error",
});
Expand Down Expand Up @@ -213,10 +216,34 @@ const SignupScreen = () => {
fieldName={"username"}
aria_dsc_by={"username-error"}
isError={!usernameAvailable}
errorMesssage={"Username not availaible"}
errorMesssage={!username.length ? `Username cannot be empty` : `Username is invalid`}
error_border={usernameAvailable}
successMessage={"Perfect!"}
/>


{ !usernameAvailable &&
<div className= "username-rules">
A valid username must
<ul>
<li>
NOT contain captial letters.
</li>
<li>
NOT contain special characters.
</li>
<li>
NOT start with a digit.
</li>
<li>
be between 4 and 20 letters long.
</li>
<li>
NOT be registered.
</li>
</ul>
</div>
}

{/* fullname input for the form */}
<Auth__text__input
label={"Full name"}
Expand All @@ -233,6 +260,7 @@ const SignupScreen = () => {
isError={error.name && error.nameError}
errorMesssage={error.nameError}
error_border={!error.nameError}
successMessage={"Perfect!"}
/>

{/* Email input for the form */}
Expand All @@ -252,6 +280,7 @@ const SignupScreen = () => {
isError={error.email && error.emailError}
errorMesssage={error.emailError}
error_border={!error.emailError}
successMessage={"Perfect!"}
/>
<div className="pass-container-both">
{/* password input for the form */}
Expand All @@ -268,6 +297,7 @@ const SignupScreen = () => {
maxLength={30}
aria_dsc_by={"password-error"}
errorMesssage={error.passwordError}
successMessage={"Perfect!"}
isError={error.password && error.passwordError}
/>

Expand All @@ -285,7 +315,9 @@ const SignupScreen = () => {
maxLength={30}
aria_dsc_by={"confirm-password-error"}
errorMesssage={error.confirmPasswordError}
successMessage={"Perfect!"}
isError={error.confirmPassword && error.confirmPasswordError}

/>
</div>
<Auth__ctn__group
Expand Down
10 changes: 8 additions & 2 deletions src/reusableComponents/Auth/Auth__pass__input.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from "react";
import { RiEyeCloseFill, RiEyeFill } from "react-icons/ri";
import { IoCheckmarkCircle } from "react-icons/io5";

const Auth__pass__input = ({
label,
Expand All @@ -12,6 +13,7 @@ const Auth__pass__input = ({
errorMesssage,
isError,
maxLength,
successMessage,
}) => {
const [showPassword, setShowPassword] = useState(false);
const handleShowPassword = (e) => {
Expand All @@ -27,7 +29,7 @@ const Auth__pass__input = ({
className={
errorMesssage
? "error-border pass__input__container password-container"
: "pass__input__container password-container"
: !value ? "pass__input__container password-container" : "success-border pass__input__container password-container"
}
>
<input
Expand All @@ -51,11 +53,15 @@ const Auth__pass__input = ({
{showPassword ? <RiEyeFill /> : <RiEyeCloseFill />}
</button>
</div>
{isError && (
{isError ? (
<p className="error" id="password-error">
{errorMesssage}
</p>
):( value && <p className="success" id={`success`}>
<IoCheckmarkCircle /> {successMessage}
</p>
)}

</div>
);
};
Expand Down
13 changes: 11 additions & 2 deletions src/reusableComponents/Auth/Auth__text__input.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from "react";

import { IoIosWarning } from "react-icons/io";
import { IoCheckmarkCircle } from "react-icons/io5";

const Auth__text__input = ({
label,
id,
Expand All @@ -10,6 +13,7 @@ const Auth__text__input = ({
isError,
aria_dsc_by,
errorMesssage,
successMessage,
fieldName,
maxLength,
type = "text",
Expand All @@ -24,7 +28,7 @@ const Auth__text__input = ({
placeholder={placeholder}
value={value}
onChange={(e) => handleChange(e)}
className={error_border ? null : "error-border"}
className={error_border ? (!value ? null : "success-border") : "error-border"}
required
maxLength={maxLength}
aria-required="true"
Expand All @@ -33,9 +37,14 @@ const Auth__text__input = ({
/>
{isError && (
<p className="error" id={`${fieldName}-error`}>
{errorMesssage}
<IoIosWarning /> {errorMesssage}
</p>
)}
{!isError && value &&
<p className="success" id={`${fieldName}-success`}>
<IoCheckmarkCircle /> {successMessage}
</p>
}
</div>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/reusableComponents/Auth/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@
font-size: 50px !important;
}
}

Loading