Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 17 additions & 16 deletions packages/yak-swc/yak_swc/src/yak_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,19 @@ impl YakTransform for TransformCssMixin {
.into(),
);
}
let css_prefix = match (self.is_exported, self.is_within_jsx_attribute) {
(true, _) => Some(format!(
let css_prefix = if self.is_within_jsx_attribute {
// Add the class name to the arguments, to be created by the CSS loader
arguments.push(
Expr::Member(MemberExpr {
span: DUMMY_SP,
obj: Box::new(Expr::Ident(css_module_identifier.clone())),
prop: create_member_prop_from_string(self.generated_class_name.clone().unwrap()),
})
.into(),
);
Some("YAK Extracted CSS:".to_string())
} else if self.is_exported {
Some(format!(
"YAK EXPORTED MIXIN:{}",
self
.export_name
Expand All @@ -228,21 +239,11 @@ impl YakTransform for TransformCssMixin {
.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(
Expr::Member(MemberExpr {
span: DUMMY_SP,
obj: Box::new(Expr::Ident(css_module_identifier.clone())),
prop: create_member_prop_from_string(self.generated_class_name.clone().unwrap()),
})
.into(),
);
Some("YAK Extracted CSS:".to_string())
}
_ => None,
))
} else {
None
};

YakTransformResult {
css: YakCss {
comment_prefix: css_prefix,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { css } from "next-yak";

export const YakLogo = () => (
<div
css={css`
display: flex;
gap: 6px;
`}
>
Yak
</div>
);
Original file line number Diff line number Diff line change
@@ -0,0 +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 Extracted CSS:
.YakLogo {
display: flex;
gap: 6px;
}
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
Yak
</div>;
Original file line number Diff line number Diff line change
@@ -0,0 +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 Extracted CSS:
.YakLogo {
display: flex;
gap: 6px;
}
*/ /*#__PURE__*/ css(__styleYak.YakLogo)({})}>
Yak
</div>;
Loading