mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-08 16:06:13 +02:00
Merge pull request #361 from the-programmers-hangout/ui-tweak-page-navigation
ui: tweak page navigation
This commit is contained in:
@@ -13,33 +13,25 @@ interface IPageContentProps {
|
|||||||
|
|
||||||
export const PageNavigation: FC<IPageContentProps> = ({ previous, next }) => {
|
export const PageNavigation: FC<IPageContentProps> = ({ previous, next }) => {
|
||||||
return (
|
return (
|
||||||
<SC.Content>
|
<SC.PageNavigationWrapper>
|
||||||
{previous ? (
|
{previous && (
|
||||||
<SC.PageContent>
|
<SC.PreviousPage>
|
||||||
<SC.Text>Previous</SC.Text>
|
<SC.Text>Previous</SC.Text>
|
||||||
<SC.NavLink to={`/resources/${previous.relativePath}`}>
|
<SC.NavLink to={`/resources/${previous.relativePath}`}>
|
||||||
<SC.PreviousArrow />
|
<SC.PreviousArrow />
|
||||||
<SC.PageTitle>
|
<SC.PageTitle>{previous.title}</SC.PageTitle>
|
||||||
{previous.title}
|
|
||||||
</SC.PageTitle>
|
|
||||||
</SC.NavLink>
|
</SC.NavLink>
|
||||||
</SC.PageContent>
|
</SC.PreviousPage>
|
||||||
) : (
|
|
||||||
<div> </div>
|
|
||||||
)}
|
)}
|
||||||
{next ? (
|
{next && (
|
||||||
<SC.PageContent>
|
<SC.NextPage>
|
||||||
<SC.Text>Next</SC.Text>
|
<SC.Text>Next</SC.Text>
|
||||||
<SC.NavLink to={`/resources/${next.relativePath}`}>
|
<SC.NavLink to={`/resources/${next.relativePath}`}>
|
||||||
<SC.PageTitle>
|
<SC.PageTitle>{next.title}</SC.PageTitle>
|
||||||
{next.title}
|
|
||||||
</SC.PageTitle>
|
|
||||||
<SC.NextArrow />
|
<SC.NextArrow />
|
||||||
</SC.NavLink>
|
</SC.NavLink>
|
||||||
</SC.PageContent>
|
</SC.NextPage>
|
||||||
) : (
|
|
||||||
<div> </div>
|
|
||||||
)}
|
)}
|
||||||
</SC.Content>
|
</SC.PageNavigationWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { Link } from "gatsby"
|
|||||||
import fontFamily from "../../design/typography"
|
import fontFamily from "../../design/typography"
|
||||||
import ArrowRight from "../../icons/arrow-right.svg"
|
import ArrowRight from "../../icons/arrow-right.svg"
|
||||||
|
|
||||||
export const Content = styled.div`
|
export const PageNavigationWrapper = styled.div`
|
||||||
|
margin-top: 64px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Text = styled.p`
|
export const Text = styled.p`
|
||||||
@@ -20,11 +20,6 @@ export const Text = styled.p`
|
|||||||
export const NavLink = styled(Link)`
|
export const NavLink = styled(Link)`
|
||||||
display: flex;
|
display: flex;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-align: right;
|
|
||||||
|
|
||||||
& > svg ~ p {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus {
|
&:focus {
|
||||||
@@ -37,14 +32,18 @@ export const PageContent = styled.div`
|
|||||||
width: 200px;
|
width: 200px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
`
|
||||||
|
|
||||||
&:last-of-type {
|
export const PreviousPage = styled(PageContent)`
|
||||||
align-items: flex-end;
|
margin-right: auto;
|
||||||
}
|
`
|
||||||
|
|
||||||
& > div {
|
export const NextPage = styled(PageContent)`
|
||||||
display: flex;
|
margin-left: auto;
|
||||||
justify-content: start;
|
|
||||||
|
${Text},
|
||||||
|
${NavLink} {
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -58,6 +57,7 @@ export const PageTitle = styled(Text)`
|
|||||||
|
|
||||||
export const NextArrow = styled(ArrowRight)`
|
export const NextArrow = styled(ArrowRight)`
|
||||||
width: 8px;
|
width: 8px;
|
||||||
|
|
||||||
path {
|
path {
|
||||||
fill: #ff74a2;
|
fill: #ff74a2;
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ export const NextArrow = styled(ArrowRight)`
|
|||||||
export const PreviousArrow = styled(ArrowRight)`
|
export const PreviousArrow = styled(ArrowRight)`
|
||||||
width: 8px;
|
width: 8px;
|
||||||
transform: rotate(180deg);
|
transform: rotate(180deg);
|
||||||
|
|
||||||
path {
|
path {
|
||||||
fill: #feac71;
|
fill: #feac71;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,18 @@ const ResourcePage: FC<any> = ({ data }) => {
|
|||||||
toc.length
|
toc.length
|
||||||
)
|
)
|
||||||
|
|
||||||
const pages = sortWith([
|
const pages = sortWith(
|
||||||
descend((f: any) => {
|
[
|
||||||
if (f.node.relativePath.includes("intro")) {
|
descend((f: any) => {
|
||||||
return 1;
|
if (f.node.relativePath.includes("intro")) {
|
||||||
}
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1
|
||||||
})
|
}),
|
||||||
], data.allFile.edges)
|
],
|
||||||
|
data.allFile.edges
|
||||||
|
)
|
||||||
const currentIndex = pages.findIndex(
|
const currentIndex = pages.findIndex(
|
||||||
(x: any) => x.node.relativePath === relativePath
|
(x: any) => x.node.relativePath === relativePath
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user