-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next and previous posts component (#53)
* feat: add previous and next nodes on gatsby-node * feat: add links on thumb and name of sidebar * feat: previous and next navigation component - import dependencies - add propTypes - add html structure - add links - add conditionals * style: add all desktop styles of component * feat: add component on blog-post file * refactor: update all proptypes * style: fix all mobile styles of component * chore: update version to 1.2.0 * refactor: fix some alpha orders and break lines * feat: add one paragraph at about page
- Loading branch information
Showing
8 changed files
with
248 additions
and
9 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
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
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,49 @@ | ||
import React from 'react'; | ||
|
||
import * as S from './styles'; | ||
import Icons from '../icons'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function PreviousNext({ next, previous }) { | ||
return ( | ||
<S.WrapPreviousNext className={(!next && '-singlePrevious') || (!previous && '-singleNext')}> | ||
{next && ( | ||
<S.LinksNavigation className="-previous" to={next.fields.slug}> | ||
<Icons name="arrow-single" /> | ||
<S.LinkInfos> | ||
<S.LinksLabel>Próximo post:</S.LinksLabel> | ||
<S.LinksTitle>{next.frontmatter.title}</S.LinksTitle> | ||
</S.LinkInfos> | ||
</S.LinksNavigation> | ||
)} | ||
{previous && ( | ||
<S.LinksNavigation className="-next" to={previous.fields.slug}> | ||
<S.LinkInfos> | ||
<S.LinksLabel>Post anterior:</S.LinksLabel> | ||
<S.LinksTitle>{previous.frontmatter.title}</S.LinksTitle> | ||
</S.LinkInfos> | ||
<Icons name="arrow-single" /> | ||
</S.LinksNavigation> | ||
)} | ||
</S.WrapPreviousNext> | ||
); | ||
} | ||
|
||
PreviousNext.propTypes = { | ||
next: PropTypes.shape({ | ||
frontmatter: PropTypes.shape({ | ||
title: PropTypes.string.isRequired, | ||
}), | ||
fields: PropTypes.shape({ | ||
slug: PropTypes.string.isRequired, | ||
}), | ||
}), | ||
previous: PropTypes.shape({ | ||
frontmatter: PropTypes.shape({ | ||
title: PropTypes.string.isRequired, | ||
}), | ||
fields: PropTypes.shape({ | ||
slug: PropTypes.string.isRequired, | ||
}), | ||
}), | ||
}; |
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,146 @@ | ||
import styled from 'styled-components'; | ||
import media from 'styled-media-query'; | ||
import { Link } from 'gatsby'; | ||
import { themes } from '../../styles/themes'; | ||
|
||
export const WrapPreviousNext = styled.section` | ||
border-bottom: 1px solid ${themes.palette.general.borders}; | ||
border-top: 1px solid ${themes.palette.general.borders}; | ||
display: flex; | ||
justify-content: space-between; | ||
margin: 30px 0; | ||
&.-singleNext { | ||
justify-content: flex-start; | ||
} | ||
&.-singlePrevious { | ||
justify-content: flex-end; | ||
} | ||
`; | ||
|
||
export const LinksNavigation = styled(Link)` | ||
align-items: center; | ||
display: inline-flex; | ||
width: 50%; | ||
section.-singlePrevious &, | ||
section.-singleNext & { | ||
${media.lessThan('small')` | ||
width: 100%; | ||
`} | ||
} | ||
${media.lessThan('large')` | ||
padding: 20px 0; | ||
`} | ||
${media.greaterThan('medium')` | ||
padding: 20px; | ||
`} | ||
> svg { | ||
${media.lessThan('medium')` | ||
height: 24px; | ||
min-height: 20px; | ||
min-width: 20px; | ||
width: 24px; | ||
`} | ||
${media.greaterThan('medium')` | ||
height: 42px; | ||
width: 42px; | ||
`} | ||
} | ||
&.-previous { | ||
border-right: 1px solid ${themes.palette.general.borders}; | ||
${media.lessThan('medium')` | ||
padding-right: 10px; | ||
`} | ||
${media.greaterThan('medium')` | ||
padding-left: 20px; | ||
transition: padding-left 0.3s; | ||
`} | ||
section.-singlePrevious &, | ||
section.-singleNext & { | ||
${media.lessThan('medium')` | ||
border-right: 0; | ||
`} | ||
} | ||
> svg { | ||
margin-right: 10px; | ||
transform: rotate(180deg); | ||
} | ||
} | ||
&.-next { | ||
justify-content: flex-end; | ||
text-align: right; | ||
${media.lessThan('medium')` | ||
padding-left: 10px; | ||
`} | ||
${media.greaterThan('medium')` | ||
padding-right: 20px; | ||
transition: padding-right 0.3s; | ||
`} | ||
section.-singlePrevious & { | ||
${media.greaterThan('small')` | ||
border-left: 1px solid ${themes.palette.general.borders}; | ||
`} | ||
} | ||
> svg { | ||
margin-left: 10px; | ||
} | ||
} | ||
&:hover { | ||
&.-previous { | ||
padding-left: 0; | ||
transition: padding-left 0.3s; | ||
} | ||
&.-next { | ||
padding-right: 0; | ||
transition: padding-right 0.3s; | ||
} | ||
strong { | ||
text-decoration: underline; | ||
} | ||
} | ||
`; | ||
|
||
export const LinkInfos = styled.span``; | ||
|
||
export const LinksLabel = styled.span` | ||
color: ${themes.palette.general.color}; | ||
display: block; | ||
font-size: 0.9rem; | ||
margin-bottom: 5px; | ||
`; | ||
|
||
export const LinksTitle = styled.strong` | ||
color: ${themes.palette.general.links}; | ||
display: block; | ||
font-family: ${themes.fonts.titles}; | ||
max-width: 450px; | ||
${media.lessThan('medium')` | ||
font-size: 1.25rem; | ||
line-height: 1; | ||
`} | ||
${media.greaterThan('medium')` | ||
font-size: 1.5rem; | ||
line-height: 1.1; | ||
`} | ||
`; |
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
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