How to conditionally apply css in emotion js

Issue #649

Check flag then define css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const Picture = (feature) => {
const shadowCss = feature.shadow ? css`
border-radius: 5px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
` : css``

return (
<div css={css`
width: 40vw;
@media (max-width: 420px) {
width: 98vw;
}
`}>
<div css={shadowCss}>
<img css={css`
max-width: 100%;
height: auto;
`}
src={require(`../apps/${feature.image}`)}
/>
</div>
</div>
)
}

Comments