Skip to content

๐ŸŽจ ์ฝ”๋“œ ์ปจ๋ฒค์…˜

YUNAH edited this page Aug 2, 2024 · 1 revision

์ฝ”๋“œ ์ปจ๋ฒค์…˜์€ ๊ธฐ๋ณธ์ ์œผ๋กœ Airbnb JavaScript ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ๋ฅผ ๋”ฐ๋ฅธ๋‹ค.


๋ฆฌ์•กํŠธ

ํ•จ์ˆ˜ ์„ ์–ธ

  • ์ปดํฌ๋„ŒํŠธ๋ฅผ ํฌํ•จํ•œ ๋ชจ๋“  ํ•จ์ˆ˜๋Š”ย ํ™”์‚ดํ‘œ ํ•จ์ˆ˜ ๋กœ ์„ ์–ธํ•œ๋‹ค.

ํƒ€์ž…

  • ํƒ€์ž…์€ interface ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
  • Union type ์˜ ๊ฐ ํ•ญ๋ชฉ์€ UPPER_CASE๋กœ ์ž‘์„ฑํ•œ๋‹ค.
    • ๋‹จ, CSS์™€ ๊ด€๋ จ๋œ Union type ์€ camelCase ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
  • ์œ ๋‹ˆ์˜จ ํƒ€์ž…์˜ ๊ฒฝ์šฐ์—๋Š” type ์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
  • ๋งค๊ฐœ๋ณ€์ˆ˜ ํƒ€์ž…์˜ ๊ฒฝ์šฐ์—๋Š” -Props ๋กœ ๋๋‚˜๋„๋ก ๋„ค์ด๋ฐํ•œ๋‹ค.
  • API ๊ด€๋ จ ํƒ€์ž…์˜ ๊ฒฝ์šฐ์—๋Š” ์ƒํ™ฉ์— ๋”ฐ๋ผ -Request / -Response ๋กœ ๋๋‚˜๋„๋ก ๋„ค์ด๋ฐํ•œ๋‹ค.

ํด๋” ๊ตฌ์กฐ

  • ์ฒ˜์Œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ๋Š” Excalidraw ํˆด๋กœ ์ปดํฌ๋„ŒํŠธ ๊ตฌ์กฐ๋ฅผ ํ™•์ •ํ•˜๊ณ  ์‹œ์ž‘ํ•œ๋‹ค.
  • ํด๋” ์ด๋ฆ„์€ ๋ณต์ˆ˜ ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
  • ํด๋” ๊ตฌ์กฐ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ํŽ˜์ด์ง€ ํด๋” ๊ตฌ์กฐ๋ฅผ ๋”ฐ๋ฅธ๋‹ค.
    • Main ํŽ˜์ด์ง€ ์•ˆ์— ์ข…์†๋œ ์ปดํฌ๋„ŒํŠธ โ†’ components/Main
    • Main ํŽ˜์ด์ง€ ์•ˆ์— ์ข…์†๋œ ์ปค์Šคํ…€ โ†’ hooks/Main
  • ๋กœ์ง ํŒŒ์ผ๊ณผ ์Šคํƒ€์ผ ํŒŒ์ผ์€ ๊ตฌ๋ถ„ํ•ด์„œ ์ž‘์„ฑํ•œ๋‹ค.

์ƒ์ˆ˜ํ™”

  • HTML ํƒœ๊ทธ์— ๋“ค์–ด๊ฐ€๋Š” ๋ฌธ์ž์—ด์˜ ๊ฒฝ์šฐ ๊ณตํ†ต์ ์œผ๋กœ ์ž์ฃผ ์“ฐ์ด๋Š” ๊ฒƒ๋“ค์„ ์ œ์™ธํ•˜๋ฉด ์ƒ์ˆ˜ํ™”ํ•˜์ง€ ์•Š๋Š”๋‹ค.
    • ex) ๋ฒ„ํŠผ ๋ผ๋ฒจ (ํ™•์ธ, ์ด์ „ ๋“ฑ)
  • ํŒŒ์ผ ๋‚ด์—์„œ๋งŒ ์‚ฌ์šฉ๋˜๊ณ , ์ƒ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ 5๊ฐœ ๋ฏธ๋งŒ์ด๋ฉด ํŒŒ์ผ์˜ ์ œ์ผ ์ƒ๋‹จ์— ์„ ์–ธํ•˜๊ณ  ๋”ฐ๋กœ ๋ถ„๋ฆฌํ•˜์ง€ ์•Š๋Š”๋‹ค.

๋„ค์ด๋ฐ

  • ๋ชจ๋“  ๋„ค์ด๋ฐ์€ ์ถ•์•ฝํ•˜์ง€ ์•Š๋Š”๋‹ค.
  • ๋ณต์ˆ˜ํ˜•์˜ ๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์œผ๋กœ -s ๋ฅผ ์‚ฌ์šฉํ•˜๋‚˜, ๋‹จ์–ด๊ฐ€ s ๋กœ ๋๋‚˜๊ฑฐ๋‚˜, ๋ณต์ˆ˜ํ˜•์ด ์—†๋Š” ๊ฒฝ์šฐ์—๋Š” -List ๋ฅผ ๋ถ™์ธ๋‹ค.

๋ณ€์ˆ˜๋ช…, ํ•จ์ˆ˜๋ช…

  • camelCase

์ƒ์ˆ˜

  • UPPER_CASE
  • ๊ฐ์ฒด์ธ ์ƒ์ˆ˜์—ฌ๋„ ๋ชจ๋“  ์š”์†Œ๋ฅผ UPPER_CASE ๋กœ ์ž‘์„ฑํ•œ๋‹ค.

์ปดํฌ๋„ŒํŠธ, ๊ฐ์ฒด, ํด๋ž˜์Šค

  • PascalCase

api

Method Prefix
GET fetch-
POST add-
PUT update-
DELETE delete-

์Šคํƒ€์ผ

ํŒŒ์ผ ๋„ค์ด๋ฐ

import * as S from './example.styles';
<S.Layout></S.Layout>

์ปดํฌ๋„ŒํŠธ ๋„ค์ด๋ฐ

Layout ์ตœ์ƒ์œ„ ๋ ˆ์ด์•„์›ƒ
Container ์—ฌ๋Ÿฌ๊ฐœ์˜ ์š”์†Œ๋ฅผ ๋ฌถ๋Š” ๊ฒฝ์šฐ
Wrapper ํ•˜๋‚˜์˜ ์š”์†Œ๋ฅผ ๋ฌถ๋Š” ๊ฒฝ์šฐ
Box div ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ
List ul ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ
Item li ํƒœ๊ทธ, ๋ฐ˜๋ณต๋˜๋Š” ์š”์†Œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ

Prop ๋„ค์ด๋ฐ

  • ์Šคํƒ€์ผ๋ง์„ ์œ„ํ•œ prop ์€ $- prefix๋ฅผ ๋ถ™์—ฌ์„œ ์‚ฌ์šฉํ•œ๋‹ค.
export const Layout = styled.div<{ $direction: Direction }>`
  display: flex;
  justify-content: ${({ $direction }) => directionMapper[$direction]};
  gap: 1.6rem;
`;

CSS Prop

  • camelCase ๋กœ ์ž‘์„ฑํ•œ๋‹ค.
export const buttonStyle = css`
  width: 9rem;
  height: 2.5rem;
  font-size: ${({ theme }) => theme.fontSize.sm};
`;
<Button css={S.buttonStyle} color="secondary" rounded={true}>
 ๋งํฌ ์ถ”๊ฐ€ํ•˜๊ธฐ
</Button>

ํ…Œ์ŠคํŠธ

  • ์ดˆ๊ธฐ๊ฐ’ ํ…Œ์ŠคํŠธ๋ฅผ ๋ฐ˜๋“œ์‹œ ํฌํ•จํ•œ๋‹ค.
  • ํ…Œ์ŠคํŠธ ๋ช…์„ธ์„œ๋Š” ํ•œ๊ตญ์–ด๋กœ ์ž‘์„ฑํ•˜๊ณ , -ํ•ด์•ผ ํ•œ๋‹ค ๋กœ ๋งˆ๋ฌด๋ฆฌํ•œ๋‹ค.
  • describe - it ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

๐Ÿ€ ์ฝ”๋”ฉํ•ด๋“€์˜ค

์ „์ฒด

์ •๋ณด

BE

FE

๊ธฐ์ˆ 

์ปจ๋ฒค์…˜

ํ…Œ์ŠคํŠธ

์„ฑ๋Šฅ ๊ฐœ์„  & ์ ‘๊ทผ์„ฑ ๊ฐœ์„  ๋ฆฌํฌํŠธ

์ธํ”„๋ผ

Clone this wiki locally