-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from tk1ng/tk1ng/web-34
chore: create the join or discord and other social links section (WEB-34)
- Loading branch information
Showing
9 changed files
with
223 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)')` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters