Unit11 - Cozโ€™ Mini Hackathon

๊ฐ•์„ฑ์ผยท2023๋…„ 5์›” 4์ผ
0
post-thumbnail

โœ… TIL


Git์œผ๋กœ ํ˜‘์—…ํ•˜๊ธฐ



Git์—์„œ ์ฝ”๋“œ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„์„ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ผ๊ณ  ํ•œ๋‹ค.

๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋Š” ์ž์‹ ์˜ ์ปดํ“จํ„ฐ์˜ ์ž‘์—… ๊ณต๊ฐ„(local)์— ์œ„์น˜ํ•œ ๋กœ์ปฌ Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์™€,
Github ๋“ฑ์˜ ์›๊ฒฉ(remote) ๊ณต๊ฐ„์— ์œ„์น˜ํ•œ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๋‹ค.




โš™๏ธ ๋กœ์ปฌ Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ(Repository)๋ž€?



  1. ์ฝ”๋“œ๋ฅผ ์ €์žฅํ•  ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ  ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์— ๋กœ์ปฌ Git repository๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. (git init)

  2. ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„, ์ž‘์—… ๊ณต๊ฐ„(work space)์˜ ํŒŒ์ผ ๋ฐ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ
    git์˜ ๊ด€๋ฆฌํ•˜์— ์žˆ๋Š” ์ƒํƒœ๋กœ ์˜ฌ๋ ค์ค„ ์ˆ˜ ์žˆ๋‹ค. ์ด ์˜์—ญ์ด staging area์ด๋‹ค. (git add)

  3. staging area์˜ ํŒŒ์ผ์€ commit์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
    commit์œผ๋กœ local Git repository์— ๋‚ด ์ฝ”๋“œ๋ฅผ ๊ธฐ๋กํ•  ์ˆ˜ ์žˆ๋‹ค. (git commit)




โš™๏ธ ์›๊ฒฉ Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ž€?


์›๊ฒฉ Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ(์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ)๋Š” ์ž์‹ ์˜ ์ปดํ“จํ„ฐ(๋กœ์ปฌ ํ™˜๊ฒฝ) ์ž‘์—… ๊ณต๊ฐ„์— ์œ„์น˜ํ•˜์ง€ ์•Š๋Š” Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์ด๋‹ค.

๊ฐœ๋ฐœ์— ๋Œ€ํ•ด์„œ ๊ฒ€์ƒ‰ํ•ด ๋ณด๋ฉด ์‰ฝ๊ฒŒ ์ ‘ํ•  ์ˆ˜ ์žˆ๋Š” Github์˜ ์—ฌ๋Ÿฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๊ฐ€ ๋Œ€ํ‘œ์ ์ธ ์˜ˆ์‹œ์ด๋‹ค.
๊ณต๊ฐœ๋œ Git ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์˜ ๊ฒฝ์šฐ, ์—ฌ๋Ÿฌ ์‚ฌ๋žŒ์ด ํ•จ๊ป˜ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋Š” ํŠน์ง•์ด ์žˆ๋‹ค.



  1. Github์—์„œ ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

  2. ๋กœ์ปฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์— ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ git url์„ ๋“ฑ๋กํ•œ๋‹ค. (git remote add)

  3. ๋กœ์ปฌ Git repository์— ๊ธฐ๋กํ•œ ๋‚ด์—ญ์„ ์›๊ฒฉ Git repository์— push ํ•œ๋‹ค. (git push)




โš™๏ธ Fork๋ž€?


ํฌํฌ๋Š” ๊ธฐ์กด์˜ ํ”„๋กœ์ ํŠธ์— ๋ณ€ํ™”๋ฅผ ์ฃผ๊ฑฐ๋‚˜ ์ƒˆ๋กœ์šด ๊ฒƒ์„ ์‹œ๋„๋ฅผ ํ•ด๋ณด๊ธฐ ์œ„ํ•ด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ๋ณต์‚ฌํ•˜๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

๊ธฐ์กด์˜ ํ”„๋กœ์ ํŠธ์— ์˜ํ–ฅ์„ ๋ฏธ์น˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์„œ๋กœ์˜ ํ”„๋กœ์ ํŠธ์— ์˜ํ–ฅ์„ ์ฃผ์ง€ ์•Š๋Š”๋‹ค.
๋˜ํ•œ ๋ผ์ด์„ ์Šค๊นŒ์ง€ ํ•จ๊ป˜ ๋ณต์‚ฌ๊ฐ€ ๋˜๊ธฐ ๋•Œ๋ฌธ์—, ๊ณต๊ฐœ๋˜์–ด ์žˆ๊ณ  ๋ผ์ด์„ ์Šค ๋ช…์‹œ๊ฐ€ ์ œ๋Œ€๋กœ ๋˜์–ด์žˆ๋Š” ํ”„๋กœ์ ํŠธ๋Š” ๋ผ์ด์„ ์Šค๋งŒ ์ž˜ ์ง€ํ‚ค๋ฉด ํฌํฌํ•ด๋„ ๋ฌธ์ œ๊ฐ€ ์—†๋‹ค.

๋ณดํ†ต Github ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋ฅผ ์ž์‹ ์˜ Github ์›๊ฒฉ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ ํฌํฌํ•œ๋‹ค.



  1. ์ž์‹ ์˜ ์ปดํ“จํ„ฐ์˜ ๋กœ์ปฌ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ git clone ํ•˜์—ฌ ๋”ฐ๋กœ ๊ฐœ๋ฐœํ•˜๊ธฐ

  2. public ํ”„๋กœ์ ํŠธ์— ๋ฒ„๊ทธ ์ˆ˜์ • ๋ฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ ์š”์ฒญ (push & pull request)
    - public ํ”„๋กœ์ ํŠธ์—์„œ ์ƒˆ๋กœ ์—…๋ฐ์ดํŠธ ๋œ ๋‚ด์šฉ์„ pull




โœ… ToDo




๋‚˜๋งŒ์˜ ์•„๊ณ ๋ผ์Šคํ…Œ์ด์ธ  ๋งŒ๋“ค๊ธฐ


๐Ÿ”ฅ Bare Minimum Requirement


  • ๋””์Šค์ปค์…˜ ๋‚˜์—ด ๊ธฐ๋Šฅ

    	> script.js๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ agoraStatesDiscussions ๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋‚˜์—ดํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
  • CSS

    	> ์•„๊ณ ๋ผ์Šคํ…Œ์ด์ธ  ์งˆ๋ฌธ ๋ฆฌ์ŠคํŠธ๊ฐ€ ์ค‘์•™์œผ๋กœ ์™€์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    	> style.css๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๋ฉ‹์ง€๊ณ  ์•„๋ฆ„๋‹ต๊ฒŒ ๋‚˜๋งŒ์˜ ์•„๊ณ ๋ผ์Šคํ…Œ์ด์ธ ๋ฅผ ๊พธ๋ฐ‰๋‹ˆ๋‹ค.
    	> colorhunt, dribbble์—์„œ ์ ์ ˆํ•œ ์ƒ‰ ์กฐํ•ฉ, ๋””์ž์ธ์„ ์ฐธ๊ณ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋””์Šค์ปค์…˜ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ

    	> script.js๋ฅผ ์ˆ˜์ •ํ•˜์—ฌ ๋””์Šค์ปค์…˜ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.
    	> section.form__container ์š”์†Œ์— ์ƒˆ๋กœ์šด ์•„๊ณ ๋ผ์Šคํ…Œ์ด์ธ  ์งˆ๋ฌธ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ ํผ์„ ์ œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ํ˜•์‹์€ ์ž์œ ์ž…๋‹ˆ๋‹ค.
    	> ์•„์ด๋””, ๋ณธ๋ฌธ์„ ์ž…๋ ฅํ•˜๊ณ  ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์‹ค์ œ ํ™”๋ฉด์— ๋””์Šค์ปค์…˜์ด ์ถ”๊ฐ€๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    	> agoraS	tatesDiscussions ๋ฐฐ์—ด์— ์ถ”๊ฐ€ํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ์‹ค์ œ ์Œ“์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • Github Page ๋ฐฐํฌ

    	> Github Page ๋ฐฐํฌ ๊ธฐ๋Šฅ์„ ์ด์šฉํ•˜์—ฌ ๋ˆ„๊ตฌ๋‚˜ ๋ณผ ์ˆ˜ ์žˆ๊ฒŒ ๋ฐฐํฌํ•ฉ๋‹ˆ๋‹ค.
  • ์ฝ”๋“œ์Šคํ…Œ์ด์ธ  fe-sprint-my-agora-states ๋ฆฌํฌ์ง€ํ† ๋ฆฌ๋กœ Pull Request

    	> ๋‚˜๋งŒ์˜ ์•„๊ณ ๋ผ์Šคํ…Œ์ด์ธ ๋ฅผ ์ฝ”๋“œ์Šคํ…Œ์ด์ธ  ๊นƒํ—ˆ๋ธŒ์— Pull requestํ•ฉ๋‹ˆ๋‹ค.
    	> ์ฃผ์–ด์ง„ Pull request ํ˜•์‹์— ๋”ฐ๋ผ์ฃผ์„ธ์š”.



๐Ÿ”ฅ Advanced Challenge


  • ํ˜„์ง€ ์‹œ๊ฐ„ ์ ์šฉ

    	> ์ƒ˜ํ”Œ ์‹œ๊ฐ„์„ ์ž˜ ๋ณ€ํ˜•ํ•˜์—ฌ, ํ˜„์ง€ ์‹œ๊ฐ„์— ๋งž๊ฒŒ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค. (ex. ์˜ค์ „ 10:02:17)
  • ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ธฐ๋Šฅ

    	> ํŽ˜์ด์ง€๋„ค์ด์…˜์— ๋Œ€ํ•ด์„œ ์Šค์Šค๋กœ ํ•™์Šตํ•ฉ๋‹ˆ๋‹ค.
    	> ํ•œ ํŽ˜์ด์ง€์— 10๊ฐœ์”ฉ ๋””์Šค์ปค์…˜์ด ๋ณด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    	> ๋‹ค์Œ ํŽ˜์ด์ง€๋กœ ๋„˜์–ด๊ฐˆ ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    	> ์ด์ „ ํŽ˜์ด์ง€๋กœ ๋Œ์•„์˜ฌ ์ˆ˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    	> ๋‹ค์Œ ํŽ˜์ด์ง€๊ฐ€ ์—†๊ฑฐ๋‚˜, ์ด์ „ ํŽ˜์ด์ง€๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ ํŽ˜์ด์ง€๋ฅผ ์œ ์ง€ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋””์Šค์ปค์…˜ ์œ ์ง€ ๊ธฐ๋Šฅ

    	> LocalStorage์— ๋Œ€ํ•ด์„œ ์Šค์Šค๋กœ ํ•™์Šตํ•˜๊ณ , ์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€ํ•˜๋Š” Discussion์ด ํŽ˜์ด์ง€๋ฅผ ์ƒˆ๋กœ๊ณ ์นจํ•ด๋„ ์œ ์ง€๋˜๋„๋ก ์ œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.



โš™๏ธ Setting Code


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My Agora States</title>
    <link rel="stylesheet" href="style.css" />
    <script
      src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/2.3.8/purify.js"
      integrity="sha512-QaF+0tDlqVmwZaQSc0kImgYmw+Cd66TxA5D9X70I5V9BNSqk6yBTbyqw2VEUsVYV5OTbxw8HD9d45on1wvYv7g=="
      crossorigin="anonymous"
      referrerpolicy="no-referrer"
    ></script>
  </head>

  <body>
    <main>
      <h1>My Agora States</h1>
      <section class="form__container">
        <form action="" method="get" class="form">
          <div class="form__input--wrapper">
            <div class="form__input--name">
              <label for="name">Enter your name: </label>
              <input type="text" name="name" id="name" required />
            </div>
            <div class="form__input--title">
              <label for="title">Enter your title: </label>
              <input type="text" name="title" id="title" required />
            </div>
            <div class="form__textbox">
              <label for="story">Your question: </label>
              <textarea
                id="story"
                name="story"
                placeholder="์งˆ๋ฌธ์„ ์ž‘์„ฑํ•˜์„ธ์š”"
                required
              ></textarea>
            </div>
          </div>
          <div class="form__submit">
            <input type="submit" value="submit" />
          </div>
        </form>
      </section>
      <section class="discussion__wrapper">
        <ul class="discussions__container">
          <li class="discussion__container">
            <div class="discussion__avatar--wrapper">
              <img
                class="discussion__avatar--image"
                src="https://avatars.githubusercontent.com/u/12145019?s=64&u=5c97f25ee02d87898457e23c0e61b884241838e3&v=4"
                alt="avatar of kimploo"
              />
            </div>
            <div class="discussion__content">
              <h2 class="discussion__title">
                <a
                  href="https://github.com/codestates-seb/agora-states-fe/discussions/6"
                  >[notice] ์ข‹์€ ์งˆ๋ฌธํ•˜๋Š” ๋ฒ•</a
                >
              </h2>
              <div class="discussion__information">
                kimploo / 2022-04-22T14:08:33Z
              </div>
            </div>
            <div class="discussion__answered"><p>โ˜‘</p></div>
          </li>
        </ul>
      </section>
    </main>
  </body>
  <script src="data.js"></script>
  <script src="script.js"></script>
</html>

// index.html์„ ์—ด์–ด์„œ agoraStatesDiscussions ๋ฐฐ์—ด ์š”์†Œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.
console.log(agoraStatesDiscussions);

// convertToDiscussion์€ ์•„๊ณ ๋ผ ์Šคํ…Œ์ด์ธ  ๋ฐ์ดํ„ฐ๋ฅผ DOM์œผ๋กœ ๋ฐ”๊ฟ”์ค๋‹ˆ๋‹ค.
const convertToDiscussion = (obj) => {
  const li = document.createElement("li"); // li ์š”์†Œ ์ƒ์„ฑ
  li.className = "discussion__container"; // ํด๋ž˜์Šค ์ด๋ฆ„ ์ง€์ •

  const avatarWrapper = document.createElement("div");
  avatarWrapper.className = "discussion__avatar--wrapper";
  const discussionContent = document.createElement("div");
  discussionContent.className = "discussion__content";
  const discussionAnswered = document.createElement("div");
  discussionAnswered.className = "discussion__answered";

  // TODO: ๊ฐ์ฒด ํ•˜๋‚˜์— ๋‹ด๊ธด ์ •๋ณด๋ฅผ DOM์— ์ ์ ˆํžˆ ๋„ฃ์–ด์ฃผ์„ธ์š”.

  li.append(avatarWrapper, discussionContent, discussionAnswered);
  return li;
};

// agoraStatesDiscussions ๋ฐฐ์—ด์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ๋ Œ๋”๋งํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.
const render = (element) => {
  for (let i = 0; i < agoraStatesDiscussions.length; i += 1) {
    element.append(convertToDiscussion(agoraStatesDiscussions[i]));
  }
  return;
};

// ul ์š”์†Œ์— agoraStatesDiscussions ๋ฐฐ์—ด์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ํ™”๋ฉด์— ๋ Œ๋”๋งํ•ฉ๋‹ˆ๋‹ค.
const ul = document.querySelector("ul.discussions__container");
render(ul);
profile
์•„์ด๋””์–ด๊ฐ€ ๋„˜์น˜๋Š” ํ”„๋ก ํŠธ์—”๋“œ๋ฅผ ๊ฟˆ๊ฟ‰๋‹ˆ๋‹ค ๐Ÿ”ฅ

0๊ฐœ์˜ ๋Œ“๊ธ€