GithubHelp home page GithubHelp logo

yhj96 / dogram Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14.63 MB

๐Ÿ• ์ธ์Šคํƒ€๊ทธ๋žจ ๋””์ž์ธ์œผ๋กœ ๊ฐ•์•„์ง€ ์‚ฌ์ง„์„ ์ถœ๋ ฅํ•˜๋Š” ์›น

Home Page: https://dogram-yhj96.netlify.app

HTML 3.27% JavaScript 96.73%

dogram's Introduction

dogram

๐Ÿ“‹ ๊ฐœ์š”

  • CRUD ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“ค์–ด๋ณด๊ธฐ.
  • ์™„์„ฑ๋œ ํŒŒ์ผ์€ ๋ฐฐํฌ ํ™ˆํŽ˜์ด์ง€๋ฅผ ์ œ๊ณตํ•˜์—ฌ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป ๋ฐฐํฌ ํŽ˜์ด์ง€

dogram ๋ฐฐํฌ ํŽ˜์ด์ง€

โœ… ์ฒดํฌ๋ฆฌ์ŠคํŠธ

  • Feed
    • ํ”ผ๋“œ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ
    • ํ”ผ๋“œ ์ด๋ฏธ์ง€ ์ˆ˜์ • ๊ธฐ๋Šฅ
    • ํ”ผ๋“œ ์‚ญ์ œ ๊ธฐ๋Šฅ
  • Comment
    • ๋Œ“๊ธ€ ์ถ”๊ฐ€ ๊ธฐ๋Šฅ
    • ๋Œ“๊ธ€ ์ˆ˜์ • ๊ธฐ๋Šฅ
    • ๋Œ“๊ธ€ ์‚ญ์ œ ๊ธฐ๋Šฅ
  • Like
    • ํ”ผ๋“œ ์ข‹์•„์š” ๊ธฐ๋Šฅ

๐Ÿš€ ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…

1. ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ƒ์„ฑ ์˜ค๋ฅ˜

  • ๋ฌธ์ œ : ์ด๋ฏธ์ง€ ํŒŒ์ผ์ด ํ•œ๊ฐœ์”ฉ ๋ฐ€๋ ค์„œ ๋“ค์–ด๊ฐ€๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒ
// NavBar Component
  const handleOnChange = ({ target }) => {
    const result = [...feedData];
    const file = target.files[0];
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => {
      const item = {
        id: "YHJ96",
        imgURL: reader.result, 
        avatarURL: avatar,
        likeAvatarURL: codestateAvatar,
        likeId: "codestates",
        likeLength: 1,
      };
      result.push(item);
    };
    setFeedData(result);
  };
  • ํ•ด๊ฒฐ : FileReader์˜ onload ๋ฉ”์†Œ๋“œ๋Š” ๋น„๋™๊ธฐ์ ์œผ๋กœ ์ž‘๋™
// NavBar Component
  const handleOnChange = ({ target }) => {
    const result = [...feedData];
    const file = target.files[0];
    const reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = () => {
      const item = {
        id: "YHJ96",
        imgURL: reader.result, 
        avatarURL: avatar,
        likeAvatarURL: codestateAvatar,
        likeId: "codestates",
        likeLength: 1,
      };
      result.push(item);
      setFeedData(result);
    };
  };

2. ํŒŒ์ผ ์„ ํƒ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ๋ฌธ์ œ

  • ๋ฌธ์ œ: ํŒŒ์ผ ์„ ํƒ์„ ์ˆจ๊ธฐ๊ณ  ํ•ด๋‹น ์ด๋ฒคํŠธ๋ฅผ ์ปค์Šคํ…€ ๋ฒ„ํŠผ์œผ๋กœ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ๋ฌธ์ œ ๋ฐœ์ƒ

  • ํ•ด๊ฒฐ: ํŒŒ์ผ ์„ ํƒ input์— ref๋ฅผ ์—ฐ๊ฒฐํ•˜๊ณ  { display: none }์„ ์‚ฌ์šฉํ•˜์—ฌ ์ˆจ๊ฒจ์ค€ ๋‹ค์Œ์— ์ปค์Šคํ…€ ๋ฒ„ํŠผ์— ์ง์ ‘ ref๋ฅผ ์ด์šฉํ•ด์„œ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ

const inputRef = useRef(null);
// ref๋ฅผ ์ด์šฉํ•ด์„œ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ํ•จ์ˆ˜ ์ƒ์„ฑ
const handleOnClickAddItem = () => inputRef.current.click();
// ์ปค์Šคํ…€ ๋ฒ„ํŠผ
<NavIcon src={plus} onClick={handleOnClickAddItem} />
// ํŒŒ์ผ ์„ ํƒ input
<input
  ref={inputRef}
  type={"file"}
  accept="image/*"
  onChange={handleOnChange}
  style={{ display: "none" }}
/>

3. React-Render ๋ฌธ์ œ

  • ๋ฌธ์ œ: Feed์™€ Comment์˜ props๋ฅผ ์ˆ˜์ •ํ•˜๋ฉด ๋ถ€๋ชจ์˜ state๊ฐ€ ๋ณ€๊ฒฝ๋˜์–ด ํ•ด๋‹น ํŽ˜์ด์ง€์˜ state๋ฅผ ๊ณต์œ ํ•˜๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ Comment ์ปดํฌ๋„ŒํŠธ์™€ Recommend ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋žœ๋”๋ง ๋ฌธ์ œ ๋ฐœ์ƒ

  • ํ•ด๊ฒฐ : React.memo()๋ฅผ ์‚ฌ์šฉํ•ด์„œ props ์ƒํƒœ๋ฅผ ๋ฉ”๋ชจ์ด์ œ์ด์…˜

// Recommend Component
export default React.memo(Recommend);
// Comment Component
export default React.memo(Comment);

4. onChange ์ด๋ฒคํŠธ๋กœ ์ธํ•œ render ํ˜ธ์ถœ ๋ฌธ์ œ

  • ๋ฌธ์ œ : Feed์˜ input์˜ ๊ฐ’์˜ ๋”ฐ๋ผ ๊ฒŒ์‹œ ๋ฒ„ํŠผ์˜ disabled ํ™œ์„ฑํ™” ๊ธฐ๋Šฅ์—์„œ ๋ฌธ์ž๋ฅผ ์ž…๋ ฅํ•  ๋•Œ ๋งˆ๋‹ค render ํ˜ธ์ถœ๋กœ ์„ฑ๋Šฅ ์ด์Šˆ

  • ํ•ด๊ฒฐ : ๋””๋ฐ”์šด์Šค ํ•จ์ˆ˜์„ ์ƒ์„ฑํ•ด์„œ 0.2์ดˆ ๊ฐ„๊ฒฉ์œผ๋กœ ์ด๋ฒคํŠธ ๋ฐœ์ƒ์œผ๋กœ ์ตœ์ ํ™”

// utils/debounce.js
export const debounce = (callback, delay) => {
  let timer;
  return (...args) => {
    clearTimeout(timer);
    timer = setTimeout(() => callback(...args), delay);
  }
};
// Feed Component
const handleOnChangeCommentInput = (e) => setInputValue(e.target.value);
const debounceOnChange = debounce(handleOnChangeCommentInput, 200);

๐Ÿ™Œ Git Commit Message

ํƒœ๊ทธ์ด๋ฆ„ ์„ค๋ช…
feat ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ์ถ”๊ฐ€
fix ๋ฒ„๊ทธ ์ˆ˜์ •
design CSS ๋“ฑ ์‚ฌ์šฉ์ž UI ์ˆ˜์ •
style ์ฝ”๋“œ ํฌ๋งท ๋ณ€๊ฒฝ, ์„ธ๋ฏธ ์ฝœ๋ก  ๋ˆ„๋ฝ, ์ฝ”๋“œ ์ˆ˜์ •์ด ์—†๋Š” ๊ฒฝ์šฐ
refactor ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง
comment ์ฃผ์„ ์ถ”๊ฐ€ ๋ฐ ๋ณ€๊ฒฝ
docs ๋ฌธ์„œ ์ˆ˜์ • (MD ํŒŒ์ผ)
chore ๋นŒ๋“œ ํ…Œ์ŠคํŠธ, ํŒจํ‚ค์ง€ ๋งค๋‹ˆ์ € ์„ค์ •
rename ํŒŒ์ผ ํ˜น์€ ํด๋”๋ช… ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ์˜ฎ๊ธฐ๋Š” ์ž‘์—…
remove ํŒŒ์ผ์„ ์‚ญ์ œํ•˜๋Š” ์ž‘์—…๋งŒ ํ•˜๋Š” ๊ฒฝ์šฐ
change ๋ฌธ์ž๋งŒ ๋ณ€๊ฒฝํ•œ ๊ฒฝ์šฐ

dogram's People

Contributors

yhj96 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.