Skip to content

Commit

Permalink
Merge pull request #40 from benji011/add-programming-languages-graph-ql
Browse files Browse the repository at this point in the history
Feature: Add programming languages to 'Projects'
  • Loading branch information
smakosh authored Oct 17, 2020
2 parents a52b7e4 + 97097a8 commit f40c38d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
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;
`;

1 comment on commit f40c38d

@vercel
Copy link

@vercel vercel bot commented on f40c38d Oct 17, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.