Skip to content

Commit 368ccca

Browse files
committed
Refactor social icons for improved accessibility and styling consistency
1 parent ef6c59b commit 368ccca

File tree

1 file changed

+94
-127
lines changed

1 file changed

+94
-127
lines changed

frontend/src/pages/index.tsx

Lines changed: 94 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -4,195 +4,160 @@ import Heading from "@theme/Heading";
44
import Layout from "@theme/Layout";
55
import Image from "@theme/ThemedImage";
66
import clsx from "clsx";
7-
import type { ReactNode } from "react";
87

98
import Admonition from "../components/Admonition";
109
import styles from "./index.module.css";
1110

1211
const socials = [
1312
{
14-
alt: "discord icon",
13+
alt: "Discord icon",
1514
src: "/images/assets/discord-icon.svg",
1615
href: "https://discord.com/invite/samp",
1716
size: 45,
1817
},
1918
{
20-
alt: "facebook icon",
19+
alt: "Facebook icon",
2120
src: "/images/assets/facebook.svg",
2221
href: "https://www.facebook.com/openmultiplayer",
2322
size: 33,
2423
},
2524
{
26-
alt: "instagram icon",
25+
alt: "Instagram icon",
2726
src: "/images/assets/instagram.svg",
2827
href: "https://instagram.com/openmultiplayer/",
2928
size: 33,
3029
},
3130
{
32-
alt: "twitch icon",
31+
alt: "Twitch icon",
3332
src: "/images/assets/twitch.svg",
3433
href: "https://twitch.tv/openmultiplayer",
3534
size: 29,
3635
},
3736
{
38-
alt: "x icon",
37+
alt: "X (formerly Twitter) icon",
3938
src: "/images/assets/x.svg",
4039
href: "https://x.com/openmultiplayer",
4140
size: 29,
42-
background: false,
4341
},
4442
{
45-
alt: "youtube icon",
43+
alt: "YouTube icon",
4644
src: "/images/assets/youtube.svg",
4745
href: "https://youtube.com/openmultiplayer",
4846
size: 35,
4947
},
5048
];
5149

52-
function HomepageHeader() {
50+
const HomepageHeader = () => {
51+
52+
const SocialIcons = () => {
53+
return (
54+
<div className={styles.socialLinks}>
55+
{socials.map((social, index) => (
56+
<a
57+
key={index}
58+
href={social.href}
59+
className={styles.socialLink}
60+
target="_blank"
61+
rel="noopener noreferrer"
62+
aria-label={social.alt}
63+
>
64+
<Image
65+
sources={{
66+
light: social.src,
67+
dark: social.src
68+
}}
69+
alt={social.alt}
70+
width={social.size}
71+
height={social.size}
72+
className={styles.socialIcon}
73+
/>
74+
</a>
75+
))}
76+
</div>
77+
);
78+
};
79+
5380
return (
54-
<header className={clsx(styles.heroBanner)}>
81+
<header className={styles.heroBanner}>
82+
5583
<Admonition
56-
className="container"
84+
className={styles.announcement}
5785
type="tip"
5886
title="A new version of open.mp server and launcher is out now!"
5987
>
6088
Version <b>1.4.0.2779</b> of open.mp server is out with many fixes,
6189
performance boosts, and new features!{" "}
62-
<Link to="https://www.open.mp/docs/changelog">Changelog</Link> |{" "}
63-
<Link to="https://github.com/openmultiplayer/open.mp/releases/latest">
90+
<Link
91+
to="https://www.open.mp/docs/changelog"
92+
className={styles.enhancedLink}
93+
>
94+
Changelog
95+
</Link> |{" "}
96+
<Link
97+
to="https://github.com/openmultiplayer/open.mp/releases/latest"
98+
className={styles.enhancedLink}
99+
>
64100
Download
65101
</Link>
66102
.
67103
<br />
68104
The launcher also got an update!{" "}
69-
<Link to="https://github.com/openmultiplayer/launcher/releases/latest">
105+
<Link
106+
to="https://github.com/openmultiplayer/launcher/releases/latest"
107+
className={styles.enhancedLink}
108+
>
70109
See what's new
71110
</Link>
72111
.
73112
</Admonition>
74-
<div
75-
className="row"
76-
style={{ justifyContent: "space-evenly", alignItems: "center" }}
77-
>
78-
<div
79-
style={{
80-
display: "flex",
81-
flexDirection: "column",
82-
alignItems: "flex-start",
83-
marginRight: 0,
84-
marginLeft: 0,
85-
maxWidth: 600,
86-
}}
87-
>
88-
<Heading as="h1" className="hero__title" style={{ color: "#9083d2" }}>
113+
114+
<div className={styles.heroContent}>
115+
<div className={styles.heroText}>
116+
<Heading as="h1" className={styles.heroTitle}>
89117
Open Multiplayer
90118
</Heading>
91-
<div
92-
style={{
93-
display: "flex",
94-
alignItems: "flex-start",
95-
flexDirection: "column",
96-
}}
97-
>
98-
<p style={{ fontSize: "1.25rem" }}>
99-
A brand new multiplayer mod for Grand Theft Auto: San Andreas that
100-
is <b>fully backwards compatible</b> with{" "}
101-
<b>San Andreas Multiplayer</b>.
102-
</p>
103-
</div>
119+
<p className={styles.heroDescription}>
120+
A brand new multiplayer mod for Grand Theft Auto: San Andreas that
121+
is <b>fully backwards compatible</b> with{" "}
122+
<b>San Andreas Multiplayer</b>.
123+
</p>
104124
</div>
105-
<div
106-
style={{
107-
justifyContent: "space-evenly",
108-
}}
109-
>
110-
<div className={clsx("margin-bottom--sm", styles.buttons)}>
111-
<Link
112-
className={clsx(
113-
"button button--primary button--md",
114-
styles.button
115-
)}
116-
title="Download open.mp launcher"
117-
to="https://github.com/openmultiplayer/launcher/releases/latest"
118-
>
119-
Download open.mp launcher 🎮
120-
</Link>
121-
</div>
122-
<div className={clsx("margin-bottom--sm", styles.buttons)}>
123-
<Link
124-
className={clsx(
125-
"button button--primary button--md",
126-
styles.button
127-
)}
128-
title="open.mp is released!"
129-
to="https://github.com/openmultiplayer/open.mp/releases/latest"
130-
>
131-
Download open.mp (server) 🖥️
132-
</Link>
133-
</div>
134-
<div className={clsx("margin-bottom--sm", styles.buttons)}>
135-
<Link
136-
className={clsx(
137-
"button button--secondary button--md",
138-
styles.button
139-
)}
140-
to="/docs"
141-
>
142-
Documentations 📜
143-
</Link>
144-
</div>
125+
126+
<div className={styles.heroButtons}>
127+
<Link
128+
className={clsx("button button--primary button--lg", styles.button)}
129+
title="Download open.mp launcher"
130+
to="https://github.com/openmultiplayer/launcher/releases/latest"
131+
>
132+
Download Launcher 🎮
133+
</Link>
134+
135+
<Link
136+
className={clsx("button button--primary button--lg", styles.button)}
137+
title="open.mp is released!"
138+
to="https://github.com/openmultiplayer/open.mp/releases/latest"
139+
>
140+
Download Server 🖥️
141+
</Link>
142+
143+
<Link
144+
className={clsx("button button--secondary button--lg", styles.button)}
145+
to="/docs"
146+
>
147+
Documentation 📜
148+
</Link>
145149
</div>
146150
</div>
147-
<div
148-
className="row margin-horiz--none margin-top--xl"
149-
style={{
150-
justifyContent: "center",
151-
}}
152-
>
153-
{socials.map((social, index) => {
154-
const iconSize = `${social.size}px`;
155-
const style: React.CSSProperties = {
156-
display: "flex",
157-
justifyContent: "center",
158-
...(social.background && {
159-
backgroundColor: "#9083d2",
160-
width: `${social.size + 17}px`,
161-
height: `${social.size + 17}px`,
162-
borderRadius: 5,
163-
}),
164-
};
165-
166-
return (
167-
<div
168-
style={{
169-
width: 70,
170-
height: 70,
171-
alignItems: "center",
172-
justifyContent: "center",
173-
display: "flex",
174-
}}
175-
>
176-
<a key={index} href={social.href} style={style} target="__blank">
177-
<Image
178-
sources={{ light: social.src, dark: social.src }}
179-
alt={social.alt}
180-
width={iconSize}
181-
height={iconSize}
182-
/>
183-
</a>
184-
</div>
185-
);
186-
})}
187-
</div>
151+
152+
<SocialIcons />
188153
</header>
189154
);
190-
}
155+
};
191156

192-
export default function Home(): ReactNode {
157+
const Home = (): JSX.Element => {
193158
return (
194159
<Layout
195-
title={`Open Multiplayer`}
160+
title="Open Multiplayer"
196161
description="A multiplayer mod for Grand Theft Auto: San Andreas that is fully backwards compatible with San Andreas Multiplayer"
197162
>
198163
<HomepageHeader />
@@ -201,4 +166,6 @@ export default function Home(): ReactNode {
201166
</main>
202167
</Layout>
203168
);
204-
}
169+
};
170+
171+
export default Home;

0 commit comments

Comments
 (0)