Skip to content

Commit

Permalink
feat(MakeProps): add sub-modules in MakeProps for handle object-fit, …
Browse files Browse the repository at this point in the history
…noOfLines, viewBox, and multi-type(string-or-number).

sub-modules of MakeProps: StringOrNumber, ObjectFit, NoOfLines, and ViewBox
  • Loading branch information
r17x committed Jun 28, 2021
1 parent 1703258 commit 51a1924
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/Interfaces/Chakra__MakeProps.res
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,16 @@ module Top = {
let fromOption = o => o->optionMap(identity)
}

module Sizes = {
open Chakra__AtomicTypes
let rec identity = x =>
switch x {
| #...Sizes.t as cs => cs->Sizes.toString->Identity.fromString
| #array(arr) => arr->arrayMap(identity)->Identity.fromArray
}
let fromOption = o => o->optionMap(identity)
}

module Right = Top
module Bottom = Top
module Left = Top
Expand Down Expand Up @@ -970,6 +980,55 @@ module Stat = {
let fromOption = o => o->optionMap(identity)
}
}
/**
this is module for handle 2 type between [string] or [number]
*/
module StringOrNumber = {
type t = [#str(string) | #num(float)]
let identity = x =>
switch x {
| #str(str) => str->Identity.fromString
| #num(num) => num->Identity.fromFloat
}
let fromOption = o => o->optionMap(identity)
}
/**
Object fit module
*/
module ObjectFit = {
open Chakra__AtomicTypes
let rec identity = x => {
switch x {
| #...ObjectFit.t as o => o->ObjectFit.toString->Identity.fromString
| #array(arr) => arr->arrayMap(identity)->Identity.fromArray
}
}
let fromOption = o => o->optionMap(identity)
}

module NoOfLines = {
@ocaml.text("It could be simply when [@unwrap] can use in [JavaScript] Object.")
let identity = x =>
switch x {
| #num(i) => i->Identity.fromInt
| #array(arr) => arr->Identity.fromArray
}
let fromOption = o => o->optionMap(identity)
}

module ViewBox = {
type t = [#viewBox(float, float, float, float)]
let identity = x =>
switch x {
| #viewBox(a, b, c, d) =>
let a = a->Js.Float.toString
let b = b->Js.Float.toString
let c = c->Js.Float.toString
let d = d->Js.Float.toString
`${a} ${b} ${c} ${d}`
}
let fromOption = o => o->optionMap(identity)
}

include Chakra__Theme

Expand Down

0 comments on commit 51a1924

Please sign in to comment.