diff --git a/source/src/App.tsx b/source/src/App.tsx
index 2cbdc3e..866aac2 100644
--- a/source/src/App.tsx
+++ b/source/src/App.tsx
@@ -91,7 +91,7 @@ const App = () => {
) : (
- } />
+ } />
} />
} />
} />
diff --git a/source/src/pages/PostList/ShowMoreButton.tsx b/source/src/pages/PostList/ShowMoreButton.tsx
new file mode 100644
index 0000000..989e8d4
--- /dev/null
+++ b/source/src/pages/PostList/ShowMoreButton.tsx
@@ -0,0 +1,53 @@
+import styled from "styled-components"
+
+import theming from "../../styles/theming"
+
+const Button = styled.button`
+ /* size */
+
+ padding: 1rem;
+
+ /* styling */
+
+ display: inline-block;
+ border: none;
+ cursor: pointer;
+ border-radius: 0.5rem;
+
+ /* text */
+
+ text-align: center;
+ text-decoration: none;
+ font-size: 1rem;
+
+ /* colors */
+
+ color: ${(props) =>
+ theming.theme(props.theme.currentTheme, {
+ light: "black",
+ dark: "#CFD0D0",
+ })};
+ background-color: ${(props) =>
+ theming.theme(props.theme.currentTheme, {
+ light: theming.light.backgroundColor2,
+ dark: theming.dark.backgroundColor2,
+ })};
+
+ :hover {
+ background-color: ${(props) =>
+ theming.theme(props.theme.currentTheme, {
+ light: theming.light.backgroundColor0,
+ dark: theming.dark.backgroundColor0,
+ })};
+ }
+`
+
+interface Props {
+ action(): void
+}
+
+const ShowMoreButton = (props: Props) => {
+ return
+}
+
+export default ShowMoreButton
diff --git a/source/src/pages/PostList.tsx b/source/src/pages/PostList/index.tsx
similarity index 65%
rename from source/src/pages/PostList.tsx
rename to source/src/pages/PostList/index.tsx
index 9ceb9ef..5d2a51e 100644
--- a/source/src/pages/PostList.tsx
+++ b/source/src/pages/PostList/index.tsx
@@ -7,12 +7,13 @@ import { useEffect, useState } from "react"
import { Helmet } from "react-helmet-async"
import styled from "styled-components"
-import PostCard from "../components/PostCard"
+import PostCard from "../../components/PostCard"
+import ShowMoreButton from "./ShowMoreButton"
-import _map from "../data/map.json"
-import theming from "../styles/theming"
+import _map from "../../data/map.json"
+import theming from "../../styles/theming"
-import { Map } from "../../types/types"
+import { Map } from "../../../types/types"
const map: Map = _map
@@ -28,16 +29,16 @@ const StyledPostList = styled.div`
interface Props {
title: string
- howMany?: number
}
const PostList = (props: Props) => {
- const howMany = props.howMany || 0
+ const [howMany, setHowMany] = useState(5)
+ const [postsLength, setPostsLength] = useState(0)
const [postCards, setPostCards] = useState([])
- useEffect(() => {
+ const loadPostCards = () => {
let postCount = 0
- const _postCards = [] as JSX.Element[]
+ const postCards = [] as JSX.Element[]
for (const date in map.date) {
if (postCount >= howMany) break
@@ -49,14 +50,19 @@ const PostList = (props: Props) => {
postCount++
const url: string = map.date[date][length - i - 1]
- _postCards.push(
+ postCards.push(
)
}
}
- setPostCards(_postCards)
- }, [])
+ setPostCards(postCards)
+ }
+
+ useEffect(() => {
+ loadPostCards()
+ setPostsLength(Object.keys(map.posts).length)
+ }, [howMany])
return (
<>
@@ -70,11 +76,16 @@ const PostList = (props: Props) => {
content={`${process.env.PUBLIC_URL}/icon/icon.svg`}
/>
-
- {howMany > 0 ? `Recent ${howMany} Posts` : "All Posts"}
-
+ Recent Posts
{postCards}
+ {postsLength > howMany && (
+ {
+ setHowMany((prev) => prev + 5)
+ }}
+ />
+ )}
>
)