diff --git a/src/component/emotion/component.js b/src/component/emotion/component.js index 55b4502..c84fe80 100644 --- a/src/component/emotion/component.js +++ b/src/component/emotion/component.js @@ -304,7 +304,17 @@ export const Button = styled.div` font-style: normal; font-weight: 600; cursor: pointer; + margin-right: 10px; svg { margin-right: 10px; } `; + +export const Inner = styled.div` + width: 100%; + display: flex; + flex-wrap: wrap; + gap: 40px; + justify-content: space-between; + margin-top: 300px; +`; diff --git a/src/component/project/board/agricultboard/component.js b/src/component/project/board/agricultboard/component.js index d4aa7bc..4eb5a04 100644 --- a/src/component/project/board/agricultboard/component.js +++ b/src/component/project/board/agricultboard/component.js @@ -37,3 +37,16 @@ export const SignButton = styled.div` align-items: center; margin-top: 30px; `; +export const OuterContainer = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + flex-direction: row; +`; + +export const FootContainer = styled.div` + display: flex; + justify-content: center; + align-items: center; + margin: 150px; +`; diff --git a/src/component/project/board/agricultboard/index.js b/src/component/project/board/agricultboard/index.js index 1c88b06..69a80ac 100644 --- a/src/component/project/board/agricultboard/index.js +++ b/src/component/project/board/agricultboard/index.js @@ -1,37 +1,45 @@ -import React from "react"; -import styled from "@emotion/styled"; -import { IndexContainer, InnerContainer, SignButton } from "./component"; +import React, { useState } from "react"; +import { + IndexContainer, + InnerContainer, + OuterContainer, + FootContainer, +} from "./component"; import { Container, ProjectBox2, Title, + Inner, ButtonContainer, Button, } from "../../../emotion/component"; import test3 from "../../../../json/test3.json"; const Agriboard = () => { - const OuterContainer = styled.div` - display: flex; - align-items: center; - justify-content: space-between; - flex-direction: row; - `; + // 한 페이지에서 보여줄 개수 + const items = 8; + // 현 페이지를 나타낼 상태 + const [currentPage, setCurrentPage] = useState(1); + + // 보여줄 페이지의 범위 + const startIndex = (currentPage - 1) * items; + const endIndex = startIndex + items; - const Inner = styled.div` - flex: 1; - display: flex; - flex-wrap: wrap; - gap: 40px; - justify-content: space-between; - margin-top: 300px; - `; - const FootContainer = styled.div` - display: flex; - justify-content: center; - align-items: center; - margin: 300px; - `; + // 페이지 범위에 따라 데이터 분할 + const currentItems = test3.Project.slice(startIndex, endIndex); + + // 현 페이지의 상태를 변화 시켜 페이지 이동 + const handlePrevPage = () => { + if (currentPage > 1) { + setCurrentPage(currentPage - 1); + } + }; + const handleNextPage = () => { + const totalPages = Math.ceil(test3.Project.length / items); + if (currentPage < totalPages) { + setCurrentPage(currentPage + 1); + } + }; return ( <> @@ -85,8 +93,8 @@ const Agriboard = () => { - {test3 && - test3.Project.map((project) => ( + {currentItems && + currentItems.map((project) => ( { - + + + + + diff --git a/src/component/project/board/proboard/index.js b/src/component/project/board/proboard/index.js index f93daa6..256d856 100644 --- a/src/component/project/board/proboard/index.js +++ b/src/component/project/board/proboard/index.js @@ -1,22 +1,14 @@ import React from "react"; -import styled from "@emotion/styled"; -import { IndexContainer, InnerContainer, SignButton } from "./component"; +import { IndexContainer, InnerContainer } from "./component"; import { Button, Container, ProjectBox, Title, + Inner, } from "../../../emotion/component"; import test from "../../../../json/test.json"; const Proboard = () => { - const Inner = styled.div` - width: 100%; - display: flex; - flex-wrap: wrap; - gap: 40px; - justify-content: space-between; - margin-top: 300px; - `; return ( <> diff --git a/src/component/project/board/sellerboard/component.js b/src/component/project/board/sellerboard/component.js index d4aa7bc..e2368a2 100644 --- a/src/component/project/board/sellerboard/component.js +++ b/src/component/project/board/sellerboard/component.js @@ -37,3 +37,10 @@ export const SignButton = styled.div` align-items: center; margin-top: 30px; `; + +export const OuterContainer = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + flex-direction: row; +`; diff --git a/src/component/project/board/sellerboard/index.js b/src/component/project/board/sellerboard/index.js index 09983cb..f6c0fe7 100644 --- a/src/component/project/board/sellerboard/index.js +++ b/src/component/project/board/sellerboard/index.js @@ -1,32 +1,17 @@ import React from "react"; import styled from "@emotion/styled"; -import { IndexContainer, InnerContainer, SignButton } from "./component"; +import { IndexContainer, InnerContainer, OuterContainer } from "./component"; import { Container, ProjectBox, Title, ButtonContainer, Button, + Inner, } from "../../../emotion/component"; import test2 from "../../../../json/test2.json"; const Proboard = () => { - const OuterContainer = styled.div` - display: flex; - align-items: center; - justify-content: space-between; - flex-direction: row; - `; - - const Inner = styled.div` - flex: 1; - display: flex; - flex-wrap: wrap; - gap: 40px; - justify-content: space-between; - margin-top: 300px; - `; - return ( <> diff --git a/src/component/project/community/component.js b/src/component/project/community/component.js index d4aa7bc..e1445f7 100644 --- a/src/component/project/community/component.js +++ b/src/component/project/community/component.js @@ -37,3 +37,47 @@ export const SignButton = styled.div` align-items: center; margin-top: 30px; `; + +export const OuterContainer = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + flex-direction: row; +`; + +export const TableContainer = styled.div` + margin-top: 40px; + padding: 0 147px; + table { + width: 100%; + border-collapse: collapse; + th { + border: 1px solid #fff; + color: #fff; + padding: 10px; + background: #76c56f; + } + td { + border: 1px solid #dfdfdf; + padding: 10px; + } + th:nth-of-type(1) { + width: 1361px; + } + th:nth-of-type(2) { + width: 265px; + } + td { + height: 60px; + } + input { + width: 100%; + height: 100%; + border: none; + background: transparent; + color: #000; + font-family: Inter; + font-size: 14px; + } + } +`; diff --git a/src/component/project/community/index.js b/src/component/project/community/index.js index 704389a..fb649cd 100644 --- a/src/component/project/community/index.js +++ b/src/component/project/community/index.js @@ -1,56 +1,12 @@ import React, { useState } from "react"; -import styled from "@emotion/styled"; import { Container, Title, ButtonContainer, Button, } from "../../emotion/component"; +import { OuterContainer, TableContainer } from "./component"; const Community = () => { - const OuterContainer = styled.div` - display: flex; - align-items: center; - justify-content: space-between; - flex-direction: row; - `; - - const TableContainer = styled.div` - margin-top: 40px; - padding: 0 147px; - table { - width: 100%; - border-collapse: collapse; - th { - border: 1px solid #fff; - color: #fff; - padding: 10px; - background: #76c56f; - } - td { - border: 1px solid #dfdfdf; - padding: 10px; - } - th:nth-of-type(1) { - width: 1361px; - } - th:nth-of-type(2) { - width: 265px; - } - td { - height: 60px; - } - input { - width: 100%; - height: 100%; - border: none; - background: transparent; - color: #000; - font-family: Inter; - font-size: 14px; - } - } - `; - const [data, setData] = useState([ { id: 1, title: "Sample Title 1", author: "John" }, { id: 2, title: "Sample Title 2", author: "Jane" }, diff --git a/src/json/test3.json b/src/json/test3.json index db8be05..525ad2a 100644 --- a/src/json/test3.json +++ b/src/json/test3.json @@ -47,6 +47,36 @@ "title": "복숭아(백도) /4KG", "content": "26,180원 ", "imageSrc": "/img/img8.png" + }, + { + "id": 9, + "title": "풀때기 /4KG", + "content": "26,180원 ", + "imageSrc": "/img/img8.png" + }, + { + "id": 10, + "title": "풀때기 /4KG", + "content": "26,180원 ", + "imageSrc": "/img/img8.png" + }, + { + "id": 11, + "title": "풀때기 /4KG", + "content": "26,180원 ", + "imageSrc": "/img/img8.png" + }, + { + "id": 12, + "title": "풀때기 /4KG", + "content": "26,180원 ", + "imageSrc": "/img/img8.png" + }, + { + "id": 13, + "title": "복숭아(백도) /4KG", + "content": "26,180원 ", + "imageSrc": "/img/img8.png" } ] }