Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/components/ColorPage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { useParams } from 'react-router-dom';
import '../styles/ColorPage.css';

<Route path="/mainpage/:id" element={<mainpage />} />
function ColorPage() {

return (
<div className="color-page">
배경 페이지입니다
<div
className="color-page"
style={{
backgroundColor: id,
height: '100vh',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
color: 'white',
fontSize: '2rem',
}}
>
배경 페이지입니다 : {id}
</div>
);
}
Expand Down
27 changes: 24 additions & 3 deletions src/components/MainPage.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
import { useNavigate } from 'react-router-dom';
import '../styles/MainPage.css';

const Mainpage = () => {

const colors = ["red", "blue", "pink", "orange", "yellow"];

const MainPage = () => {
const navigate = useNavigate();

return (
<div className="container">
<h2>React 색상 선택</h2>
<hr />
{colors.map((color) => (
<button>
key={color}
onClick={() => navigate(`/color/${color}`)}
styled={{
backgroundColor: color,
color: color === "yellow" ? "black" : "white",
margin: "5px",
padding: "10px",
border: "none",
borderRadius: "5px",
cursor: "pointer"
}}

{color}
</button>
))}

</div>
);
};

export default Mainpage;
export default MainPage;