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/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 40 41 42 43 44 45 46 47 48 49 50 51 52 53
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} ;; let delete : t Js.t -> unit = Js.Unsafe.pure_js_expr {js| (function (style_sheet) { document.adoptedStyleSheets = document.adoptedStyleSheets.filter(x => !(x === style_sheet)) }) |js} ;; end type t = Style_sheet.t Js.t let delete_stylesheet = Style_sheet.delete 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) module For_testing = struct let dump_testing_state _ = "constructed-stylesheet-strategy has an opaque state" end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>