package ppx_css
A ppx that takes in css strings and produces a module for accessing the unique names defined within
Install
Dune Dependency
Authors
Maintainers
Sources
v0.17.0.tar.gz
sha256=e60e31aadd820b131f7f05827f369164564400bd4fd51c199d066abf7e68753f
doc/src/ppx_css.inline_css/style_element_strategy.ml.html
Source file style_element_strategy.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
open! Core open Js_of_ocaml module Make (T : sig val name : string val parent_selector : string end) = struct include T type t = Dom_html.styleElement Js.t let make_style_element () = Dom_html.createStyle Dom_html.document let update t content = t##.innerText := Js.string content let initialize () = let parent = Dom_html.document##querySelector (Js.string parent_selector) in match Js.Opt.to_option parent with | None -> Or_error.error_string (parent_selector ^ " not found in document") | Some parent -> (try let style_element = make_style_element () in ignore (parent##appendChild (style_element :> Dom.node Js.t) : Dom.node Js.t); Ok style_element with | exn -> Or_error.of_exn exn) ;; module For_testing = struct let dump_testing_state _ = [%string "%{T.name} has an opauque testing state"] end end module Into_head = Make (struct let name = "<style> element inside <head> element" let parent_selector = "head" end) module Into_body = Make (struct let name = "<style> element inside <body> element" let parent_selector = "body" end) module Into_root_element = Make (struct let name = "any element inside the document" let parent_selector = "*" end)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>