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

Feature: Add programming languages to 'Projects' #40

Merged
merged 4 commits into from
Oct 17, 2020
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
6 changes: 6 additions & 0 deletions src/components/common/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export const Card = styled.div`
background: ${({ theme }) => (theme === 'light' ? '#fff' : '#181717')};
height: 100%;
`;

export const TitleWrap = styled.div`
display: flex;
flex-direction: row;
justify-content: space-between;
`;
43 changes: 31 additions & 12 deletions src/components/landing/Projects/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useContext } from 'react';
import { useStaticQuery, graphql } from 'gatsby';
import { ThemeContext } from 'providers/ThemeProvider';
import { Container, Card } from 'components/common';
import { Container, Card, TitleWrap } from 'components/common';
import Star from 'components/common/Icons/Star';
import Fork from 'components/common/Icons/Fork';
import { Wrapper, Grid, Item, Content, Stats } from './styles';
import { Wrapper, Grid, Item, Content, Stats, Languages } from './styles';

export const Projects = () => {
const { theme } = useContext(ThemeContext);
Expand All @@ -30,6 +30,12 @@ export const Projects = () => {
totalCount
}
forkCount
languages(first: 3) {
nodes {
id,
name
}
}
}
}
}
Expand All @@ -49,16 +55,29 @@ export const Projects = () => {
<h4>{node.name}</h4>
<p>{node.description}</p>
</Content>
<Stats theme={theme}>
<div>
<Star color={theme === 'light' ? '#000' : '#fff'} />
<span>{node.stargazers.totalCount}</span>
</div>
<div>
<Fork color={theme === 'light' ? '#000' : '#fff'} />
<span>{node.forkCount}</span>
</div>
</Stats>
<TitleWrap>
<Stats theme={theme}>
<div>
<Star color={theme === "light" ? "#000" : "#fff"} />
<span>{node.stargazers.totalCount}</span>
</div>
<div>
<Fork color={theme === "light" ? "#000" : "#fff"} />
<span>{node.forkCount}</span>
</div>
</Stats>
<Stats theme={theme}>
<Languages>
{
node.languages.nodes.map(({ id, name }) => (
<span key={id}>
{name}
</span>
))
}
</Languages>
</Stats>
</TitleWrap>
</Card>
</Item>
))}
Expand Down
6 changes: 6 additions & 0 deletions src/components/landing/Projects/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const Item = styled.div`

export const Content = styled.div`
padding: 1rem 0;
min-height: 160px;
`;

export const Stats = styled.div`
Expand All @@ -63,3 +64,8 @@ export const Stats = styled.div`
}
}
`;

export const Languages = styled.div`
opacity: 0.5;
font-size: 14px;
`;