Skip to content

Commit a64e7a6

Browse files
committed
Fix toString on backgroundSize
1 parent 399bb49 commit a64e7a6

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

e2e/melange/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"jsdom": "^21.1.0",
1313
"react": "^18.2.0",
1414
"react-dom": "^18.2.0",
15-
1615
"webpack": "^5.73.0",
1716
"webpack-cli": "^4.9.2",
1817
"webpack-dev-server": "^4.9.1"

e2e/melange/src/ui/ui.re

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ let container = [%cx
8989
];
9090

9191
module App = {
92+
let blockDefaultBackground = [%cx
93+
{|
94+
background-size: 20px 20px;
95+
background-position: 0 0, 10px 0, 10px -10px, 0 10px;
96+
|}
97+
];
98+
9299
[@react.component]
93100
let make = () =>
94-
<>
101+
<main className=blockDefaultBackground>
95102
<div className=post>
96103
<div className={card ++ " " ++ container}>
97104
<h2> {React.string("Card title")} </h2>
@@ -102,7 +109,7 @@ module App = {
102109
<div className=clx> {React.string("code everywhere!")} </div>
103110
<div className=selectors> {React.string("Red text")} </div>
104111
</Cositas>
105-
</>;
112+
</main>;
106113
};
107114

108115
let color = `hex("333");

packages/ppx/test/css-support/backgrounds-and-borders-module.t/input.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module Color = {
4545
[%css {|background-size: 10px auto|}];
4646
[%css {|background-size: auto 10%|}];
4747
[%css {|background-size: 50em 50%|}];
48+
[%css {|background-size: 20px 20px|}];
4849
/* [%css {|background: url(foo.png), url(bar.svg)|}]; */
4950
[%css {|background: top left / 50% 60%|}];
5051
[%css {|background: border-box|}];

packages/ppx/test/css-support/backgrounds-and-borders-module.t/run.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ If this test fail means that the module is not in sync with the ppx
6161
CSS.backgroundSize(`size((`pxFloat(10.), `auto)));
6262
CSS.backgroundSize(`size((`auto, `percent(10.))));
6363
CSS.backgroundSize(`size((`em(50.), `percent(50.))));
64+
CSS.backgroundSize(`size((`pxFloat(20.), `pxFloat(20.))));
6465

6566
CSS.backgroundPosition(`hvOffset((`left, `top)));
6667
CSS.backgroundOrigin(`borderBox);

packages/runtime/native/shared/Css_types.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3653,9 +3653,14 @@ module BackgroundSize = struct
36533653
let size (x : [ Length.t | Auto.t ]) (y : [ Length.t | Auto.t ]) =
36543654
`size (x, y)
36553655

3656-
let rec toString (x : t) =
3656+
let size_to_string (x : [ Length.t | Auto.t ]) =
3657+
match x with
3658+
| #Length.t as l -> Length.toString l
3659+
| #Auto.t -> Auto.toString
3660+
3661+
let toString (x : t) =
36573662
match x with
3658-
| `size (x, y) -> (toString (x :> t) ^ {js| |js}) ^ toString (y :> t)
3663+
| `size (x, y) -> size_to_string x ^ {js| |js} ^ size_to_string y
36593664
| `cover -> {js|cover|js}
36603665
| `contain -> {js|contain|js}
36613666
| #Length.t -> Auto.toString

0 commit comments

Comments
 (0)