Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix css prop in exported component #253

Open
wants to merge 2 commits into
base: update-dependencies
Choose a base branch
from
Open
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
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
@@ -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