awesome-uses/src/pages/index.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-01-07 20:23:53 +00:00
import React, { useContext } from 'react';
import { useStaticQuery, graphql } from 'gatsby';
2020-01-07 22:58:15 +00:00
import styled from 'styled-components';
2020-01-07 20:23:53 +00:00
import FilterContext from '../context/FilterContext';
import Layout from '../components/layout';
import Person from '../components/Person';
import Topics from '../components/Topics';
2020-01-22 17:14:25 +00:00
import BackToTop from '../components/BackToTop';
2020-01-20 20:35:48 +00:00
2020-01-07 20:23:53 +00:00
function IndexPage() {
const { currentTag } = useContext(FilterContext);
const { allPerson } = useStaticQuery(graphql`
query People {
allPerson {
nodes {
computer
country
description
emoji
id
name
phone
tags
twitter
url
}
}
}
`);
const people = allPerson.nodes.filter(
person =>
currentTag === 'all' ||
person.tags.includes(currentTag) ||
2020-01-08 11:44:52 +00:00
currentTag === person.country ||
currentTag === person.computer ||
currentTag === person.phone
2020-01-07 20:23:53 +00:00
);
return (
<Layout>
<Topics />
2020-01-07 22:58:15 +00:00
<People>
2020-01-07 20:23:53 +00:00
{people.map(person => (
<Person key={person.name} person={person} currentTag={currentTag} />
))}
2020-01-07 22:58:15 +00:00
</People>
2020-01-22 17:14:25 +00:00
<BackToTop />
2020-01-07 20:23:53 +00:00
</Layout>
);
}
export default IndexPage;
2020-01-07 22:58:15 +00:00
// Component Styles
const People = styled.div`
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
grid-gap: 5rem;
2020-01-08 18:32:10 +00:00
@media all and (max-width: 400px) {
grid-template-columns: 1fr;
}
2020-01-07 22:58:15 +00:00
`;