Skip to content

Commit 25d82a0

Browse files
authored
Merge pull request #358 from 1chooo/refactor/improve-config-structure
refactor(web): improve config structure
2 parents a18af28 + e5a6d93 commit 25d82a0

File tree

8 files changed

+48
-23
lines changed

8 files changed

+48
-23
lines changed

apps/web/src/components/about/github-stats.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const yellowTheme: ThemeInput = {
1717
dark: ['hsl(0, 0%, 22%)', '#FFDA6B'],
1818
};
1919

20-
const { socialMedia } = config;
20+
const { about } = config;
21+
22+
const { socialMedia } = about;
2123
const { githubUsername } = socialMedia;
2224

2325
const subHeaderText = '$ ls -al GitHub Stats';

apps/web/src/components/side-bar/avatar-box.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
firstName,
1313
lastName,
1414
middleName,
15+
preferredName
1516
} = about;
1617

1718
type AvatarBoxProps = {
@@ -26,7 +27,7 @@ const AvatarBox: React.FC<AvatarBoxProps> = ({ avatar }) => {
2627
<Image
2728
id="profile-img"
2829
src={avatar}
29-
alt={`${firstName} (${middleName}) ${lastName}`}
30+
alt={`${firstName} (${preferredName}) ${lastName}`}
3031
width={imageSize.width}
3132
height={imageSize.height}
3233
loading="lazy"

apps/web/src/components/side-bar/info-content.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@ const { about } = config;
66
const {
77
firstName,
88
lastName,
9-
middleName,
9+
middleName, // TODO: Research how to render this in the UI
10+
preferredName
1011
} = about;
1112

1213
const InfoContent: React.FC = () => (
1314
<div className="info-content">
1415
<h1
1516
className="name"
16-
title={`${firstName} (${middleName}) ${lastName}`}
17-
>{firstName} ({middleName}) {lastName}
17+
title={`${firstName} (${preferredName}) ${lastName}`}
18+
>{firstName} ({preferredName}) {lastName}
1819
</h1>
1920
<p className="title">
2021
<strong>{status}</strong>

apps/web/src/components/side-bar/social-list.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { MdAttachment, MdOutlineSignpost } from "react-icons/md";
66

77
import config from "@/config";
88

9-
const { socialMedia } = config;
9+
const { about } = config;
10+
11+
const { socialMedia } = about;
1012
const { githubUsername, twitterUsername, linkedinUsername, mediumUsername } = socialMedia;
1113

1214
const socialLinks = [

apps/web/src/config/index.ts

+9-8
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,20 @@ const config: Config = {
2020
{ path: '/blog', label: 'Blog' },
2121
{ path: '/contact', label: 'Contact' }
2222
],
23-
socialMedia: {
24-
"githubUsername": "1chooo",
25-
"mediumUsername": "1chooo",
26-
"twitterUsername": "1chooo___",
27-
"linkedinUsername": "1chooo"
28-
},
2923
about: {
3024
"subHeader": "$ ls -al Hugo 👨🏻‍💻",
3125
"firstName": 'Chun-Ho',
3226
"lastName": 'Lin',
33-
"middleName": 'Hugo' || '',
34-
"preferredName": 'Hugo' || '',
27+
"middleName": "",
28+
"preferredName": "Hugo",
29+
"additionalName": "Hugo",
3530
"pronouns": 'He/Him',
31+
"socialMedia": {
32+
"githubUsername": "1chooo",
33+
"mediumUsername": "1chooo",
34+
"twitterUsername": "1chooo___",
35+
"linkedinUsername": "1chooo"
36+
},
3637
"introductions": [
3738
// "#### $ ls -al Hugo 👨🏻‍💻 (He/Him)",
3839
"I obtained my Bachelor's degree from [National Central University 🐿️](https://www.ncu.edu.tw/), driven by a *sincere passion* for **Software Engineering 💻.**",

apps/web/src/tests/social-list.test.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import SocialList from '../components/side-bar/social-list';
4-
import { abouts } from '../config/about';
4+
import config from '@/config';
5+
6+
const { about } = config;
7+
8+
59

610
describe('SocialList', () => {
711
it('should render the correct number of social links', () => {
@@ -12,7 +16,7 @@ describe('SocialList', () => {
1216

1317
it('should render the correct social links', () => {
1418
render(<SocialList />);
15-
const { socialMedia } = abouts;
19+
const { socialMedia } = about;
1620
const { githubUsername, twitterUsername, linkedinUsername, mediumUsername } = socialMedia;
1721

1822
expect(screen.getByRole('link', { name: 'GitHub' })).toHaveAttribute('href', `https://github.com/${githubUsername}`);

apps/web/src/types/about.d.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,38 @@ export type TechStack = {
1212
alt: string;
1313
}
1414

15+
export type SocialMedia = {
16+
githubUsername: string;
17+
mediumUsername: string;
18+
twitterUsername: string;
19+
linkedinUsername: string;
20+
}
21+
1522
/**
1623
* Type definition for the About component.
1724
*
18-
* @param {Readonly<Options>} options
19-
* Props.
20-
* @returns {JSX.Element}
21-
* React element.
25+
* @example
26+
* about: {
27+
* "subHeader": "$ ls -al Hugo 👨🏻‍💻",
28+
* "firstName": 'Chun-Ho',
29+
* "lastName": 'Lin',
30+
* "middleName": "",
31+
* "preferredName": "Hugo",
32+
* "additionalName": "Hugo",
33+
* "pronouns": 'He/Him',
34+
* ...
35+
* }
36+
* @returns {About} The About component.
2237
*/
2338
export type About = {
2439
subHeader: string;
2540
firstName: string;
2641
lastName: string;
2742
middleName: string;
2843
preferredName: string;
44+
additionalName: string;
2945
pronouns: string;
46+
socialMedia: SocialMedia;
3047
introductions: string[];
3148
lifestyles: LifeStyle[];
3249
programmingLanguage: TechStack[];

apps/web/src/types/config.d.ts

-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import type { About } from "@/types/about";
2-
import type { SocialMedia } from "@/types/social-media";
32
import type { Resume } from "@/types/resume";
43
import type { NavItem } from "@/types/nav-bar";
54

65
/**
76
* Type definition for the Web app configuration.
87
*
9-
* @param {SocialMedia} socialMedia
108
* @param {About} about
119
* @param {Resume} resume
1210
*/
@@ -19,7 +17,6 @@ export type Config = {
1917
keywords: string[];
2018
status: string;
2119
navItems: NavItem[];
22-
socialMedia: SocialMedia;
2320
about: About;
2421
resume: Resume;
2522
}

0 commit comments

Comments
 (0)