-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable conditional styling for the css prop (#242)
- Loading branch information
Showing
9 changed files
with
654 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"next-yak": patch | ||
"yak-swc": patch | ||
--- | ||
|
||
Enable conditional styling for the css prop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
207 changes: 207 additions & 0 deletions
207
packages/yak-swc/yak_swc/tests/fixture/css-prop-conditional/input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
import { css } from "next-yak"; | ||
|
||
const Elem = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
show && | ||
css` | ||
color: red; | ||
`} | ||
`} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem2 = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
show && | ||
css` | ||
color: red; | ||
`} | ||
`} | ||
className="test-class" | ||
/> | ||
); | ||
}; | ||
|
||
const Elem3 = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
style={{ padding: "5px" }} | ||
css={css` | ||
${() => | ||
show && | ||
css` | ||
padding: 10px; | ||
`} | ||
`} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem4 = (props: any) => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
show && | ||
css` | ||
color: green; | ||
`} | ||
`} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem5 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
props.show && | ||
css` | ||
color: purple; | ||
`} | ||
`} | ||
{...props.a} | ||
{...props.b} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem6 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
props.show && | ||
css` | ||
font-size: 16px; | ||
`} | ||
`} | ||
className="main" | ||
style={{ fontWeight: "bold" }} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem7 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
${() => props.show && css``} | ||
`} | ||
className="empty-css" | ||
/> | ||
); | ||
}; | ||
|
||
const Elem8 = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
color: ${() => show && "red"}; | ||
`} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem9 = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
color: ${() => show && "red"}; | ||
`} | ||
className="test-class" | ||
/> | ||
); | ||
}; | ||
|
||
const Elem10 = () => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
style={{ padding: "5px" }} | ||
css={css` | ||
padding: ${() => show && "10px"}; | ||
`} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem11 = (props: any) => { | ||
const show = Math.random() > 0.5; | ||
return ( | ||
<div | ||
css={css` | ||
color: ${() => show && "green"}; | ||
`} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem12 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
color: ${() => props.show && "purple"}; | ||
`} | ||
{...props.a} | ||
{...props.b} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem13 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
font-size: ${() => props.show && "16px"}; | ||
`} | ||
className="main" | ||
style={{ fontWeight: "bold" }} | ||
/> | ||
); | ||
}; | ||
|
||
const Elem14 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
display: ${() => props.show && "block"}; | ||
`} | ||
className="empty-css" | ||
/> | ||
); | ||
}; | ||
|
||
const Elem15 = (props: any) => { | ||
return ( | ||
<div | ||
css={css` | ||
${() => | ||
props.a && | ||
css` | ||
${() => | ||
props.b && | ||
css` | ||
color: ${() => props.c && "orange"}; | ||
`} | ||
`} | ||
`} | ||
/> | ||
); | ||
}; |
Oops, something went wrong.