Gwangju-Web-Study / WoowahanTS_Study

โœ๏ธ ์šฐ์•„ํ•œ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ with ๋ฆฌ์•กํŠธ ์Šคํ„ฐ๋””
6 stars 2 forks source link

11.1 CSS-in-JS์˜ ๋‹จ์  #43

Closed hyeonseong2023 closed 1 day ago

hyeonseong2023 commented 3 days ago

๐Ÿ“ 328p โ“ CSS-in-JS์˜ ๋‹จ์ ๊ณผ ๋ณด์™„ ๋ฐฉ๋ฒ• ์ฑ…์—์„œ๋Š” CSS-in-JS์˜ ์žฅ์ ๋งŒ์„ ์–˜๊ธฐํ•˜๊ณ  ์žˆ๋Š”๋ฐ, CSS-in-JS์˜ ๋‹จ์ ์ด ์žˆ๋Š”์ง€, ์žˆ๋‹ค๋ฉด ์ด๋ฅผ ๋ณด์™„ํ•  ๋ฐฉ๋ฒ•์€ ๋ฌด์—‡์ด ์žˆ๋Š”์ง€ ์•Œ๊ณ  ์‹ถ์–ด์š”!

gwangminjun commented 2 days ago

CSS-in-JS ๋ฐฉ์‹์˜ ๋‹จ์ 

  1. ๋ฒˆ๋“ค ํฌ๊ธฐ ์ฆ๊ฐ€

    • CSS-in-JS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ž์ฒด๊ฐ€ ๋ฒˆ๋“ค ํฌ๊ธฐ์— ์ถ”๊ฐ€๋ฉ๋‹ˆ๋‹ค.
    • Styled Components, Emotion ๋“ฑ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ์ถ”๊ฐ€์ ์ธ ์ฝ”๋“œ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ์–ด ๋ฒˆ๋“ค ํฌ๊ธฐ๋ฅผ ๋Š˜๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
  2. ๋””๋ฒ„๊น… ๋‚œ์ด๋„ ์ฆ๊ฐ€

    • CSS์™€ JavaScript๊ฐ€ ํ˜ผํ•ฉ๋˜์–ด ์žˆ์–ด ๋””๋ฒ„๊น…์ด ๋” ์–ด๋ ค์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  3. ์„œ๋ฒ„ ์‚ฌ์ด๋“œ ๋ Œ๋”๋ง(SSR) ๋ณต์žก์„ฑ

    • CSS-in-JS์—์„œ๋Š” ์ปดํฌ๋„ŒํŠธ๋ณ„๋กœ ์Šคํƒ€์ผ์ด ์ •์˜๋ฉ๋‹ˆ๋‹ค.
    • ์ด ์Šคํƒ€์ผ ์ •๋ณด๋ฅผ ์„œ๋ฒ„์—์„œ ์ถ”์ถœํ•˜์—ฌ ํด๋ผ์ด์–ธํŠธ์— ์ „๋‹ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • Styled Components๋‚˜ Emotion ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” ์ด๋ฅผ ์œ„ํ•œ API๋ฅผ ์ œ๊ณตํ•˜์ง€๋งŒ, ์ ์ ˆํ•œ ๊ตฌํ˜„์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
fe-Jay commented 2 days ago

CSS-in-JS์˜ ๋‹จ์ 

1. ๋Ÿฐํƒ€์ž„ ์„ฑ๋Šฅ ์ €ํ•˜

2. ์ดˆ๊ธฐ ๋žœ๋”๋ง ์ง€์—ฐ

2. ์ •์  CSS์— ๋น„ํ•ด ๋ณต์žกํ•œ ๋””๋ฒ„๊น…

CSS-in-JS ๋‹จ์ ์˜ ๋ณด์™„ ๋ฐฉ๋ฒ•

1. ์ •์  CSS ์ถ”์ถœ

2. ์ฝ”๋“œ ๋ถ„ํ•  (Code Splitting)

hyeonseong2023 commented 1 day ago

๊ธฐ์กด CSS-in-JS์˜ ๋‹จ์ 

  1. JavaScript๋กœ CSS๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ณผ์ •์—์„œ ์„ฑ๋Šฅ ์ €ํ•˜
  2. ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ ์ธํ•œ ๋ฒˆ๋“ค์‚ฌ์ด์ฆˆ ์ฆ๊ฐ€
  3. ๋Ÿฐํƒ€์ž„์— ํ—ค๋“œ์˜ ๋์— ์Šคํƒ€์ผ์‹œํŠธ๋ฅผ ์‚ฝ์ž…ํ•˜๊ธฐ ๋•Œ๋ฌธ์— SEO์— ๋ถ€์ ํ•ฉ

๋ณด์™„ ๋ฐฉ์‹

Atomic CSS(feat. Tailwind CSS)

CSS-in-JS Atomic CSS
์Šคํƒ€์ผ ์ •์˜ JavaScript ๋‚ด์—์„œ CSS ์ž‘์„ฑ HTML/JSX์—์„œ ๋ฏธ๋ฆฌ ์ •์˜๋œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํด๋ž˜์Šค ์‚ฌ์šฉ
๋Ÿฐํƒ€์ž„ ์˜ค๋ฒ„ํ—ค๋“œ JavaScript ์‹คํ–‰ ์‹œ์ ์—์„œ ์Šคํƒ€์ผ ์ƒ์„ฑ ๋ฐ ์ฃผ์ž… ํ•„์š” ๋นŒ๋“œ ํƒ€์ž„์— ๋ชจ๋“  ์Šคํƒ€์ผ ์ƒ์„ฑ (์ œ๋กœ ๋Ÿฐํƒ€์ž„)
๋ฒˆ๋“ค ํฌ๊ธฐ CSS-in-JS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ž์ฒด์˜ ํฌ๊ธฐ ์ถ”๊ฐ€ ์‚ฌ์šฉ๋œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํด๋ž˜์Šค๋งŒ ํฌํ•จ๋˜์–ด ์ตœ์ ํ™”
์„ฑ๋Šฅ ๋Ÿฐํƒ€์ž„ ๊ณ„์‚ฐ ํ•„์š”
SSR ์‹œ ์ถ”๊ฐ€ ์„ค์ • ํ•„์š”
์ตœ์ ํ™”๋œ ์ •์  CSS ์ƒ์„ฑ
SSR ์นœํ™”์ 
์œ ์ง€๋ณด์ˆ˜ ์ปดํฌ๋„ŒํŠธ๋ณ„ ์Šคํƒ€์ผ ๊ด€๋ฆฌ ์šฉ์ด
์Šคํƒ€์ผ ์ค‘๋ณต ๊ฐ€๋Šฅ์„ฑ ์กด์žฌ
์žฌ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ํด๋ž˜์Šค๋กœ ์ค‘๋ณต ์ตœ์†Œํ™”
๊ธด ํด๋ž˜์Šค๋ช…์œผ๋กœ ์ธํ•œ ๊ฐ€๋…์„ฑ ์ด์Šˆ

์˜ˆ์‹œ ์ฝ”๋“œ

// Tailwind CSS
<button class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600">
  ๋ฒ„ํŠผ
</button>
// ์ˆœ์„œ๋Œ€๋กœ ๋ฐฐ๊ฒฝ์ƒ‰, ํ…์ŠคํŠธ, ํŒจ๋”ฉ, ๋ชจ์„œ๋ฆฌ, ํ˜ธ๋ฒ„