Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mission4 / 강하은 #30

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.6.8",
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@slack/webhook": "^7.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"styled-components": "^6.1.8"
},
"devDependencies": {
"@types/react": "^18.2.64",
Expand Down
44 changes: 44 additions & 0 deletions public/api/products.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[
{
"id": 1,
"src": "https://img.freepik.com/free-photo/jeans_1203-8092.jpg",
"name": "무시무시한바지",
"price": "500000₩",
"isSale": "true"
},
{
"id": 2,
"src": "https://img.freepik.com/free-psd/jerzees-pullover-hooded-sweatshirt-mockup-01_126278-94.jpg?w=1480&t=st=1712066977~exp=1712067577~hmac=e2134a114b35532277ab0c2b76ae698527139f0b46b345c0caa0e9aa3d66cd33",
"name": "후드티",
"price": "500000₩",
"isSale": "true"
},
{
"id": 3,
"src": "https://img.freepik.com/free-photo/basic-white-tee-women-s-apparel-rear-view_53876-108033.jpg?t=st=1712067014~exp=1712070614~hmac=7f176e8ed6876ac7593cb0bf2cc392ede4372858b1fec4bb3e585546753bea02&w=1380",
"name": "반팔 티",
"price": "200000₩",
"isSale": "false"
},
{
"id": 4,
"src": "https://img.freepik.com/free-photo/background-textile-protection-back-object_1203-6405.jpg?t=st=1712067043~exp=1712070643~hmac=30c53d8fcb2e8a6d516b952a2f0b1df44ee66af6ec82856ec8f0e676db9b5c8e&w=1060",
"name": "볼 캡 (야구모자)",
"price": "500000₩",
"isSale": "true"
},
{
"id": 5,
"src": "https://img.freepik.com/free-photo/still-life-rendering-jackets-display_23-2149745031.jpg?t=st=1712067097~exp=1712070697~hmac=2a020243be6e84e0541f2292493bb00dd13ea328e50021ceff86fa567e5fab95&w=2000",
"name": "가죽 자켓",
"price": "500000₩",
"isSale": "true"
},
{
"id": 6,
"src": "https://img.freepik.com/free-vector/all-types-black-white-socks-sports-every-day-realistic-set-isolated-vector-illustration_1284-73137.jpg?t=st=1712067118~exp=1712070718~hmac=d5bc8f8b274ebd67d98d0bfa02db9e530818eb49b18a7ed13fa3751f26737dae&w=2000",
"name": "양말",
"price": "200000₩",
"isSale": "false"
}
]
30 changes: 30 additions & 0 deletions public/api/sale_products.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"id": 1,
"src": "https://img.freepik.com/free-photo/jeans_1203-8092.jpg",
"name": "무시무시한바지",
"price": "500000₩",
"isSale": "true"
},
{
"id": 2,
"src": "https://img.freepik.com/free-psd/jerzees-pullover-hooded-sweatshirt-mockup-01_126278-94.jpg?w=1480&t=st=1712066977~exp=1712067577~hmac=e2134a114b35532277ab0c2b76ae698527139f0b46b345c0caa0e9aa3d66cd33",
"name": "후드티",
"price": "500000₩",
"isSale": "true"
},
{
"id": 4,
"src": "https://img.freepik.com/free-photo/background-textile-protection-back-object_1203-6405.jpg?t=st=1712067043~exp=1712070643~hmac=30c53d8fcb2e8a6d516b952a2f0b1df44ee66af6ec82856ec8f0e676db9b5c8e&w=1060",
"name": "볼 캡 (야구모자)",
"price": "500000₩",
"isSale": "true"
},
{
"id": 5,
"src": "https://img.freepik.com/free-photo/still-life-rendering-jackets-display_23-2149745031.jpg?t=st=1712067097~exp=1712070697~hmac=2a020243be6e84e0541f2292493bb00dd13ea328e50021ceff86fa567e5fab95&w=2000",
"name": "가죽 자켓",
"price": "500000₩",
"isSale": "true"
}
]
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

42 changes: 0 additions & 42 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,42 +0,0 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
93 changes: 66 additions & 27 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,74 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useState, useEffect } from "react";
import Image from "./assets/Image.jpg";
import styled from "styled-components";
import axios from "axios";

function App() {
const [count, setCount] = useState(0)
const [products, setProducts] = useState([]);
const [currentView, setCurrentView] = useState("All product");

useEffect(() => {
axios
.get(
`api/${
currentView === "All product" ? "products.json" : "sale_products.json"
}`
)
.then((res) => {
setProducts(res.data);
})
.catch((error) => {
console.error("상품 데이터를 불러오는 중 오류가 발생했습니다.", error);
Comment on lines +11 to +21
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#29 (comment)
(위와 다른 코멘트입니다.)

});
}, [currentView]);
return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.jsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<img src={Image} style={{ width: "100%" }} />
<ProductFrame>
{
<Button
onClick={() => {
setCurrentView(
currentView === "Sale product" ? "All product" : "Sale product"
);
}}
>
{currentView === "All product" ? "All product" : "Sale product"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{currentView === "All product" ? "All product" : "Sale product"}
{currentView}

로 쓸수 있나요??

</Button>
}
<ProductList>
{products.map((product) => (
<div key={product.id}>
<img src={product.src} style={{ width: "100%" }} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styled-component를 사용하지 않고 inline style을 준 이유가 있나요?

<div>{product.name}</div>
<div>{product.price}</div>
</div>
))}
</ProductList>
</ProductFrame>
</>
)
);
}

export default App
export default App;

const ProductFrame = styled.div`
padding: 1.5rem;
`;
const ProductList = styled.div`
display: flex;
gap: 5rem;
flex-wrap: wrap;
padding: 1rem;
& > div {
width: calc((100% - 10rem) / 3);
}
`;

const Button = styled.button`
border: none;
border-radius: 1rem;
font-size: 1.5rem;
width: auto;
height: 3rem;
`;
Binary file added src/assets/Image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

68 changes: 0 additions & 68 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,68 +0,0 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
13 changes: 6 additions & 7 deletions src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";

ReactDOM.createRoot(document.getElementById('root')).render(
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
</React.StrictMode>
);