Gatsby: gatsby-plugin-styled-components์— ๋Œ€ํ•œ ์งˆ๋ฌธ

์— ๋งŒ๋“  2017๋…„ 11์›” 12์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: gatsbyjs/gatsby

์šฐ์„ , GATSBY์˜ ๋ชจ๋“  ๊ธฐ์—ฌ์ž ๋•๋ถ„์— ๋‚˜๋Š” ๊ทธ๊ฒƒ์„ ์‚ฌ๋ž‘ํ•ฉ๋‹ˆ๋‹ค! ๋‚ด ์งˆ๋ฌธ์€ ๋งค์šฐ ๊ฐ„๋‹จํ•˜์ง€๋งŒ ๋‹ต๋ณ€์ด ํฌํ•จ๋œ ๊ฒŒ์‹œ๋ฌผ์„ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

Typography.js๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ gatsby-plugin-styled-components์— ๋Œ€ํ•œ ์ „์—ญ ์Šคํƒ€์ผ์„ ์–ด๋–ป๊ฒŒ ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?
์˜ˆ๋ฅผ ๋“ค์–ด:
๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์–ด๋””์— ์‚ฝ์ž…ํ•ฉ๋‹ˆ๊นŒ?

injectGlobal`
  * { box-sizing: border-box; }
  body { margin: 0; color: #374047}
`

๋ฏธ๋ฆฌ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

question or discussion

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

@dustinhorton ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
index.js ํŒŒ์ผ๋กœ ๋ ˆ์ด์•„์›ƒ ํด๋”๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ๋‹ค์Œ ์ „์—ญ ์Šคํƒ€์ผ์„ ์ฃผ์ž…ํ–ˆ๊ณ  ๋งค๋ ฅ์ฒ˜๋Ÿผ ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค :-)

import React from "react"

import { injectGlobal } from 'styled-components'

injectGlobal`
*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: inherit; }

html {
  font-size: 62.5%; }

body {
  box-sizing: border-box; }

body {
  font-family: "Lato", sans-serif;
  font-weight: 400;
  line-height: 1.7;
  color: #374047; }
`

export default ({children}) =>
 <div>
     {children()}
 </div>

๋ชจ๋“  3 ๋Œ“๊ธ€

๋‚ด๊ฐ€ ์˜คํ•ดํ•˜๊ณ ์žˆ์–ด (์ด ์ง„์ • ์Šคํƒ€์ผ์˜ ๊ตฌ์„ฑ ์š”์†Œ์™€ ๋‹ค๋ฅด๊ฒŒ ์ผ์„ํ•ด์•ผ)ํ•˜์ง€ ์•Š๋Š” ํ•œ, HN ์‚ฌ์ดํŠธ ์˜ˆ๋ฅผ ๋“ค์–ด ์ด ๋‹ฌ์„ฑ ํ•  ์ˆ˜์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค https://github.com/gatsbyjs/gatsby/blob/5a0aac34bc4a509e871f524d8705cb9e0a501ce1/examples/hn/ src/๋ ˆ์ด์•„์›ƒ/default.js#L4

ํŽธ์ง‘: injectGlobal ๊ฐ€ ์Šคํƒ€์ผ์ด ์ง€์ •๋œ ๊ตฌ์„ฑ ์š”์†Œ ๋ฐฉ๋ฒ•์ด๋ผ๋Š” ๊ฒƒ์„ ๊นจ๋‹ซ์ง€ ๋ชปํ–ˆ์ง€๋งŒ @ https://www.styled-components.com/docs/api์—์„œ ๋ณผ ์ˆ˜

@dustinhorton ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.
index.js ํŒŒ์ผ๋กœ ๋ ˆ์ด์•„์›ƒ ํด๋”๋ฅผ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ๋‹ค์Œ ์ „์—ญ ์Šคํƒ€์ผ์„ ์ฃผ์ž…ํ–ˆ๊ณ  ๋งค๋ ฅ์ฒ˜๋Ÿผ ์ž‘๋™ํ–ˆ์Šต๋‹ˆ๋‹ค :-)

import React from "react"

import { injectGlobal } from 'styled-components'

injectGlobal`
*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: inherit; }

html {
  font-size: 62.5%; }

body {
  box-sizing: border-box; }

body {
  font-family: "Lato", sans-serif;
  font-weight: 400;
  line-height: 1.7;
  color: #374047; }
`

export default ({children}) =>
 <div>
     {children()}
 </div>

@ferMartz ์ด ๋ฌธ์ œ๋ฅผ ๋‹ซ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? :)

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰