Skip to content

Commit 7b7ead0

Browse files
committed
Fix css prop handling in exported components
1 parent acdd292 commit 7b7ead0

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

.changeset/friendly-chefs-heal.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"next-yak": patch
3+
"yak-swc": patch
4+
---
5+
6+
Fix issue with the css prop where it wouldn't be generated when used inside an exported component

packages/yak-swc/yak_swc/src/yak_transforms.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,6 @@ impl YakTransform for TransformCssMixin {
218218
);
219219
}
220220
let css_prefix = match (self.is_exported, self.is_within_jsx_attribute) {
221-
(true, _) => Some(format!(
222-
"YAK EXPORTED MIXIN:{}",
223-
self
224-
.export_name
225-
.as_ref()
226-
.unwrap()
227-
.parts
228-
.iter()
229-
.map(|atom| encode_percent(atom.as_str()))
230-
.join(":")
231-
)),
232221
(_, true) => {
233222
// Add the class name to the arguments, to be created by the CSS loader
234223
arguments.push(
@@ -241,6 +230,17 @@ impl YakTransform for TransformCssMixin {
241230
);
242231
Some("YAK Extracted CSS:".to_string())
243232
}
233+
(true, _) => Some(format!(
234+
"YAK EXPORTED MIXIN:{}",
235+
self
236+
.export_name
237+
.as_ref()
238+
.unwrap()
239+
.parts
240+
.iter()
241+
.map(|atom| encode_percent(atom.as_str()))
242+
.join(":")
243+
)),
244244
_ => None,
245245
};
246246
YakTransformResult {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { css, __yak_mergeCssProp } from "next-yak/internal";
22
import __styleYak from "./input.yak.module.css!=!./input?./input.yak.module.css";
3-
export const YakLogo = ()=><div {.../*YAK EXPORTED MIXIN:YakLogo
3+
export const YakLogo = ()=><div {.../*YAK Extracted CSS:
44
.YakLogo {
55
display: flex;
66
gap: 6px;
77
}
8-
*/ /*#__PURE__*/ css()({})}>
8+
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
99
Yak
1010
</div>;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { css, __yak_mergeCssProp } from "next-yak/internal";
22
import __styleYak from "./input.yak.module.css!=!./input?./input.yak.module.css";
3-
export const YakLogo = ()=><div {.../*YAK EXPORTED MIXIN:YakLogo
3+
export const YakLogo = ()=><div {.../*YAK Extracted CSS:
44
.YakLogo {
55
display: flex;
66
gap: 6px;
77
}
8-
*/ /*#__PURE__*/ css()({})}>
8+
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
99
Yak
1010
</div>;

0 commit comments

Comments
 (0)