-
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.
- Loading branch information
1 parent
b3265d1
commit fbc7411
Showing
8 changed files
with
98 additions
and
11 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,15 @@ | ||
import React from 'react'; | ||
import * as S from './Choice.styled'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
|
||
export default function Choice(props) { | ||
const { game } = props | ||
console.log(game) | ||
return ( | ||
<S.ItemContainer> | ||
<S.ItemList>{game.firstTitle}</S.ItemList> | ||
<S.ItemList2>{game.secondTitle}</S.ItemList2> | ||
</S.ItemContainer> | ||
); | ||
} |
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,36 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const ItemContainer = styled.div` | ||
font-family:"HSSantokki2-Regular"; | ||
margin-top: 3.2rem; | ||
display: grid; /* Grid 레이아웃 사용 */ | ||
grid-template-columns: repeat(3, 1fr); /* 3개의 열 생성 */ | ||
`; | ||
|
||
export const ItemList = styled.div` | ||
padding: 5rem; | ||
text-align:center; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 2rem; | ||
font-size: 3.4rem; | ||
width: 60.7rem; | ||
height: 34.2rem; | ||
border: 0.2rem solid ${(props) => props.theme.colors.black}; | ||
background-color: ${(props) => props.theme.colors.gray200}; | ||
`; | ||
|
||
export const ItemList2 = styled.div` | ||
padding: 5rem; | ||
text-align:center; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: 2rem; | ||
font-size: 3.4rem; | ||
width: 60.7rem; | ||
height: 34.2rem; | ||
border: 0.2rem solid ${(props) => props.theme.colors.black}; | ||
background-color: ${(props) => props.theme.colors.primaryGreen}; | ||
`; |
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,28 +1,30 @@ | ||
import { useEffect, useState } from 'react'; | ||
import * as S from './Item.styled'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
export default function Item() { | ||
const [e, setE] = useState([]); | ||
export default function Game() { | ||
const [games, setGames] = useState([]); | ||
useEffect(() => { | ||
const a = async () => { | ||
const res = await fetch('http://localhost:5173/api/item'); | ||
const data = await res.json(); | ||
console.log(data.data); | ||
setE(data.data); | ||
setGames(data.data); | ||
}; | ||
a(); | ||
}, []); | ||
|
||
|
||
return ( | ||
<S.ItemContainer> | ||
{e.map((item) => { | ||
{games.map((game) => { | ||
return ( | ||
<div key={item.id}> | ||
<S.ItemList>{item.firstTitle}</S.ItemList> | ||
<S.ItemList2>{item.secondTitle}</S.ItemList2> | ||
</div> | ||
<Link key={game.id} to={`/game/${game.id}`} style={{ textDecoration: 'none', color: 'inherit' }}> | ||
<S.ItemList>{game.firstTitle}</S.ItemList> | ||
<S.ItemList2>{game.secondTitle}</S.ItemList2> | ||
</Link> | ||
); | ||
})} | ||
</S.ItemContainer> | ||
); | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"id": 1, | ||
"firstTitle": "애인이 나 말고 연락하는 사람 한명도 없는 아싸", | ||
"secondTitle": "애인이 나 아니어도 연락할 사람 너무 많은 인싸" | ||
} |
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,20 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import Choice from '../components/choice/Choice'; | ||
|
||
export default function GamePage() { | ||
const [gameData, setGameData] = useState([]) | ||
const { id } = useParams() | ||
useEffect(() => { | ||
const a = async () => { | ||
const res = await fetch(`http://localhost:5173/api/game/${id}`); | ||
const data = await res.json(); | ||
console.log(data.data); | ||
setGameData(data.data); | ||
}; | ||
a(); | ||
}, []); | ||
return (<> | ||
<Choice game={gameData} /> | ||
</>) | ||
} |
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,11 +1,14 @@ | ||
import { createBrowserRouter } from "react-router-dom"; | ||
import GlobalLayout from "./layout/GlobalLayout"; | ||
import MainPage from "./pages/MainPage"; | ||
import GamePage from "./pages/GamePage"; | ||
|
||
export const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <GlobalLayout />, | ||
children: [{ index: true, element: <MainPage /> }], | ||
children: [{ index: true, element: <MainPage /> }, | ||
{ path: "/game/:id", element: <GamePage /> } | ||
], | ||
}, | ||
]); |