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

Cleanup grid properties #502

Merged
merged 2 commits into from
Aug 12, 2024
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
26 changes: 15 additions & 11 deletions packages/ppx/src/Property_to_runtime.re
Original file line number Diff line number Diff line change
Expand Up @@ -3692,7 +3692,7 @@ let render_line_names = (~loc, value: Types.line_names) => {
line_names
|> String.concat(" ")
|> Printf.sprintf("[%s]")
|> (name => [[%expr `name([%e render_string(~loc, name)])]]);
|> (name => [[%expr `lineNames([%e render_string(~loc, name)])]]);
};

let render_maybe_line_names = (~loc, value) => {
Expand Down Expand Up @@ -3899,13 +3899,15 @@ let grid_template_columns =
(~loc) => [%expr CSS.gridTemplateColumns],
(~loc, value: Types.property_grid_template_columns) =>
switch (value) {
| `None => [%expr [|`none|]]
| `Interpolation(v) => render_variable(~loc, v)
| `None => [%expr `none]
| `Track_list(track_list, line_names) =>
render_track_list(~loc, track_list, line_names)
| `Auto_track_list(list) => render_auto_track_list(~loc, list)
| `Static((), None) => [%expr [|`subgrid|]]
| `Static((), Some(subgrid)) => render_subgrid(~loc, subgrid)
[%expr `value([%e render_track_list(~loc, track_list, line_names)])]
| `Auto_track_list(list) =>
[%expr `value([%e render_auto_track_list(~loc, list)])]
| `Static((), None) => [%expr `value([|`subgrid|])]
| `Static((), Some(subgrid)) =>
[%expr `value([%e render_subgrid(~loc, subgrid)])]
},
);

Expand All @@ -3915,13 +3917,15 @@ let grid_template_rows =
(~loc) => [%expr CSS.gridTemplateRows],
(~loc, value: Types.property_grid_template_rows) =>
switch (value) {
| `None => [%expr [|`none|]]
| `Interpolation(v) => render_variable(~loc, v)
| `None => [%expr `none]
| `Track_list(track_list, line_names) =>
render_track_list(~loc, track_list, line_names)
| `Auto_track_list(list) => render_auto_track_list(~loc, list)
| `Static((), None) => [%expr [|`subgrid|]]
| `Static((), Some(subgrid)) => render_subgrid(~loc, subgrid)
[%expr `value([%e render_track_list(~loc, track_list, line_names)])]
| `Auto_track_list(list) =>
[%expr `value([%e render_auto_track_list(~loc, list)])]
| `Static((), None) => [%expr `value([|`subgrid|])]
| `Static((), Some(subgrid)) =>
[%expr `value([%e render_subgrid(~loc, subgrid)])]
},
);

Expand Down
25 changes: 13 additions & 12 deletions packages/ppx/test/css-support/grid-layout-module.t/input.re
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@
[%css
{|grid-template-columns: [linename1 linename2] 100px repeat(auto-fit, [linename1] 300px) [linename3]; |}
];
let value = [|
`repeat((
`num(4),
[|
`pxFloat(10.),
`name({js|[col-start]|js}),
`pxFloat(250.),
`name({js|[col-end]|js}),
|],
)),
`pxFloat(10.),
|];
let value =
`value([|
`repeat((
`num(4),
[|
`pxFloat(10.),
`lineNames({js|[col-start]|js}),
`pxFloat(250.),
`lineNames({js|[col-end]|js}),
|],
)),
`pxFloat(10.),
|]);
[%css {|grid-template-columns: $(value)|}];
[%css {|grid-template-rows: none|}];
[%css {|grid-template-rows: auto|}];
Expand Down
Loading
Loading