Skip to content
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

chore: create the join or discord and other social links section (WEB-34) #83

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"dependencies": {
"next": "14.1.1",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"react-icons": "^5.1.0"
},
"devDependencies": {
"@babel/preset-env": "^7.24.0",
Expand Down
25 changes: 25 additions & 0 deletions src/app/components/socialSection/socialLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { IconContext } from 'react-icons';
import { SocialLinkData } from './socialSection';
import styles from './socialSection.module.css';

interface SocialLinksProps {
links: SocialLinkData[];
}

const SocialLinks = ({ links }: SocialLinksProps) => {
return (
<IconContext.Provider value={{ color: 'black', size: '7rem' }}>
<ul className={styles.socialLinks}>
{links.map((link) => (
<li key={link.id}>
<a href={link.link} target='_blank'>
{link.icon}
</a>
</li>
))}
</ul>
</IconContext.Provider>
);
};

export default SocialLinks;
35 changes: 35 additions & 0 deletions src/app/components/socialSection/socialSection.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.socialSection {
display: flex;
gap: 4rem;
align-items: center;
padding: 60px 60px 60px 0;
}

.socialSection p {
font-family: 'Raleway', sans-serif;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this could be defined using CSS variables, along with other global styles like specific theme colors, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great idea. Lets create another ticket for adding global css variables to tackle consistency across the web app.

font-size: 55px;
}

.imageContainer {
display: flex;
align-items: center;
justify-content: start;
width: 50%;
height: 500px;
background-color: #0f1034;
border-radius: 0 30px 30px 0;
}

.imageContainer img {
border-radius: 0 15px 15px 0;
width: 93%;
height: 90%;
}

.socialLinks {
display: flex;
gap: 2.5rem;
justify-content: space-evenly;
list-style: none;
padding: 0;
}
45 changes: 45 additions & 0 deletions src/app/components/socialSection/socialSection.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { render, screen } from '@testing-library/react';
import SocialSection from './socialSection';

describe('SocialSection', () => {
const mockData = [
{
id: 'github',
imgSrc: '/assets/githubIcon.png',
alt: 'Github social icon',
link: 'https://github.com',
},
{
id: 'discord',
imgSrc: '/assets/discordIcon.png',
alt: 'Discord social icon',
link: 'https://discord.com',
},
{
id: 'meetup',
imgSrc: '/assets/meetupIcon.png',
alt: 'Meetup social icon',
link: '/',
},
{
id: 'linkedin',
imgSrc: '/assets/linkedinIcon.png',
alt: 'LinkedIn social icon',
link: '/',
},
];

test('renders SocialSection component', () => {
render(<SocialSection socialData={mockData} />);

const socialSection = screen.getByTestId('socialSection');
expect(socialSection).toBeInTheDocument();
});

test('renders all social icons', () => {
render(<SocialSection socialData={mockData} />);

const linkList = screen.getAllByRole('listitem');
expect(linkList).toHaveLength(4);
});
});
40 changes: 40 additions & 0 deletions src/app/components/socialSection/socialSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Image from 'next/image';
import SocialLinks from './socialLinks';
import styles from './socialSection.module.css';

export interface SocialLinkData {
id: string;
icon: React.ReactNode;
imgSrc: string;
alt: string;
link: string;
}

interface SocialSectionProps {
socialData: SocialLinkData[];
}

export default function SocialSection({ socialData }: SocialSectionProps) {
return (
<div className={styles.socialSection} data-testid='socialSection'>
<div className={styles.imageContainer}>
<Image
src='/assets/joinOurDiscord.png'
alt=''
width={500}
height={350}
/>
</div>
<div>
<p>
Join our Discord and <br /> other social links!
</p>
<p>
This is YOUR community,
<br /> be a part of it!
</p>
<SocialLinks links={socialData} />
</div>
</div>
);
}
7 changes: 7 additions & 0 deletions src/app/hooks/useMediaQuery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This is a slimmer version of the `useMediaQuery` hook from [useHooks-ts](https://usehooks-ts.com/react-hook/use-media-query)

This hook uses the [`matchMedia()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) method of the `Window` object to check for matching conditions against a media query passed into the hook.

`useMediaQuery` takes a media query argument passed as a string:

`useMediaQuery('(max-width: 750px)')`
18 changes: 18 additions & 0 deletions src/app/hooks/useMediaQuery/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useState, useEffect } from 'react';

const useMediaQuery = (query: string): boolean => {
const [isMatch, setIsMatch] = useState<boolean>(false);

useEffect(() => {
const mediaQueryList = window.matchMedia(query);
setIsMatch(mediaQueryList.matches);

mediaQueryList.onchange = (event) => {
setIsMatch(event.matches);
};
}, [query]);

return isMatch;
};

export default useMediaQuery;
41 changes: 41 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
'use client';
import { FaDiscord, FaGithub, FaLinkedin, FaMeetup } from 'react-icons/fa';
import useMediaQuery from './hooks/useMediaQuery';
import CardsSection from './components/cardsSection/cardsSection';
import BannerSection from './components/bannerSection/bannerSection';
import HeroSection from './components/heroSection/heroSection';
import Navbar from './components/navbar/navbar';
import SocialSection from './components/socialSection/socialSection';
import styles from './page.module.css';
import GroupPhotoSection from './components/groupPhotoSection/groupPhotoSection';
import BentoSection from './components/bentoSection/bentoSection';
Expand Down Expand Up @@ -35,14 +39,51 @@ export default function Home() {
meetupUrl: 'https://www.meetup.com/dallas-software-developers-meetup/',
communityUrl: '/',
cohortUrl: '/',
githubUrl: 'https://github.com/dallassoftwaredevelopers',
discordUrl: '/',
linkedinUrl: 'https://www.linkedin.com/company/dallas-software-developers',
};

const socialData = [
{
id: 'github',
icon: <FaGithub />,
imgSrc: '/assets/githubIcon.png',
alt: 'Github social icon',
link: labelMap.githubUrl,
},
{
id: 'discord',
icon: <FaDiscord />,
imgSrc: '/assets/discordIcon.png',
alt: 'Discord social icon',
link: labelMap.discordUrl,
},
{
id: 'meetup',
icon: <FaMeetup />,
imgSrc: '/assets/meetupIcon.png',
alt: 'Meetup social icon',
link: labelMap.meetupUrl,
},
{
id: 'linkedin',
icon: <FaLinkedin />,
imgSrc: '/assets/linkedinIcon.png',
alt: 'LinkedIn social icon',
link: labelMap.linkedinUrl,
},
];

const isDesktop = useMediaQuery('(min-width: 1024px)');

return (
<main className={styles.main}>
<Navbar label={labelMap} />
<HeroSection label={labelMap.lblHero} />
<BannerSection label={labelMap} />
<CardsSection label={labelMap} />
{isDesktop && <SocialSection socialData={socialData} />}
<GroupPhotoSection label='' />
<BentoSection />
</main>
Expand Down
Loading