-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve dynamic value error message (#212)
- Loading branch information
Showing
5 changed files
with
82 additions
and
3 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,5 @@ | ||
--- | ||
"yak-swc": patch | ||
--- | ||
|
||
Better error message for wrong usage of dynamic properties in nested template |
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
21 changes: 21 additions & 0 deletions
21
packages/yak-swc/yak_swc/tests/fixture/nested-dynamic-mixin/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,21 @@ | ||
import { styled, css } from "next-yak"; | ||
|
||
// example taken from https://github.com/jantimon/next-yak/issues/208 | ||
|
||
const spacing = "20px"; | ||
|
||
const ContainerFluid = styled.div` | ||
position: relative; | ||
margin: 0 auto; | ||
padding-top: ${spacing}; | ||
max-width: 100%; | ||
${({ $isApp, $pageHeaderHeight }) => | ||
$isApp ? css` | ||
margin-top: unset; | ||
` : css` | ||
margin-top: ${$pageHeaderHeight}px; | ||
`}; | ||
margin-top: ${({ $pageHeaderHeight }) => $pageHeaderHeight}px; | ||
`; |
11 changes: 11 additions & 0 deletions
11
packages/yak-swc/yak_swc/tests/fixture/nested-dynamic-mixin/output.stderr
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,11 @@ | ||
x The shorthand access to the variable "$pageHeaderHeight" is not allowed in a nested expression. | ||
| To be able to use the property turn it into a CSS variable by wrapping it in a function: | ||
| | ||
| ${() => $pageHeaderHeight}; | ||
| | ||
,-[input.js:17:1] | ||
16 | ` : css` | ||
17 | margin-top: ${$pageHeaderHeight}px; | ||
: ^^^^^^^^^^^^^^^^^ | ||
18 | `}; | ||
`---- |
25 changes: 25 additions & 0 deletions
25
packages/yak-swc/yak_swc/tests/fixture/nested-dynamic-mixin/output.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,25 @@ | ||
import { styled, css, __yak_unitPostFix } from "next-yak/internal"; | ||
import __styleYak from "./input.yak.module.css!=!./input?./input.yak.module.css"; | ||
// example taken from https://github.com/jantimon/next-yak/issues/208 | ||
const spacing = "20px"; | ||
const ContainerFluid = /*YAK Extracted CSS: | ||
.ContainerFluid { | ||
position: relative; | ||
margin: 0 auto; | ||
padding-top: 20px; | ||
max-width: 100%; | ||
} | ||
.ContainerFluid__$isApp { | ||
margin-top: unset; | ||
} | ||
.ContainerFluid__not_$isApp { | ||
margin-top: px; | ||
} | ||
.ContainerFluid { | ||
margin-top: var(--ContainerFluid__margin-top_m7uBBu); | ||
} | ||
*/ /*#__PURE__*/ styled.div(__styleYak.ContainerFluid, ({ $isApp, $pageHeaderHeight })=>$isApp ? /*#__PURE__*/ css(__styleYak.ContainerFluid__$isApp) : /*#__PURE__*/ css(__styleYak.ContainerFluid__not_$isApp), { | ||
"style": { | ||
"--ContainerFluid__margin-top_m7uBBu": __yak_unitPostFix(({ $pageHeaderHeight })=>$pageHeaderHeight, "px") | ||
} | ||
}); |