Skip to content

Commit

Permalink
Merge pull request #16 from ITurres/fix/accessibility
Browse files Browse the repository at this point in the history
Issue #11 🎫: Accessibility issues
  • Loading branch information
ITurres authored Mar 14, 2024
2 parents f9d6eca + ac31d28 commit a50c457
Show file tree
Hide file tree
Showing 17 changed files with 7,402 additions and 8,289 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ yarn-error.log*
config.ts

.env

# * pull request template.
pr.md
9 changes: 3 additions & 6 deletions .vscode/terminals.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"name": "Commit",
"type": "bash",
"color": "terminal.ansiBlue",
"icon": "git-commit",
"command": "git branch -a"
"icon": "git-commit"
},
{
"name": "React CLI",
Expand All @@ -20,8 +19,7 @@
"name": "React Dev Server",
"type": "bash",
"color": "terminal.ansiCyan",
"icon": "browser",
"command": "npm start"
"icon": "browser"
},
{
"name": "Jest",
Expand All @@ -33,8 +31,7 @@
"name": "Linters",
"type": "bash",
"color": "terminal.ansiGreen",
"icon": "checklist",
"command": "npx eslint '**/*.{ts,tsx}' && npx stylelint '**/*.{css,scss}'"
"icon": "checklist"
}
]
}
15,340 changes: 7,184 additions & 8,156 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 @@ -42,7 +42,7 @@
]
},
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/core": "^7.24.0",
"@babel/eslint-parser": "^7.22.9",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-syntax-jsx": "^7.22.5",
Expand Down
32 changes: 0 additions & 32 deletions src/components/UI/AnimatedButton.tsx

This file was deleted.

116 changes: 70 additions & 46 deletions src/components/UI/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const ContactForm: React.FC = () => {
// * sessionStorage.getItem('formContent')! is not null.
);

// * This state is to disable the submit button after the form is submitted.
const [formSubmittedStatus, setFormSubmittedStatus] = useState(false);
const [showSubmitButton, setShowSubmitButton] = useState(false);

const actionURL = process.env.REACT_APP_FORM_ACTION_URL;

Expand Down Expand Up @@ -54,8 +56,14 @@ const ContactForm: React.FC = () => {
) => {
if (isValid) {
inputDomElement.classList.remove('invalid');
if (inputDomElement.nextSibling instanceof HTMLElement) {
inputDomElement.nextSibling.classList.add('show');

// * If the input is valid, remove invalid class, add show class to next
// * input after label, and add valid class.
// ! Note: This method of accessing the next input after the label may not
// ! be the most robust.
const inputElementAfterLabelElement = inputDomElement.nextSibling?.nextSibling;
if (inputElementAfterLabelElement instanceof HTMLElement) {
inputElementAfterLabelElement.classList.add('show');
}
inputDomElement.classList.add('valid');
} else {
Expand All @@ -64,45 +72,46 @@ const ContactForm: React.FC = () => {
}
};

const setSubmitButtonStyle = (isValid: boolean) => {
if (isValid) {
$submitButton.current?.classList.remove('invalid');
$submitButton.current?.classList.add('valid');
} else {
$submitButton.current?.classList.remove('valid');
$submitButton.current?.classList.add('invalid');
}
};

const validateInput = useCallback((input: any, regex: RegExp) => {
const inputKey = input.obj.current?.name as keyof typeof inputs;
const isValid = regex.test(input.obj.current?.value || '');
const validateInput = useCallback(
(input: any, regex: RegExp) => {
const inputKey = input.obj.current?.name as keyof typeof inputs;
const isValid = regex.test(input.obj.current?.value || '');

inputs[inputKey].validated = isValid;
setInputStyle(input.obj.current, isValid);
inputs[inputKey].validated = isValid;
setInputStyle(input.obj.current, isValid);

// * set the submit button style based on the validity of all inputs.
setSubmitButtonStyle(
Object.values(inputs).every((inputObj) => inputObj.validated),
);
}, [inputs]);
// * set the submit button style based on the validity of all inputs.
const areAllValidInputs = Object.values(inputs).every(
(inputObj) => inputObj.validated,
);
if (areAllValidInputs) {
setShowSubmitButton(true);
} else {
setShowSubmitButton(false);
}
},
[inputs],
);

useEffect(() => {
if (formContent) {
sessionStorage.setItem('formContent', JSON.stringify(formContent));
}
}, [formContent]);

const updateFormContent = useCallback((input: any) => () => {
const inputKey = input.obj.current?.name as keyof typeof inputs;
const updateFormContent = useCallback(
(input: any) => () => {
const inputKey = input.obj.current?.name as keyof typeof inputs;

setFormContent((previousFormContent: any) => {
const currentFormContent = { ...previousFormContent };
currentFormContent[inputKey] = input.obj.current?.value;
setFormContent((previousFormContent: any) => {
const currentFormContent = { ...previousFormContent };
currentFormContent[inputKey] = input.obj.current?.value;

return currentFormContent;
});
}, []);
return currentFormContent;
});
},
[],
);

useEffect(() => {
Object.values(inputs).forEach((input) => {
Expand Down Expand Up @@ -236,7 +245,10 @@ const ContactForm: React.FC = () => {
ref={$form}
onSubmit={handleSubmission}
>
{/* eslint-disable jsx-a11y/label-has-associated-control */}
<label htmlFor="name">Name:</label>
<input
id="name"
type="text"
ref={$nameInputRef}
name="name"
Expand All @@ -245,7 +257,9 @@ const ContactForm: React.FC = () => {
required
/>

<label htmlFor="company">Company name: </label>
<input
id="company"
type="text"
ref={$companyInputRef}
name="company"
Expand All @@ -254,15 +268,19 @@ const ContactForm: React.FC = () => {
required
/>

<label htmlFor="email">Email: </label>
<input
id="email"
type="email"
ref={$emailInputRef}
name="email"
placeholder="an email, e.g [email protected]"
required
/>

<label htmlFor="message">Message: </label>
<textarea
id="message"
ref={$messageInputRef}
name="message"
placeholder="your message, at least 20 characters long"
Expand All @@ -271,22 +289,28 @@ const ContactForm: React.FC = () => {
required
/>

<button
type="submit"
disabled={formSubmittedStatus}
ref={$submitButton}
className="my-btn"
>
{formSubmittedStatus ? 'Thank you!' : 'Send'}
{formSubmittedStatus && (
<img
src={successButtonIcon}
alt="alien waving hand"
aria-hidden="true"
className="send-email-icon"
/>
)}
</button>
{showSubmitButton && (
<button
type="submit"
disabled={formSubmittedStatus}
ref={$submitButton}
className={`my-btn ${showSubmitButton ? 'valid show' : 'invalid'}`}
aria-label={
formSubmittedStatus ? 'Thank you! email sent' : 'Send email'
}
>
{formSubmittedStatus ? 'Thank you!' : 'Send'}

{formSubmittedStatus && (
<img
src={successButtonIcon}
alt="alien waving hand"
aria-hidden="true"
className="send-email-icon"
/>
)}
</button>
)}
</form>
);
};
Expand Down
41 changes: 41 additions & 0 deletions src/components/UI/ExpertiseLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { Link } from 'react-router-dom';

import '../../styles/UI/ExpertiseLinks.scss';

const ExpertiseLinks: React.FC = () => (
<div className="expertise-links">
<Link
to="/homepage/expertise"
className="text-hue-rotate"
aria-label="navigate to expertise section"
>
languages
</Link>
<Link
to="/homepage/expertise"
className="text-hue-rotate"
aria-label="navigate to expertise section"
>
frameworks
</Link>
<Link
to="/homepage/expertise"
className="text-hue-rotate"
aria-label="navigate to expertise section"
>
skills
</Link>
<a
href="https://docs.google.com/document/d/1vfOALwpILAh8Jn29zV6aO6jwuGZQwLyYjRb3_YKZfQ0/edit?usp=sharing"
className="text-hue-rotate"
aria-label="navigate to Arthur's resume which is hosted on Google Docs"
target="_blank"
rel="noreferrer noopener"
>
resume
</a>
</div>
);

export default ExpertiseLinks;
38 changes: 17 additions & 21 deletions src/components/UI/FileTabsNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,57 +21,53 @@ const FileTabsNavbar: React.FC = () => {
);

return (
<nav className="file-tabs-navbar">
<nav
className="file-tabs-navbar"
aria-label="Desktop File Tabs"
role="navigation"
>
<ul>
<li>
<Link
to={paths.homepage}
aria-label="About Me Page - learn more about Arthur"
className={pathname === paths.homepage ? 'active' : ''}
title="About Arthur"
>
<FaReact
size={iconSize}
className="tech-logo"
title="about me page"
/>
<FaReact size={iconSize} className="tech-logo" />
About.tsx
</Link>
</li>
<li>
<Link
to={paths.projects}
aria-label="My Projects Page - learn more about Arthur's projects"
className={pathname === paths.projects ? 'active' : ''}
title="Arthur's Projects Page"
>
<FaReact
size={iconSize}
className="tech-logo"
title="my projects page"
/>
<FaReact size={iconSize} className="tech-logo" />
Projects.tsx
</Link>
</li>
<li>
<Link
to={paths.contact}
aria-label="Contact Me Page - contact Arthur"
className={pathname === paths.contact ? 'active' : ''}
title="Arthur's Contact Page"
>
<FaReact
size={iconSize}
className="tech-logo"
title="contact page"
/>
<FaReact size={iconSize} className="tech-logo" />
Contact.tsx
</Link>
</li>
<li>
<Link
to={paths.expertise}
aria-label="My Expertise Page - learn more about Arthur's expertise"
className={pathname === paths.expertise ? 'active' : ''}
title="Arthur's Expertise Page"
>
<FaReact
size={iconSize}
className="tech-logo"
title="expertise page"
/>
<FaReact size={iconSize} className="tech-logo" />
Expertise.tsx
</Link>
</li>
Expand Down
Loading

0 comments on commit a50c457

Please sign in to comment.