-
Notifications
You must be signed in to change notification settings - Fork 52
Refactor GitHub link handling in Header component for improved structure and mobile responsiveness #293
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
Refactor GitHub link handling in Header component for improved structure and mobile responsiveness #293
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -46,14 +46,15 @@ function Header({notice }) { | |||||||||||||||||||||||||||||
| link: "/resources", | ||||||||||||||||||||||||||||||
| icon: <MdStore size="1.2rem" />, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| name: "Github", | ||||||||||||||||||||||||||||||
| link: "https://github.com/devvsakib/github-error-solve", | ||||||||||||||||||||||||||||||
| icon: <AiFillGithub size="1.2rem" />, | ||||||||||||||||||||||||||||||
| isExternalURL: true, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const githubLink = { | ||||||||||||||||||||||||||||||
| name: "Github", | ||||||||||||||||||||||||||||||
| link: "https://github.com/devvsakib/github-error-solve", | ||||||||||||||||||||||||||||||
| icon: <AiFillGithub size="1.2rem" />, | ||||||||||||||||||||||||||||||
| isExternalURL: true, | ||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <header className="p-4 shadow-lg backdrop-blur-sm z-50"> | ||||||||||||||||||||||||||||||
| <div className="w-full md:w-5/6 mx-auto flex flex-row md:flex-row justify-between items-center"> | ||||||||||||||||||||||||||||||
|
|
@@ -66,12 +67,32 @@ function Header({notice }) { | |||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| {/* Menu icon */} | ||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||
| onClick={() => setOpen((val) => !val)} | ||||||||||||||||||||||||||||||
| className="cursor-pointer md:hidden" | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {open ? <MdClose size="1.2rem" /> : <MdMenu size="1.2rem" />} | ||||||||||||||||||||||||||||||
| {/* GitHub, theme toggle and menu icon for mobile */} | ||||||||||||||||||||||||||||||
| <div className="flex items-center gap-3 md:hidden"> | ||||||||||||||||||||||||||||||
| <a target="_blank" href={githubLink.link}> | ||||||||||||||||||||||||||||||
| <div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full text-sm"> | ||||||||||||||||||||||||||||||
| <span className="githubBtn"> | ||||||||||||||||||||||||||||||
| {githubLink.icon} | ||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| countStar && ( | ||||||||||||||||||||||||||||||
| <div className="flex items-center gap-1"> | ||||||||||||||||||||||||||||||
| {countStar} | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||
| <div className="text-lg cursor-pointer" onClick={toggleTheme}> | ||||||||||||||||||||||||||||||
| <HiMoon className="dark:hidden" /> | ||||||||||||||||||||||||||||||
| <HiSun className="hidden dark:inline" /> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
|
Comment on lines
+119
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add accessible label to theme toggle button. The theme toggle lacks semantic button markup and an Apply this diff to improve accessibility: -<div className="text-lg cursor-pointer" onClick={toggleTheme}>
+<button className="text-lg cursor-pointer bg-transparent border-0" onClick={toggleTheme} aria-label="Toggle theme">
<HiMoon className="dark:hidden" />
<HiSun className="hidden dark:inline" />
-</div>
+</button>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||
| onClick={() => setOpen((val) => !val)} | ||||||||||||||||||||||||||||||
| className="cursor-pointer" | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {open ? <MdClose size="1.2rem" /> : <MdMenu size="1.2rem" />} | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
|
Comment on lines
+123
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add accessible label to menu toggle button. The menu toggle lacks semantic button markup and an Apply this diff to improve accessibility: -<div
- onClick={() => setOpen((val) => !val)}
- className="cursor-pointer"
->
+<button
+ onClick={() => setOpen((val) => !val)}
+ className="cursor-pointer bg-transparent border-0"
+ aria-label="Toggle menu"
+ aria-expanded={open}
+>
{open ? <MdClose size="1.2rem" /> : <MdMenu size="1.2rem" />}
-</div>
+</button>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| {/* Nav link items */} | ||||||||||||||||||||||||||||||
|
|
@@ -88,34 +109,33 @@ function Header({notice }) { | |||||||||||||||||||||||||||||
| ${open ? (theme === "dark" ? "bg-dark/90" : "bg-white/90") : ""} | ||||||||||||||||||||||||||||||
| ${open ? "top-14" : "top-[-490px]"}`} | ||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||
| {navLink.map((link, index) => { | ||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||
| <div key={`${link.name}-${index}`}> | ||||||||||||||||||||||||||||||
| {link?.isExternalURL ? ( | ||||||||||||||||||||||||||||||
| <a target="_blank" href={link.link}> | ||||||||||||||||||||||||||||||
| <div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full"> | ||||||||||||||||||||||||||||||
| <span className="githubBtn"> | ||||||||||||||||||||||||||||||
| {link.icon} | ||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| countStar && ( | ||||||||||||||||||||||||||||||
| <div className="flex items-center gap-1"> | ||||||||||||||||||||||||||||||
| {countStar} | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| {navLink.map((link, index) => ( | ||||||||||||||||||||||||||||||
| <div key={`${link.name}-${index}`}> | ||||||||||||||||||||||||||||||
| <Link className="flex items-center gap-1" to={link.link}> | ||||||||||||||||||||||||||||||
| {/* {link.icon} */} | ||||||||||||||||||||||||||||||
| {link.name} | ||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||
| {/* GitHub link for desktop */} | ||||||||||||||||||||||||||||||
| <div className="hidden md:block"> | ||||||||||||||||||||||||||||||
| <a target="_blank" href={githubLink.link}> | ||||||||||||||||||||||||||||||
| <div className="bg-blue-600/50 shadow font-semibold flex gap-1 p-1 px-2 items-center rounded-full"> | ||||||||||||||||||||||||||||||
| <span className="githubBtn"> | ||||||||||||||||||||||||||||||
| {githubLink.icon} | ||||||||||||||||||||||||||||||
| </span> | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| countStar && ( | ||||||||||||||||||||||||||||||
| <div className="flex items-center gap-1"> | ||||||||||||||||||||||||||||||
| {countStar} | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||
| ) : ( | ||||||||||||||||||||||||||||||
| <Link className="flex items-center gap-1" to={link.link}> | ||||||||||||||||||||||||||||||
| {/* {link.icon} */} | ||||||||||||||||||||||||||||||
| {link.name} | ||||||||||||||||||||||||||||||
| </Link> | ||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| })} | ||||||||||||||||||||||||||||||
| <div className="text-lg cursor-pointer" onClick={toggleTheme}> | ||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||
|
Comment on lines
+151
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add Same security issue as the mobile GitHub link (Lines 72-85). Opening links with Apply this diff to fix the security issue: -<a target="_blank" href={githubLink.link}>
+<a target="_blank" rel="noopener noreferrer" href={githubLink.link} aria-label="Star us on GitHub">🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
| {/* Theme toggle for desktop */} | ||||||||||||||||||||||||||||||
| <div className="text-lg cursor-pointer hidden md:block" onClick={toggleTheme}> | ||||||||||||||||||||||||||||||
| <HiMoon className="dark:hidden" /> | ||||||||||||||||||||||||||||||
| <HiSun className="hidden dark:inline" /> | ||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||
|
Comment on lines
+162
to
165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add accessible label to theme toggle button. Same accessibility issue as the mobile theme toggle (Lines 86-89). The theme toggle should use semantic button markup with an Apply this diff to improve accessibility: -<div className="text-lg cursor-pointer hidden md:block" onClick={toggleTheme}>
+<button className="text-lg cursor-pointer bg-transparent border-0 hidden md:block" onClick={toggleTheme} aria-label="Toggle theme">
<HiMoon className="dark:hidden" />
<HiSun className="hidden dark:inline" />
-</div>
+</button>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
rel="noopener noreferrer"to external link.Opening links with
target="_blank"withoutrel="noopener noreferrer"exposes users to potential security risks (tabnabbing attacks) and performance issues. The opened page can accesswindow.openerand potentially redirect the original page to a malicious site.Apply this diff to fix the security issue:
📝 Committable suggestion
🤖 Prompt for AI Agents
Add accessible label to GitHub link.
The GitHub link lacks an
aria-label, which impacts screen reader users who may not understand the purpose of the link from the icon alone.Apply this diff to improve accessibility:
📝 Committable suggestion
🤖 Prompt for AI Agents