Skip to content

Commit

Permalink
Merge pull request #26 from brunomachadors/25-investigate-and-resolve…
Browse files Browse the repository at this point in the history
…-hydration-error-in-console

feat(contact-page): add loading spinner, accessibility improvements, …
  • Loading branch information
brunomachadors authored Jan 6, 2025
2 parents 0dadc8e + 3308ba5 commit 990ab32
Show file tree
Hide file tree
Showing 22 changed files with 624 additions and 143 deletions.
Binary file added public/icons/email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/instagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/medium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
'use client';

import { useState, useEffect } from 'react';
import Image from 'next/image';
import AboutSections from '../components/AboutSections/AboutSections';
import LinkButton from '../components/Button/LinkButton';
import LoadingSpinner from '../components/Loading/Loading';

export default function About() {
const [isLoading, setIsLoading] = useState(true);

useEffect(() => {
const timer = setTimeout(() => {
setIsLoading(false);
}, 1000); // Simulate a loading time, adjust as needed
return () => clearTimeout(timer);
}, []);

if (isLoading) {
return (
<div className="flex items-center justify-center min-h-screen">
<LoadingSpinner />
</div>
);
}

return (
<main
className="flex flex-col items-center justify-center min-h-[85vh] p-8"
Expand All @@ -24,6 +45,7 @@ export default function About() {
height={600}
className="rounded-lg shadow-lg object-cover"
aria-label="Photo of Bruno Machado"
priority
/>
</div>

Expand Down
39 changes: 22 additions & 17 deletions src/app/components/AboutSections/AboutSections.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';
import React from 'react';
import { useState } from 'react';
import React, { useState } from 'react';

const sections = [
{
Expand Down Expand Up @@ -64,56 +63,62 @@ export default function AboutSections() {
</p>

{sections.map((section, index) => (
<div
<section
key={index}
className="w-full pb-4 border-b border-yellow-500 cursor-pointer last:border-none px-0 mx-0"
data-test-id={`section-${index}`}
onClick={() => toggleSection(index)}
>
<div className="flex justify-between items-center">
<span
<header
className="flex justify-between items-center"
role="button"
tabIndex={0}
aria-expanded={openSection === index}
aria-controls={`section-content-${index}`}
data-test-id={`section-toggle-${index}`}
>
<h2
className="text-lg sm:text-xl font-bold text-yellow-500"
data-test-id={`section-title-${index}`}
id={`section-title-${index}`}
>
{section.title}
</span>
</h2>
<span
className={`transform transition-transform duration-300 ${
openSection === index ? 'rotate-180' : ''
}`}
data-test-id={`toggle-icon-${index}`}
onClick={() => toggleSection(index)}
role="button" // Semântica de acessibilidade
aria-expanded={openSection === index}
>
</span>
</div>
</header>
{openSection === index && (
<div
className="mt-2 text-gray-300 text-base sm:text-lg"
data-test-id={`section-content-${index}`}
id={`section-content-${index}`}
>
{typeof section.content === 'string' ? (
<span data-test-id={`section-text-${index}`}>
{section.content}
</span>
<p data-test-id={`section-text-${index}`}>{section.content}</p>
) : (
<div>
<div data-test-id={`section-content-wrapper-${index}`}>
{React.Children.map(
section.content.props.children,
(child, childIndex) => (
<p
<div
key={childIndex}
data-test-id={`section-content-${index}-line-${childIndex}`}
>
{child}
</p>
</div>
)
)}
</div>
)}
</div>
)}
</div>
</section>
))}
</div>
);
Expand Down
10 changes: 9 additions & 1 deletion src/app/components/Button/SkillButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ interface SkillButtonProps {
description?: string;
isActive: boolean;
onClick: () => void;
testId?: string; // Novo parâmetro para test ID
}

export default function SkillButton({
text,
description = 'This is a placeholder description for the skill.',
isActive,
onClick,
testId, // Recebendo test ID
}: SkillButtonProps) {
const colorClasses = skillColors[text] || defaultSkillColor;

Expand All @@ -26,6 +28,7 @@ export default function SkillButton({
alignItems: 'center',
justifyContent: 'center',
}}
data-test-id={testId} // Adicionando test ID ao container principal
>
<button
className={`border ${
Expand All @@ -36,16 +39,21 @@ export default function SkillButton({
textAlign: 'center',
whiteSpace: 'normal',
}}
data-test-id={`${testId}-button`} // Adicionando test ID específico para o botão
>
<span
className={`font-bold transition-all duration-300 ${
isActive ? 'text-2xl sm:text-2xl px-4 sm:px-12' : 'text-lg'
}`}
data-test-id={`${testId}-text`} // Test ID para o texto
>
{text}
</span>
{isActive && (
<p className={`mt-4 text-m sm:text-xl ${colorClasses} px-4 sm:px-12`}>
<p
className={`mt-4 text-m sm:text-xl ${colorClasses} px-4 sm:px-12`}
data-test-id={`${testId}-description`} // Test ID para a descrição
>
{description}
</p>
)}
Expand Down
10 changes: 5 additions & 5 deletions src/app/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function Footer() {
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase"
data-test-id="footer-link-instagram"
>
<span className="material-icons text-sm sm:text-xl">instagram</span>
<span className=" text-sm sm:text-xl">instagram</span>
</a>
<a
href="https://www.linkedin.com/in/brunomrs/"
Expand All @@ -26,7 +26,7 @@ export default function Footer() {
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase"
data-test-id="footer-link-linkedin"
>
<span className="material-icons text-sm sm:text-xl">linkedin</span>
<span className=" text-sm sm:text-xl">linkedin</span>
</a>
<a
href="https://github.com/brunomachadors"
Expand All @@ -36,7 +36,7 @@ export default function Footer() {
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase"
data-test-id="footer-link-github"
>
<span className="material-icons text-sm sm:text-xl">github</span>
<span className=" text-sm sm:text-xl">github</span>
</a>
<a
href="https://medium.com/@brunomachadoricardosilva"
Expand All @@ -46,15 +46,15 @@ export default function Footer() {
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase"
data-test-id="footer-link-medium"
>
<span className="material-icons text-sm sm:text-xl">Medium</span>
<span className="text-sm sm:text-xl">Medium</span>
</a>
<a
href="mailto:[email protected]"
aria-label="EMAIL"
className="hover:text-yellow-500 transition transform hover:scale-110 uppercase"
data-test-id="footer-link-email"
>
<span className="material-icons text-sm sm:text-xl">Email</span>
<span className=" text-sm sm:text-xl">Email</span>
</a>
</div>

Expand Down
36 changes: 36 additions & 0 deletions src/app/components/Loading/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
interface LoadingSpinnerProps {
size?: string; // Tamanho do spinner, ex: 'w-8 h-8'
color?: string; // Cor de preenchimento do spinner
text?: string; // Texto opcional para acessibilidade
}

export default function LoadingSpinner({
size = 'w-12 h-12',
color = 'fill-yellow-400',
text = 'Loading...',
}: LoadingSpinnerProps) {
return (
<div
role="status"
className="flex flex-col items-center justify-center gap-2"
>
<svg
aria-hidden="true"
className={`animate-spin ${size} text-gray-200 dark:text-gray-600 ${color}`}
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span className="sr-only">{text}</span>
</div>
);
}
4 changes: 2 additions & 2 deletions src/app/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import Header from './Header/Header';

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div className="flex flex-col justify-between h-screen">
<div className="flex flex-col justify-between min-h-screen">
<Header />
<main>{children}</main>
{children}
<Footer />
</div>
);
Expand Down
Loading

0 comments on commit 990ab32

Please sign in to comment.