Skip to content

Commit

Permalink
kebab unsafe properties
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Aug 21, 2023
1 parent ced81e8 commit 85735d1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/css/native/shared/Css_Js_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,21 @@ let transformOrigin3d x y z =
^ {js| |js} )

let transformBox x = D ({js|transform-box|js}, TransformBox.toString x)
let unsafe property value = D (property, value)

let explode s =
let rec exp i l = if i < 0 then l else exp (i - 1) (s.[i] :: l) in
exp (String.length s - 1) []

let camelCaseToKebabCase str =
let insert_dash acc letter =
match letter with
| 'A' .. 'Z' as letter ->
("-" ^ String.make 1 (Char.lowercase_ascii letter)) :: acc
| _ -> String.make 1 letter :: acc
in
String.concat "" (List.rev (List.fold_left insert_dash [] (explode str)))

let unsafe property value = D (camelCaseToKebabCase property, value)

let userSelect x =
D
Expand Down
16 changes: 15 additions & 1 deletion packages/css/native/shared/Css_Legacy_Core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,21 @@ let transformOrigin3d x y z =
^ {js| |js} )

let transformBox x = D ({js|transform-box|js}, TransformBox.toString x)
let unsafe property value = D (property, value)

let explode s =
let rec exp i l = if i < 0 then l else exp (i - 1) (s.[i] :: l) in
exp (String.length s - 1) []

let camelCaseToKebabCase str =
let insert_dash acc letter =
match letter with
| 'A' .. 'Z' as letter ->
("-" ^ String.make 1 (Char.lowercase_ascii letter)) :: acc
| _ -> String.make 1 letter :: acc
in
String.concat "" (List.rev (List.fold_left insert_dash [] (explode str)))

let unsafe property value = D (camelCaseToKebabCase property, value)

let userSelect x =
D
Expand Down

0 comments on commit 85735d1

Please sign in to comment.