Skip to content

Commit 89a21c4

Browse files
committed
update links for a11y
1 parent f9ffc67 commit 89a21c4

2 files changed

Lines changed: 63 additions & 74 deletions

File tree

‎frontend/main/src/layout/AppMenu.tsx‎

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ActiveLink from '@/components/ActiveLink';
22
import TitleLogo from '@/components/global/logos/TitleLogo';
33
import OutsideClick from '@/components/OutsideClick';
44
import dynamic from 'next/dynamic';
5-
import { Dispatch, SetStateAction, useEffect, useRef } from 'react';
5+
import { Dispatch, LegacyRef, SetStateAction, useEffect, useRef } from 'react';
66
import { useSigninCheck } from 'reactfire';
77

88
const AvatarMenu = dynamic<any>(() => import('@/components/user/AvatarMenu'), {
@@ -29,6 +29,31 @@ export default function AppMenu({
2929
}
3030
}, [overlayMenuActive]);
3131

32+
const Link = ({
33+
href,
34+
comparison,
35+
name,
36+
ref,
37+
}: {
38+
href: string;
39+
comparison: string;
40+
name: string;
41+
ref?: LegacyRef<HTMLAnchorElement> | undefined;
42+
}) => {
43+
return (
44+
<ActiveLink
45+
activeClassName="bg-primary-500 rounded-sm"
46+
href={href}
47+
comparison={comparison}
48+
>
49+
<a className="p-2 links-secondary hover:bg-primary-500" ref={focusme}>
50+
<span className="sr-only">{`${name}`}</span>
51+
{name}
52+
</a>
53+
</ActiveLink>
54+
);
55+
};
56+
3257
return (
3358
<div
3459
className={`${
@@ -95,51 +120,16 @@ export default function AppMenu({
95120
className="grid content-start h-full gap-4 p-4 bg-primary-900 dark:bg-primary-900"
96121
aria-label="Sidebar"
97122
>
98-
<ActiveLink
99-
activeClassName="bg-primary-500 rounded-sm"
123+
<Link
100124
href="/courses"
101125
comparison="/course"
102-
>
103-
<a
104-
className="p-2 links-secondary hover:bg-primary-500"
105-
ref={focusme}
106-
>
107-
Courses
108-
</a>
109-
</ActiveLink>
110-
<ActiveLink
111-
activeClassName="bg-primary-500 rounded-sm"
112-
href="/tutorials"
113-
comparison="/tutorial"
114-
>
115-
<a className="p-2 links-secondary hover:bg-primary-500">
116-
Tutorials
117-
</a>
118-
</ActiveLink>
119-
<ActiveLink
120-
activeClassName="bg-primary-500 rounded-sm"
121-
href="/blog"
122-
comparison="/post"
123-
>
124-
<a className="p-2 links-secondary hover:bg-primary-500">Blog</a>
125-
</ActiveLink>
126-
<ActiveLink
127-
activeClassName="bg-primary-500 rounded-sm"
128-
href="/podcasts"
129-
comparison="/podcast"
130-
>
131-
<a className="p-2 links-secondary hover:bg-primary-500">
132-
Podcasts
133-
</a>
134-
</ActiveLink>
135-
<ActiveLink
136-
activeClassName="bg-primary-500 rounded-sm"
137-
href="/schedule"
138-
>
139-
<a className="p-2 links-secondary hover:bg-primary-500">
140-
Schedule
141-
</a>
142-
</ActiveLink>
126+
name="Courses"
127+
ref={focusme}
128+
/>
129+
<Link href="/tutorials" comparison="/tutorial" name="Tutorials" />
130+
<Link href="/blog" comparison="/post" name="Blog" />
131+
<Link href="/podcasts" comparison="/podcast" name="Podcasts" />
132+
<Link href="/schedule" comparison="/schedule" name="Schedule" />
143133
</nav>
144134
<section className="flex self-end p-4 bg-primary-700 dark:bg-primary-700">
145135
<OutsideClick toggle={setUserMenu} value={false}>

‎frontend/main/src/layout/NavLinks.tsx‎

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,39 @@ import Schedule from '@/components/global/icons/nav/Schedule';
77

88
const navLinks = `grid place-items-center links-secondary`;
99

10+
const Link = ({
11+
href,
12+
name,
13+
component,
14+
}: {
15+
href: string;
16+
name: string;
17+
component: JSX.Element;
18+
}) => {
19+
return (
20+
<ActiveLink activeClassName="" href={`${href}`}>
21+
<a className={`${navLinks} nav-links`}>
22+
<span className="sr-only">{`${name}`}</span>
23+
{component}
24+
{`${name}`}
25+
</a>
26+
</ActiveLink>
27+
);
28+
};
29+
1030
const NavLinks = () => {
1131
return (
1232
<nav className="flex mx-auto">
1333
<div className="hidden md:flex md:gap-4 md:place-items-center">
14-
<ActiveLink activeClassName="" href="/courses">
15-
<a className={`${navLinks} nav-links`}>
16-
<Courses />
17-
Courses
18-
</a>
19-
</ActiveLink>
20-
<ActiveLink activeClassName="" href="/tutorials">
21-
<a className={`${navLinks} nav-links`}>
22-
<Tutorials />
23-
Tutorials
24-
</a>
25-
</ActiveLink>
26-
<ActiveLink activeClassName="" href="/podcasts">
27-
<a className={`${navLinks} nav-links`}>
28-
<Podcasts />
29-
Podcasts
30-
</a>
31-
</ActiveLink>
32-
<ActiveLink activeClassName="" href="/schedule">
33-
<a className={`${navLinks} nav-links`}>
34-
<Schedule fill="#BC2261" />
35-
Schedule
36-
</a>
37-
</ActiveLink>
38-
<ActiveLink activeClassName="" href="/blog">
39-
<a className={`${navLinks} nav-links`}>
40-
<Blog />
41-
Blog
42-
</a>
43-
</ActiveLink>
34+
<Link href="/courses" name="Courses" component={<Courses />} />
35+
<Link href="/tutorials" name="Tutorials" component={<Tutorials />} />
36+
<Link href="/podcasts" name="Podcasts" component={<Podcasts />} />
37+
<Link
38+
href="/schedule"
39+
name="Schedule"
40+
component={<Schedule fill="#BC2261" />}
41+
/>
42+
<Link href="/blog" name="Blog" component={<Blog />} />
4443
</div>
4544
<style jsx>{`
4645
.nav-links:hover {

0 commit comments

Comments
 (0)