Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- createElement
- VAR
- 학습법 #집중력
- Append
- input
- Let
- appendChild
- const
- createtextnode
- htmlFor
- FOR
- Openlayers
- boolean
Archives
- Today
- Total
Atomic Habits
React. Part2. ch2. 04. emotion 2 본문
○ styled components vs emotion
- https://github.com/jsjoeio/styled-components-vs-emotion
○ props 전달 css
/** @jsx jsx */
import { jsx, css } from '@emotion/react'
const pinkInput = css`
background-color: pink;
`;
const RedPasswordInput = props => (
<input
type="password"
css={css`
background-color: red;
display: block;
`}
{...props}
/>
)
render(
<div>
<RedPasswordInput placeholder="red" />
<RedPasswordInput placeholder="pink" css={pinkInput} />
</div>
);
MediaQueries - map
/** @jsxImportSource @emotion/react */
import {css} from '@emotion/react'
const breakpoints = [576, 768, 992, 1200]
const mq = breakpoints.map(
bp => `@media (min-width: ${bp}px)`
)
export default function MediaQueriesEx() {
return (
<>
<div>
<div
css={{
color: 'green',
[mq[0]]: {
color: 'gray'
},
[mq[1]]: {
color: 'hotpink'
}
}}
>
Some text!
</div>
<p
css={css`
color: green;
${mq[0]} {
color: gray;
}
${mq[1]} {
color: hotpink;
}
`}
>
Some other text!
</p>
</div>
</>
)
}
'IT > React' 카테고리의 다른 글
[VS CODE] React Code Snippets (0) | 2021.11.14 |
---|---|
[checkAll] ! ! list .length ? boolean ? (0) | 2021.11.14 |
React. Part2. ch2. 03. emotion 1 (0) | 2021.11.12 |
React. Part2. ch2. 02-2. styled-components (0) | 2021.11.11 |
React. Part2. ch2. 02-1. styled-components (0) | 2021.11.10 |
Comments