Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Implement project header component
- Loading branch information
1 parent
d7b0d71
commit 7f0ff3f
Showing
4 changed files
with
103 additions
and
3 deletions.
There are no files selected for viewing
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,10 @@ | ||
| import styled from "styled-components"; | ||
| import { Box } from "rebass"; | ||
|
|
||
| const AspectRatioBox = styled(Box)` | ||
| padding-bottom: ${props => (1 / props.ratio) * 100}%; | ||
| background: #e3e4e5; | ||
| height: 0; | ||
| `; | ||
|
|
||
| export default AspectRatioBox; |
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,78 @@ | ||
| import React from "react"; | ||
| import { Box, Flex, Heading, Text } from "rebass"; | ||
| import styled, { css } from "styled-components"; | ||
|
|
||
| import AspectRatioBox from "./aspect-ratio-box"; | ||
|
|
||
| const Title = styled(Heading)` | ||
| color: ${props => props.theme.colors.black}; | ||
| font-family: ${props => props.theme.fonts.sans}; | ||
| font-weight: 600; | ||
| font-size: ${props => props.theme.fontSizes[5]}px; | ||
| margin: 0; | ||
| @media (min-width: ${props => props.theme.breakpoints[1]}) { | ||
| font-size: ${props => props.theme.fontSizes[6]}px; | ||
| } | ||
| `; | ||
|
|
||
| const Description = styled(Text)` | ||
| color: ${props => props.theme.colors.black}; | ||
| font-family: ${props => props.theme.fonts.sans}; | ||
| font-weight: 600; | ||
| font-size: ${props => props.theme.fontSizes[3]}px; | ||
| line-height: 1.35em; | ||
| margin: 0; | ||
| @media (min-width: ${props => props.theme.breakpoints[1]}) { | ||
| font-size: ${props => props.theme.fontSizes[4]}px; | ||
| } | ||
| `; | ||
|
|
||
| const Category = styled(Text)` | ||
| color: ${props => props.theme.colors.grey}; | ||
| font-family: ${props => props.theme.fonts.sans}; | ||
| font-size: ${props => props.theme.fontSizes[3]}px; | ||
| font-weight: normal; | ||
| margin: 0; | ||
| `; | ||
|
|
||
| const HeroWrap = styled(Box)` | ||
| ${props => | ||
| props.truncated && | ||
| css` | ||
| max-height: 200px; | ||
| overflow: hidden; | ||
| `} | ||
| `; | ||
|
|
||
| const Hero = ({ truncated }) => ( | ||
| <HeroWrap mt={[4, 5]} truncated={truncated}> | ||
| <AspectRatioBox ratio={8 / 5} /> | ||
| </HeroWrap> | ||
| ); | ||
|
|
||
| const ProjectHeader = ({ project, truncated }) => ( | ||
| <Box> | ||
| <Flex flexWrap="wrap"> | ||
| <Box width={[1, 1 / 2]}> | ||
| <Title as="h1">{project.title}</Title> | ||
| <Box mt={3}> | ||
| <Category as="h3">Random Works</Category> | ||
| </Box> | ||
| </Box> | ||
| <Box width={[1, 1 / 2]}> | ||
| <Box mt={[3, 0]}> | ||
| <Description as="h2"> | ||
| Lorem ipsum dolor amet scenester distillery tbh messenger bag DIY | ||
| pok pok food truck. Ramps iPhone gastropub actually freegan | ||
| cardigan. | ||
| </Description> | ||
| </Box> | ||
| </Box> | ||
| </Flex> | ||
| <Hero truncated={truncated} /> | ||
| </Box> | ||
| ); | ||
|
|
||
| export default ProjectHeader; |
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 |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| import React from "react"; | ||
|
|
||
| import Layout from "../components/layout"; | ||
| import ProjectHeader from "../components/project-header"; | ||
|
|
||
| const Project = ({ pageContext: project }) => <Layout>{project.title}</Layout>; | ||
| const Project = ({ pageContext: project }) => ( | ||
| <Layout> | ||
| <ProjectHeader project={project} /> | ||
| <ProjectHeader project={project.next} truncated /> | ||
| </Layout> | ||
| ); | ||
|
|
||
| export default Project; |