Skip to content

Commit

Permalink
Refactor footer
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickNiyogitare28 committed Jun 15, 2024
1 parent 009ea53 commit fc0fdbc
Showing 1 changed file with 16 additions and 52 deletions.
68 changes: 16 additions & 52 deletions src/components/footer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { Icon } from '@components/icons';
Expand Down Expand Up @@ -67,65 +67,29 @@ const StyledCredit = styled.div`
}
`;

const Footer = () => {
const [githubInfo, setGitHubInfo] = useState({
stars: null,
forks: null,
});

useEffect(() => {
if (process.env.NODE_ENV !== 'production') {
return;
}
fetch('https://api.github.com/repos/bchiang7/v4')
.then(response => response.json())
.then(json => {
const { stargazers_count, forks_count } = json;
setGitHubInfo({
stars: stargazers_count,
forks: forks_count,
});
})
.catch(e => console.error(e));
}, []);

return (
<StyledFooter>
<StyledSocialLinks>
<ul>
{socialMedia &&
const Footer = () => (
<StyledFooter>
<StyledSocialLinks>
<ul>
{socialMedia &&
socialMedia.map(({ name, url }, i) => (
<li key={i}>
<a href={url} aria-label={name}>
<Icon name={name} />
</a>
</li>
))}
</ul>
</StyledSocialLinks>
</ul>
</StyledSocialLinks>

<p style={{ fontSize: '12px' }}>&copy; Patrick Niyo 2021 - {new Date().getFullYear()}</p>
<StyledCredit tabindex="-1">
<a href="https://github.com/bchiang7/v4">
<div>Adopted From Brittany Chiang</div>

{githubInfo.stars && githubInfo.forks && (
<div className="github-stats">
<span>
<Icon name="Star" />
<span>{githubInfo.stars.toLocaleString()}</span>
</span>
<span>
<Icon name="Fork" />
<span>{githubInfo.forks.toLocaleString()}</span>
</span>
</div>
)}
</a>
</StyledCredit>
</StyledFooter>
);
};
<p style={{ fontSize: '12px' }}>&copy; Patrick Niyo 2021 - {new Date().getFullYear()}</p>
<StyledCredit tabindex="-1">
<a href="https://github.com/bchiang7/v4">
<div>Adopted From Brittany Chiang</div>
</a>
</StyledCredit>
</StyledFooter>
);

Footer.propTypes = {
githubInfo: PropTypes.object,
Expand Down

0 comments on commit fc0fdbc

Please sign in to comment.