[1st project] TabomGalagsin #01 ๐Ÿฉด

Havaianas clone coding

ยท

2 min read

1st day of the project

์šฐ๋ฆฌ๊ฐ€ ํด๋ก  ํ•  website!! : https://havaianas.com.br/

์ดˆ๊ธฐ์„ธํŒ… git clone ๋ฐ›๊ธฐ!

  • ์˜ค์ „์— ์–ด์ œ ํŒ€์›๋“ค๊ณผ ์ง„ํ–‰ํ•œ ์ดˆ๊ธฐ์„ธํŒ…ํ•œ main์„ github์„ ํ†ตํ•ด clone๋ฐ›๊ณ  ๋‚ด๊ฐ€ ๋งก์€ ๋ถ„์•ผ์ธ navbar ๊ตฌํ˜„์„ ์ง„ํ–‰ํ–ˆ๋‹ค.

Sprint standup meeting

  • ํŒ€์›๋“ค๊ณผ ์ฒซ standup meeting์„ ์ง„ํ–‰ํ–ˆ๋‹ค. ๋ฐฑ์—”๋“œ, ํ”„๋ก ํŠธ์—”๋“œ ์–ด์ œํ•œ ์ผ, ์˜ค๋Š˜ํ•  ์ผ ๊ทธ๋ฆฌ๊ณ  blocker์„ ๊ณต์œ ํ•˜์˜€๋‹ค. ๋‚˜๋Š” navbar์— ์ถ”๊ฐ€ํ•  ์šฐ๋ฆฌํŒ€ ๋กœ๊ณ ๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์—ฌ์ฃผ์—ˆ๋‹ค. ๋‹คํ–‰ํžˆ ๋งˆ์Œ์— ๋“ค์–ดํ•˜์…”์„œ ๋กœ๊ณ ๋กœ ์ถ”๊ฐ€ํ•˜๊ธฐ๋Ÿฌ ํ–ˆ๋‹ค.

Navbar ๊ตฌํ˜„ ์‹œ์ž‘!

  • ์ผ๋‹จ cloneํ•  website๋ฅผ ๋ณด๋ฉฐ ๊ตฌ์กฐ๋ฅผ ์žก์•˜๋‹ค. ์ƒ๋‹จ๋ฉ”๋‰ด๊ฐ€ ์—ฌ๋Ÿฌ๊ฐ€์ง€์˜€๋Š”๋ฐ ๊ทธ ์ค‘ ์นดํ…Œ๊ณ ๋ฆฌ๋ถ€๋ถ„๋งŒ ์ผ๋‹จ ํด๋ก ํ•˜๊ฒŒ ๋˜์–ด ์ƒ๋‹จ ๋ฉ”๋‰ด๋ฐ”์˜ ๊ตฌ์กฐ๋ฅผ ์‚ด์ง ์ˆ˜์ •ํ–ˆ๋‹ค. Navbar์€ 2๊ฐœ๋กœ ๋‚˜๋ˆ„์—ˆ๊ณ  (๋ฉ”๋‰ด๋ฐ” ์œ„์— carousel ๊ด‘๊ณ ๊ธฐ๋Šฅ์„ ์œ„ํ•ด) flex๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ ์•„์ด์ฝ˜๊ณผ ๋กœ๊ณ ์˜ position์„ ์žก์•„์ฃผ์—ˆ๊ณ  navbar๋Š” 2๊ฐœ๋กœ ๋‚˜๋ˆ„์—ˆ๋‹ค.
  • ์ฒ˜์Œ์—” ๊ณต์‹์›น์‚ฌ์ดํŠธ์˜ ๋ฉ”์ธ colour์„ ๋„ฃ์—ˆ์ง€๋งŒ ํ™”๋ฉด์ด ๋ฐ”๋€” ๋•Œ๋งˆ๋‹ค ๋ฐฐ๊ฒฝํ™”๋ฉด๊ณผ nav bar๋„ ๊ฐ™์ด ๋ฐ”๋€Œ๋Š”๊ฑธ ๋ณด๊ณ  background: none์œผ๋กœ ์ˆ˜์ •, ๊ทธ๋ฆฌ๊ณ  box-shadow: 0px 8px 15px rgb(0 0 0 / 10%) ๋„ฃ์–ด์ฃผ์–ด ๋ฉ”์ธ ๋ฐฐ๊ฒฝ์ƒ‰๊ณผ ๊ตฌ๋ถ„์ด ๊ฐ€๋„๋ก ํ•œ ๊ฒƒ์„ ํด๋ก ํ•˜์˜€๋‹ค.
  • CSS hover๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•ด์„œ ๋ฉ”๋‰ด๋ฅผ ๋งˆ์šฐ์Šค๋กœ hoverํ–ˆ์„ ๋•Œ dropdown ๋ฉ”๋‰ด๊ฐ€ ๋œจ๊ฒŒ ํ•˜๊ณ  ์‹ถ์—ˆ๋Š”๋ฐ ์•„๋ฌด๋ž˜๋„ ์•„์ด์ฝ˜๊ณผ nesting์ด ๋˜์ง€ ์•Š์€ <div>์—ฌ์„œ ์ ์šฉ์ด ๋˜์ง€ ์•Š์•˜๋‹ค. ์–ด๋–ป๊ฒŒ ํ•˜๋ฉด dropdown ๋ฉ”๋‰ด๊ฐ€ ๋œฐ ์ˆ˜ ์žˆ์„์ง€ ๊ณ ๋ฏผ ํ•ด ๋ณด์•˜๋‹ค. ์•ž์„œ ๋ฐฐ์šด useState๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ดˆ๊ธฐ๊ฐ’์„ false๋กœ ์„ค์ •ํ•˜๊ณ  addEventListener onMouseOver(๋˜๋Š” onMouseEnter)์„ ์‚ฌ์šฉํ•˜์—ฌ ๋งˆ์šฐ์Šค๋ฅผ ๊ฐ–๋‹ค ๋Œ”์„ ๋•Œ, ๋ฉ”๋‰ด dropdown๋ฉ”๋‰ด๊ฐ€ navbarํ•˜๋‹จ์— ์ƒ๊ธฐ๊ฒŒ ํ•˜๊ณ  onMouseLeave์„ ์จ์„œ ๋งˆ์šฐ์Šค๊ฐ€ dropdown๋ฉ”๋‰ด์™€ ์•„์ด์ฝ˜์„ ๋ฒ—์–ด๋‚˜๋ฉด ๋‹ค์‹œ ๊ทธ ๋ฉ”๋‰ด๊ฐ€ ์‚ฌ๋ผ์ง€๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์—ˆ๋‹ค! ํ•˜์ง€๋งŒ ์—ฌ๊ธฐ์„œ ๋˜ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค. ๊ฐ™์€๊ธฐ๋Šฅ์„ ํ•˜๋Š” ์ด useState๋ฅผ child component์—๋„ ์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์—ˆ๋Š”๋ฐ ๊ทธ๋ ‡๊ฒŒ ๋˜๋‹ˆ true์™€ false๊ฐ€ ์„ž์—ฌ๋ฒ„๋ ค ๋ Œ๋”๋ง์ด ์•ˆ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค.
  • ๊ฐ™์€ ํŒ€์›๋ถ„๊ป˜ SOS๋ฅผ ์š”์ฒญํ–ˆ๋”๋‹ˆ ๊ฐ์ปดํฌ๋„ŒํŠธ๋ณ„๋กœ useState๋ฅผ ๋”ฐ๋กœ ์ค˜์„œ ์„ž์ด์ง€ ์•Š๊ฒŒ ํ•ด์•ผํ•œ๋‹ค๊ณ  ํ•˜์…จ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•ด์ฃผ์…จ๋Š”๋ฐ ํ›จ์”ฌ ์ฝ”๋“œ๊ฐ€ ์งง์•„์กŒ๊ณ  ์ œ ๊ธฐ๋Šฅ๋„ ๊ตฌํ˜„์ด ๋˜์—ˆ๋‹ค.
import React, { useState } from 'react';
import DropdownContent from './DropdownContent/DropdownContent';
import './Dropdown.scss';

function Dropdown({ onMouseLeave }) {
  const [menuMouseEnter, setMenuMouseEnter] = useState('Categories'); // true false ๋Œ€์‹  ๋ฉ”๋‰ด ์ด๋ฆ„ ์‚ฌ์šฉ

  return (
    <div className="Dropdown" onMouseLeave={onMouseLeave}> // ๋งˆ์šฐ์Šค๊ฐ€ div๋ฅผ ๋– ๋‚ฌ์„ ๋•Œ ๋“œ๋กญ๋‹ค์šด์„ ์—†์• ๋ผ
      <div className="dropdownMenu">
        <div className="dropdownCategory">
          <ul>
            <li
              className="arrow"
              onMouseOver={() => {
                setMenuMouseEnter('Categories'); // arrow function์œผ๋กœ ๋ณ€์ˆ˜๋ฅผ ์ˆ˜์ •
              }}
            > // ์นดํ…Œ๊ณ ๋ฆฌ๋ฅผ hoverํ–ˆ์„ ๋•Œ, ์นดํ…Œ๊ณ ๋ฆฌ๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ฒŒ
              Categories <i className="fa-solid fa-angle-right arrow" />
            </li>
            <li
              className="arrow"
              onMouseOver={() => {
                setMenuMouseEnter('Colour');
              }}
            > // colour๋ฅผ hover ํ–ˆ์„ ๋•Œ, colour๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ฒŒ
              Colour <i className="fa-solid fa-angle-right arrow" />
            </li>
          </ul>
        </div>
        <DropdownContent title={menuMouseEnter} /> // ์ด ์ปดํฌ๋„ŒํŠธ ์•ˆ์— ์žˆ๋Š” ํƒ€์ดํ‹€ ๋ณ„๋กœ ๋‚ด์šฉ ๋ณ€๊ฒฝ
      </div>
    </div>
  );
}

export default Dropdown;
  • <DropdownContent>๋Š” ์žฌ์‚ฌ์šฉํ•˜์˜€๋‹ค. โ†’ ๊ฐ™์€ format ์•ˆ์— ๋‹ค๋ฅธ ๋‚ด์šฉ

image.png


My thoughts

ย