Skip to content

Commit

Permalink
Fix css prop handling in exported components
Browse files Browse the repository at this point in the history
  • Loading branch information
Mad-Kat committed Dec 30, 2024
1 parent acdd292 commit 7b7ead0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changeset/friendly-chefs-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"next-yak": patch
"yak-swc": patch
---

Fix issue with the css prop where it wouldn't be generated when used inside an exported component
22 changes: 11 additions & 11 deletions packages/yak-swc/yak_swc/src/yak_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,6 @@ impl YakTransform for TransformCssMixin {
);
}
let css_prefix = match (self.is_exported, self.is_within_jsx_attribute) {
(true, _) => Some(format!(
"YAK EXPORTED MIXIN:{}",
self
.export_name
.as_ref()
.unwrap()
.parts
.iter()
.map(|atom| encode_percent(atom.as_str()))
.join(":")
)),
(_, true) => {
// Add the class name to the arguments, to be created by the CSS loader
arguments.push(
Expand All @@ -241,6 +230,17 @@ impl YakTransform for TransformCssMixin {
);
Some("YAK Extracted CSS:".to_string())
}
(true, _) => Some(format!(
"YAK EXPORTED MIXIN:{}",
self
.export_name
.as_ref()
.unwrap()
.parts
.iter()
.map(|atom| encode_percent(atom.as_str()))
.join(":")
)),
_ => None,
};
YakTransformResult {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { css, __yak_mergeCssProp } from "next-yak/internal";
import __styleYak from "./input.yak.module.css!=!./input?./input.yak.module.css";
export const YakLogo = ()=><div {.../*YAK EXPORTED MIXIN:YakLogo
export const YakLogo = ()=><div {.../*YAK Extracted CSS:
.YakLogo {
display: flex;
gap: 6px;
}
*/ /*#__PURE__*/ css()({})}>
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
Yak
</div>;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { css, __yak_mergeCssProp } from "next-yak/internal";
import __styleYak from "./input.yak.module.css!=!./input?./input.yak.module.css";
export const YakLogo = ()=><div {.../*YAK EXPORTED MIXIN:YakLogo
export const YakLogo = ()=><div {.../*YAK Extracted CSS:
.YakLogo {
display: flex;
gap: 6px;
}
*/ /*#__PURE__*/ css()({})}>
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
Yak
</div>;

0 comments on commit 7b7ead0

Please sign in to comment.