Skip to content

Commit

Permalink
Add vertical-align and interpolation safe
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Jul 10, 2023
1 parent 980475c commit bbdb43c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/ppx/src/declarations_to_emotion.re
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,26 @@ let outline_width =
render_line_width_interp,
);

let vertical_align =
apply(
Parser.property_vertical_align,
(~loc) => [%expr CssJs.verticalAlign],
(~loc, value) => {
switch (value) {
| `Baseline => [%expr `baseline]
| `Sub => [%expr `sub]
| `Super => [%expr `super]
| `Text_top => [%expr `textTop]
| `Text_bottom => [%expr `textBottom]
| `Middle => [%expr `middle]
| `Top => [%expr `top]
| `Bottom => [%expr `bottom]
| `Extended_length(l) => render_extended_length(~loc, l)
| `Extended_percentage(p) => render_extended_percentage(~loc, p)
}
}
);

let border =
emit(
Parser.property_border,
Expand Down Expand Up @@ -3340,6 +3360,7 @@ let properties = [
("outline-offset", found(outline_offset)),
("outline-style", found(outline_style)),
("outline-width", found(outline_width)),
("vertical-align", found(vertical_align)),
/* SVG */
("fill", found(fill)),
("stroke", found(stroke)),
Expand Down
8 changes: 8 additions & 0 deletions packages/ppx/test/css-support/css-support.expected.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
CssJs.verticalAlign(`baseline);
CssJs.verticalAlign(`sub);
CssJs.verticalAlign(`super);
CssJs.verticalAlign(`top);
CssJs.verticalAlign(`textTop);
CssJs.verticalAlign(`middle);
CssJs.verticalAlign(`bottom);
CssJs.verticalAlign(`textBottom);
CssJs.backgroundRepeat(`space);
CssJs.backgroundRepeat(`round);
CssJs.backgroundRepeat(`hv((`repeat, `repeat)));
Expand Down
9 changes: 9 additions & 0 deletions packages/ppx/test/css-support/css-support.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[%css {|vertical-align: baseline|}];
[%css {|vertical-align: sub|}];
[%css {|vertical-align: super|}];
[%css {|vertical-align: top|}];
[%css {|vertical-align: text-top|}];
[%css {|vertical-align: middle|}];
[%css {|vertical-align: bottom|}];
[%css {|vertical-align: text-bottom|}];

/* CSS Backgrounds and Borders Module Level 3 */
[%css {|background-repeat: space|}];
[%css {|background-repeat: round|}];
Expand Down

0 comments on commit bbdb43c

Please sign in to comment.