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 issue 443 #462

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 2 additions & 8 deletions packages/css/js/Css_Js_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ let fontSize x =
D
( {js|fontSize|js},
match x with
| #FontSize.t as fs -> FontSize.toString fs
| #Length.t as l -> Length.toString l
| #Var.t as va -> Var.toString va
| #Cascading.t as c -> Cascading.toString c )
Expand Down Expand Up @@ -1972,14 +1973,7 @@ let backgrounds x =
| `none -> {js|none|js})
|. Std.Array.joinWith ~sep:{js|, |js} )

let backgroundSize x =
D
( {js|backgroundSize|js},
match x with
| `size (x, y) -> (Length.toString x ^ {js| |js}) ^ Length.toString y
| `auto -> {js|auto|js}
| `cover -> {js|cover|js}
| `contain -> {js|contain|js} )
let backgroundSize x = D ({js|backgroundSize|js}, BackgroundSize.toString x)

let fontFace ~fontFamily ~src ?fontStyle ?fontWeight ?fontDisplay ?sizeAdjust ()
=
Expand Down
10 changes: 2 additions & 8 deletions packages/css/js/Css_Legacy_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ let fontSize x =
D
( {js|fontSize|js},
match x with
| #FontSize.t as fs -> FontSize.toString fs
| #Length.t as l -> Length.toString l
| #Var.t as va -> Var.toString va
| #Cascading.t as c -> Cascading.toString c )
Expand Down Expand Up @@ -1801,14 +1802,7 @@ let backgrounds x =
| `none -> {js|none|js})
|. Std.List.joinWith ~sep:{js|, |js} )

let backgroundSize x =
D
( {js|backgroundSize|js},
match x with
| `size (x, y) -> Length.toString x ^ {js| |js} ^ Length.toString y
| `auto -> {js|auto|js}
| `cover -> {js|cover|js}
| `contain -> {js|contain|js} )
let backgroundSize x = D ({js|backgroundSize|js}, BackgroundSize.toString x)

let fontFace ~fontFamily ~src ?fontStyle ?fontWeight ?fontDisplay ?sizeAdjust ()
=
Expand Down
10 changes: 2 additions & 8 deletions packages/css/native/Css_Js_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ let fontSize x =
D
( {js|font-size|js},
match x with
| #FontSize.t as fs -> FontSize.toString fs
| #Length.t as l -> Length.toString l
| #Var.t as va -> Var.toString va
| #Cascading.t as c -> Cascading.toString c )
Expand Down Expand Up @@ -1922,14 +1923,7 @@ let backgrounds x =
| `none -> {js|none|js})
|. Std.Array.joinWith ~sep:{js|, |js} )

let backgroundSize x =
D
( {js|background-size|js},
match x with
| `size (x, y) -> (Length.toString x ^ {js| |js}) ^ Length.toString y
| `auto -> {js|auto|js}
| `cover -> {js|cover|js}
| `contain -> {js|contain|js} )
let backgroundSize x = D ({js|background-size|js}, BackgroundSize.toString x)

let fontFace ~fontFamily ~src ?fontStyle ?fontWeight ?fontDisplay ?sizeAdjust ()
=
Expand Down
10 changes: 2 additions & 8 deletions packages/css/native/Css_Legacy_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ let fontSize x =
D
( {js|font-size|js},
match x with
| #FontSize.t as fs -> FontSize.toString fs
| #Length.t as l -> Length.toString l
| #Var.t as va -> Var.toString va
| #Cascading.t as c -> Cascading.toString c )
Expand Down Expand Up @@ -1807,14 +1808,7 @@ let backgrounds x =
| `none -> {js|none|js})
|. Std.List.joinWith ~sep:{js|, |js} )

let backgroundSize x =
D
( {js|background-size|js},
match x with
| `size (x, y) -> Length.toString x ^ {js| |js} ^ Length.toString y
| `auto -> {js|auto|js}
| `cover -> {js|cover|js}
| `contain -> {js|contain|js} )
let backgroundSize x = D ({js|background-size|js}, BackgroundSize.toString x)

let fontFace ~fontFamily ~src ?fontStyle ?fontWeight ?fontDisplay ?sizeAdjust ()
=
Expand Down
87 changes: 87 additions & 0 deletions packages/css/native/shared/Css_AtomicTypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ module Length = struct
| `inch of float
| `pc of float
| `pt of int
| `cap of float
| `ic of float
| `in_ of float
| `lh of float
| `rlh of float
| `vb of float
| `vi of float
| `q of float
| `zero
| `percent of float
]
Expand Down Expand Up @@ -201,6 +209,14 @@ module Length = struct
let pc x = `pc x
let pt x = `pt x
let zero = `zero
let cap x = `cap x
let ic x = `ic x
let in_ x = `in_ x
let lh x = `lh x
let rlh x = `rlh x
let vb x = `vb x
let vi x = `vi x
let q x = `q x

let rec toString x =
match x with
Expand All @@ -222,6 +238,14 @@ module Length = struct
| `zero -> {js|0|js}
| `calc calc -> string_of_calc_min_max calc
| `percent x -> Std.Float.toString x ^ {js|%|js}
| `cap x -> Std.Float.toString x ^ {js|cap|js}
| `ic x -> Std.Float.toString x ^ {js|ic|js}
| `in_ x -> Std.Float.toString x ^ {js|in|js}
| `lh x -> Std.Float.toString x ^ {js|lh|js}
| `rlh x -> Std.Float.toString x ^ {js|rlh|js}
| `vb x -> Std.Float.toString x ^ {js|vb|js}
| `vi x -> Std.Float.toString x ^ {js|vi|js}
| `q x -> Std.Float.toString x ^ {js|q|js}
| (`min _ | `max _) as x -> minmax_to_string x

and calc_value_to_string x =
Expand Down Expand Up @@ -368,6 +392,37 @@ module FontStyle = struct
| `oblique -> {js|oblique|js}
end

module FontSize = struct
type relative_size =
[ `smaller
| `larger
]

type t =
[ relative_size
| `xx_small
| `x_small
| `small
| `medium
| `large
| `x_large
| `xx_large
| `xxx_large
]

let toString = function
| `smaller -> {js|smaller|js}
| `larger -> {js|larger|js}
| `xx_small -> {js|xx-small|js}
| `x_small -> {js|x-small|js}
| `small -> {js|small|js}
| `medium -> {js|medium|js}
| `large -> {js|large|js}
| `x_large -> {js|x-large|js}
| `xx_large -> {js|xx-large|js}
| `xxx_large -> {js|xxx-large|js}
end

module TabSize = struct
type t = [ `num of float ]

Expand Down Expand Up @@ -2078,6 +2133,38 @@ module BackgroundAttachment = struct
| `local -> {js|local|js}
end

module BackgroundSize = struct
type size =
[ `auto
| Length.t
| `size of size * size
]

type t =
[ `cover
| `contain
| size
| Length.t
]

let rec toString = function
| `cover -> {js|cover|js}
| `contain -> {js|contain|js}
| `auto -> {js|auto|js}
| #Length.t as l -> Length.toString l
| `size _ as s -> size_to_string s

and foo = function
| `auto -> {js|auto|js}
| #Length.t as l -> Length.toString l

and size_to_string = function
| `size (x, y) ->
(match x, y with
| `auto, `auto -> {js|auto auto|js}
| l, l2 -> foo l ^ {js| |js} ^ foo l2)
end

module BackgroundClip = struct
type t =
[ `borderBox
Expand Down
61 changes: 61 additions & 0 deletions packages/css/native/shared/Css_AtomicTypes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ module Length : sig
| `pt of int
| `zero
| `percent of float
| `cap of float
| `ic of float
| `in_ of float
| `lh of float
| `rlh of float
| `vb of float
| `vi of float
| `q of float
]

type calc_value =
Expand Down Expand Up @@ -140,6 +148,14 @@ module Length : sig
val pc : 'a -> [> `pc of 'a ]
val pt : 'a -> [> `pt of 'a ]
val zero : [> `zero ]
val cap : 'a -> [> `cap of 'a ]
val ic : 'a -> [> `ic of 'a ]
val in_ : 'a -> [> `in_ of 'a ]
val lh : 'a -> [> `lh of 'a ]
val rlh : 'a -> [> `rlh of 'a ]
val vb : 'a -> [> `vb of 'a ]
val vi : 'a -> [> `vi of 'a ]
val q : 'a -> [> `q of 'a ]
val toString : t -> string
end

Expand Down Expand Up @@ -238,6 +254,27 @@ module FontStyle : sig
val toString : t -> string
end

module FontSize : sig
type relative_size =
[ `smaller
| `larger
]

type t =
[ relative_size
| `xx_small
| `x_small
| `small
| `medium
| `large
| `x_large
| `xx_large
| `xxx_large
]

val toString : t -> string
end

module TabSize : sig
type t = [ `num of float ]

Expand Down Expand Up @@ -1353,6 +1390,30 @@ module BackgroundAttachment : sig
val toString : t -> string
end

module BackgroundSize : sig
type size =
[ `auto
| Length.t
| `size of size * size
]

type t =
[ `cover
| `contain
| size
| Length.t
]

val toString :
[< `auto
| `contain
| `cover
| Length.t
| `size of ([ `auto | Length.t ] as 'a) * 'a
] ->
string
end

module BackgroundClip : sig
type t =
[ `borderBox
Expand Down
Loading
Loading