Skip to content

Fix fontWeight binding (make it an abstract type) #776

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

Merged
merged 1 commit into from
Oct 20, 2022
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
3 changes: 3 additions & 0 deletions src/apis/Style.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ function rad(num) {
return num.toString() + "rad";
}

var FontWeight = {};

exports.pct = pct;
exports.deg = deg;
exports.rad = rad;
exports.FontWeight = FontWeight;
/* No side effect */
43 changes: 30 additions & 13 deletions src/apis/Style.res
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,36 @@ type resizeMode = [#cover | #contain | #stretch | #repeat | #center]

type fontStyle = [#normal | #italic]

type fontWeight = [
| #normal
| #bold
| #100
| #200
| #300
| #400
| #500
| #600
| #700
| #800
| #900
]
module FontWeight = {
// Note: we cannot model this as a polymorphic variant
// because #"100" = #100 = the number 100 in JS, but we need the string "100" here.
type t = string

@inline
let normal = "normal"
@inline
let bold = "bold"
@inline
let _100 = "100"
@inline
let _200 = "200"
@inline
let _300 = "300"
@inline
let _400 = "400"
@inline
let _500 = "500"
@inline
let _600 = "600"
@inline
let _700 = "700"
@inline
let _800 = "800"
@inline
let _900 = "900"
}

type fontWeight = FontWeight.t

type fontVariant = [
| #"small-caps"
Expand Down
43 changes: 30 additions & 13 deletions src/apis/Style.resi
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,36 @@ type resizeMode = [#cover | #contain | #stretch | #repeat | #center]

type fontStyle = [#normal | #italic]

type fontWeight = [
| #normal
| #bold
| #100
| #200
| #300
| #400
| #500
| #600
| #700
| #800
| #900
]
module FontWeight: {
// Note: we cannot model this as a polymorphic variant
// because #"100" = #100 = the number 100 in JS, but we need the string "100" here.
type t

@inline("normal")
let normal: t
@inline("bold")
let bold: t
@inline("100")
let _100: t
@inline("200")
let _200: t
@inline("300")
let _300: t
@inline("400")
let _400: t
@inline("500")
let _500: t
@inline("600")
let _600: t
@inline("700")
let _700: t
@inline("800")
let _800: t
@inline("900")
let _900: t
}

type fontWeight = FontWeight.t

type fontVariant = [
| #"small-caps"
Expand Down