React

[TIL/React] 2023/08/18

CardComponent ๐ŸŸ src/components/common/ProductCard.jssrc/data/ProductList.jssrc/pages/Home.jsproduct list์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ์žก๊ณ , ์นด๋“œ ์ปดํฌ๋„ŒํŠธ์— map์„ ํ†ตํ•ด ์ ์šฉํ•œ ๋’ค, home

2023๋…„ 8์›” 18์ผ2min read

CardComponent ๐ŸŸ 

1. src/components/common/ProductCard.js

code
import React from "react";
import { styled } from "styled-components";
import ComponentWrapper from "./ComponentWrapper";
import { products } from "../../data/ProductList";

const ProductWrapper = styled.div`
  width: calc(33.3% - 40px);
  margin: 10px;
`;

const ProductImgWrapper = styled.div`
  background-color: rgb(249, 247, 248);
  width: 100%;
  height: 400px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  box-shadow: 0px 10px 8px #999;
`;

const ProductImage = styled.img`
  width: 100%;
  height: auto;
`;

const ProductInfoTitle = styled.p`
  font-weight: bolder;
  font-size: 25px;
`;

const ProductInfoEtc = styled.p`
  color: #9b9b9b;
  font-weight: bolder;
`;

const ProductCard = () => {
  return (
    <ComponentWrapper style={{ display: "flex", flexWrap: "wrap" }}>
      {products?.map((product) => (
        <ProductWrapper key={product?.id}>
          <ProductImgWrapper>
            <ProductImage src={product?.image} />
          </ProductImgWrapper>
          <div>
            <ProductInfoTitle>{product?.title}</ProductInfoTitle>
            <ProductInfoEtc>
              {product?.price} / {product?.weight}
            </ProductInfoEtc>
          </div>
        </ProductWrapper>
      ))}
    </ComponentWrapper>
  );
};

export default ProductCard;

2. src/data/ProductList.js

code
import {
  porkImg,
  chickenImg,
  porkcutletImg,
  eggImg,
  milkImg,
  hanuroundImg,
  carthegardenImg,
} from "../images";

export const products = [
  {
    id: "1",
    image: porkImg,
    title: "์ดˆ์‹ ์„  ๋ผ์ง€ ์‚ผ๊ฒน์‚ด ๊ตฌ์ด์šฉ",
    price: "๊ธฐ์ค€๊ฐ€ 19,800์›",
    weight: "600g",
  },
  {
    id: "2",
    image: chickenImg,
    title: "์ดˆ์‹ ์„  ๋‹ญ๋ณถ์Œํƒ•",
    price: "๊ธฐ์ค€๊ฐ€ 7,800์›",
    weight: "950g",
  },
  {
    id: "3",
    image: porkcutletImg,
    title: "์ดˆ์‹ ์„  ๋“ฑ์‹ฌ ๋ˆ๊นŒ์Šค",
    price: "๊ธฐ์ค€๊ฐ€ 12,500์›",
    weight: "770g",
  },
  {
    id: "4",
    image: eggImg,
    title: "์ดˆ์‹ ์„  ๋™๋ฌผ๋ณต์ง€ ๋ฌดํ•ญ์ƒ์ œ ์œ ์ •๋ž€",
    price: "๊ธฐ์ค€๊ฐ€ 6,900์›",
    weight: "12๊ตฌ",
  },
  {
    id: "5",
    image: milkImg,
    title: "์ดˆ์‹ ์„  ๋ฌดํ•ญ์ƒ์ œ ์šฐ์œ ",
    price: "๊ธฐ์ค€๊ฐ€ 3,600์›",
    weight: "900ml",
  },
  {
    id: "6",
    image: hanuroundImg,
    title: "์ดˆ์‹ ์„  ์ด์œ ์‹์šฉ ํ•œ์šฐ ์šฐ๋‘” ๋‹ค์ง์œก",
    price: "๊ธฐ์ค€๊ฐ€ 17,100์›",
    weight: "180g",
  },
  {
    id: "7",
    image: carthegardenImg,
    title: "๋‚˜๊ฐ€๊ฑฐ๋“  ๋‹˜",
    price: "๊ธฐ์ค€๊ฐ€ 39,800์›",
    weight: "980g",
  },
];

3. src/pages/Home.js

code
import React from "react";
import { backgroundImg } from "../images";
import ComponentWrapper from "../components/common/ComponentWrapper";
import TestComponent from "../components/common/TestComponent";
import ProductCard from "../components/common/ProductCard";
const Home = () => {
  return (
    <>
      <div style={{ backgroundColor: "white", height: "1000px" }}>
        <img src={backgroundImg} style={{ width: "100%", height: "100%" }} />
      </div>
      <div
        style={{
          backgroundColor: "white",
          height: "1000px",
          overflowX: "auto",
        }}
      >
        <ProductCard />
      </div>

      <div style={{ backgroundColor: "gray", height: "1000px" }}></div>
      <div style={{ backgroundColor: "white", height: "1000px" }}></div>
    </>
  );
};

export default Home;

product list์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ๋ฅผ ์žก๊ณ , ์นด๋“œ ์ปดํฌ๋„ŒํŠธ์— map์„ ํ†ตํ•ด ์ ์šฉํ•œ ๋’ค, home page์—์„œ ํ•ด๋‹น ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ Œ๋”๋งํ•˜๋Š” ๊ตฌ์กฐ์ด๋‹ค.

4. ํ˜„์žฌ

์ฝ”๋“œ๋Š” ์กฐ์žกํ•˜๋‚˜ ๋””์ž์ธ์€ ๋งˆ์Œ์— ๋“ ๋‹ค.

More to read

Amazon VPC

Amazon VPC Architecture ์ดํ•ดํ•˜๊ธฐ

์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ๋ฅผ ๊ธฐํšํ•˜๋ฉฐ, ๊ฐœ๋ฐœ์—์„œ ๋ฌด์—‡์„ ๊ฐ€์žฅ ๋จผ์ € ๊ณ ๋ฏผํ•ด์•ผ ํ•˜๋Š”์ง€ ๋‹ค์‹œ ๋Œ์•„๋ณด๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.ํ•œ๋•Œ๋Š” ํ”„๋ก ํŠธ์—”๋“œ๊ฐ€ ๋ชจ๋“  ์„ค๊ณ„์˜ ์ถœ๋ฐœ์ ์ด๋ผ๊ณ  ๋ฏฟ์—ˆ์Šต๋‹ˆ๋‹ค. ์œ ์ €๊ฐ€ ๋ฌด์—‡์„ ๋ณด๊ณ , ์–ด๋–ค ํ๋ฆ„์—์„œ ๋จธ๋ฌด๋ฅด๊ณ  ์ดํƒˆํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์ดํ•ด ์—†์ด ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ ๋‹ค๋Š” ๊ฑด ๋ถˆ๊ฐ€๋Šฅํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ธฐ

'์›์‚ฌ์ดํŠธ'

ํ”„๋ก ํŠธ์—”๋“œ ๊ด€์ ์œผ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ดํ•ดํ•˜๊ธฐ

์˜ค๋žœ๋งŒ์— ๋ฐฉ๋ฒ•๋ก ์— ๊ด€ํ•œ ๊ธ€์„ ์“ฐ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ตœ๊ทผ ์ƒํ™ฉ์€ ์ด๋ ‡์Šต๋‹ˆ๋‹ค. SSAFY์—์„œ๋Š” ํ•˜๋ฃจ์— ์—„์ฒญ๋‚œ ์–‘์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋“ค์„ ๊ณผ์ œ๋กœ ์ˆ˜ํ–‰ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ ๊ณผ์ •์—์„œ, '๊ตฌํ˜„๋ ฅ'์ด ๋งค์šฐ ๋–จ์–ด์ง„๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์™„์ „ํžˆ ์–ด๋ ค์šด ๋ฌธ์ œ๋ผ๋ฉด '์•„์‰ฌ์›€'์ด๋ผ๋Š” ๊ฐ์ •์กฐ์ฐจ ๋А๋ผ์ง€

Subnet

VPC ์„ค๊ณ„์˜ ์‹œ์ž‘: IP์™€ Subnet

๋ฐ˜๋ณต๋˜๋Š” ๋ฃจํ‹ด ์†์—์„œ ์–ป์€ ์•ˆ์ •๊ฐ์„ ๋ฐœํŒ ์‚ผ์•„, ์ด์ œ๋Š” ๊ธฐ์ˆ ์  ์ŠคํŽ™ํŠธ๋Ÿผ์„ ๋„“ํžˆ๊ธฐ ์œ„ํ•œ ๊ฐœ์ธ ํ”„๋กœ์ ํŠธ์— ์ฐฉ์ˆ˜ํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค.์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์˜ ๋ชฉํ‘œ๋Š” ๋‹จ์ˆœํ•œ ํฌํŠธํด๋ฆฌ์˜ค ๊ตฌ์ถ•์„ ๋„˜์–ด, ์‹ค์ œ ์„œ๋น„์Šค ์ˆ˜์ค€์˜ ๋ธ”๋กœ๊ทธ ์‹œ์Šคํ…œ ๊ตฌํ˜„๊ณผ ๋‹ค๊ตญ์–ด ์ฒ˜๋ฆฌ ์ ์šฉ ๋“ฑ ์‹ค๋ฌด์— ๊ฐ€๊นŒ์šด ์—ญ๋Ÿ‰์„ ํ•œ ๋‹จ๊ณ„