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
ppx_css-v0.16.0.tar.gz
sha256=58a8f237e28c0f223e85552f0f1097c9f7a9682fccee61c593dae32c506926ae
doc/src/ppx_css.inline_css/constructed_stylesheet_strategy.ml.html
Source file constructed_stylesheet_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
open! Core open Js_of_ocaml module Style_sheet = struct class type t = object method replaceSync : Js.js_string Js.t -> unit Js.meth end let t : t Js.t Js.constr Js.Optdef.t = Js.Unsafe.global##._CSSStyleSheet let append : t Js.t -> unit = Js.Unsafe.pure_js_expr {js| (function (style_sheet) { // push doesn't work because this field is really weird. document.adoptedStyleSheets = Array.prototype.concat.apply(document.adoptedStyleSheets, [style_sheet]); }) |js} ;; end type t = Style_sheet.t Js.t let name = "constructed stylesheet" let initialize () = match Js.Optdef.to_option Style_sheet.t with | Some stylesheet_constructor -> (try let style_sheet = new%js stylesheet_constructor in Style_sheet.append style_sheet; Ok style_sheet with | exn -> Or_error.of_exn exn) | None -> Or_error.error_string "window.CSSStyleSheet doesn't exist" ;; let update t content = t##replaceSync (Js.string content)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>