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/inline_css_dynamic.ml.html
Source file inline_css_dynamic.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 54
open! Core open Virtual_dom module Input = struct type t = string [@@deriving sexp_of, equal] let combine = ( ^ ) end module State = struct type t = Constructed_stylesheet_strategy.t Or_error.t let iter (t : t) ~f = match t with | Error error -> print_s [%message "Error while attempting to create CSSStyleSheet. Styles may not load." (error : Error.t)] | Ok stylesheet -> f stylesheet ;; end module S = struct module Input = Input module State = State let init string _element = let state = Constructed_stylesheet_strategy.initialize () in State.iter state ~f:(fun stylesheet -> Constructed_stylesheet_strategy.update stylesheet string); state ;; let on_mount = `Do_nothing let update ~old_input ~new_input state _element = if phys_equal old_input new_input || Input.equal old_input new_input then ( (* do nothing if the inputs don't change *) ) else State.iter state ~f:(fun stylesheet -> Constructed_stylesheet_strategy.update stylesheet new_input) ;; let destroy _input state _element = State.iter state ~f:(fun stylesheet -> Constructed_stylesheet_strategy.update stylesheet ""; Constructed_stylesheet_strategy.delete_stylesheet stylesheet) ;; end module Hook = Vdom.Attr.Hooks.Make (S) let attr s = Vdom.Attr.create_hook "inline-css-dynamic" (Hook.create s)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>