Skip to content

Commit 1bb5010

Browse files
Jeong-jjblack7375
authored andcommitted
Refactor: restrict rules() to function-style compoundVariants #245
1 parent 8d9ae2a commit 1bb5010

File tree

7 files changed

+431
-299
lines changed

7 files changed

+431
-299
lines changed

.changeset/fresh-rice-sip.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@mincho-js/css": minor
3+
---
4+
5+
**rules - compat**
6+
- Add `recipe` in the compat layer.
7+
- Separate `rules` implementation to `compat-impl.ts` to support compound object variants in `recipe`.

examples/react-babel/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ const Container = styled(BaseComponent, {
3636
},
3737
},
3838
},
39-
compoundVariants: [
39+
compoundVariants: ({ size, color }) => [
4040
{
41-
variants: { size: "small", color: "blue" },
41+
condition: [size.small, color.blue],
4242
style: {
4343
color: "green",
4444
},
4545
},
4646
{
47-
variants: { size: "large", color: "blue" },
47+
condition: [size.large, color.blue],
4848
style: {
4949
color: "yellow",
5050
},

packages/css/src/compat.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export type {
4343
ResolveComplex,
4444
PropDefinitionOutput
4545
} from "./rules/types.js";
46-
export { rules as recipe } from "./rules/index.js";
46+
47+
// Import recipe from compat-impl (supports variants-style compoundVariants)
48+
export { recipe } from "./rules/compat-impl.js";
49+
export type { CompatPatternOptions } from "./rules/compat-impl.js";
4750

4851
export type {
4952
CSSProperties,

packages/css/src/css/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ function cssWith<const T extends CSSRule>(
153153
function cssWithMultiple<
154154
StyleMap extends Record<string | number, RestrictedCSSRule>
155155
>(styleMap: StyleMap, debugId?: string): Record<keyof StyleMap, string> {
156+
// TODO: Use css.with supported data mapping when available
156157
// Transform each value using cssFunction
157158
type TransformedStyleMap = Record<keyof StyleMap, ComplexCSSRule>;
158159
const transformedStyleMap: TransformedStyleMap = {} as TransformedStyleMap;

0 commit comments

Comments
 (0)