this repo has no description

support for inline css

ArthurW a8a02c59 f2a12a2f

+29 -8
+19 -6
src/cell.ml
··· 84 84 invalidate_from ~editor; 85 85 Client.fmt ~id:editor.id editor.worker doc 86 86 87 - let init ~id ?extra_style worker this = 88 - let shadow = Webcomponent.attach_shadow this in 89 - 87 + let init_css shadow ~extra_style ~inline_style = 90 88 El.append_children shadow 91 - [ El.style [ El.txt @@ Jstr.of_string [%blob "style.css"] ] ]; 92 - (match extra_style with 89 + [ 90 + El.style 91 + (El.txt (Jstr.of_string [%blob "style.css"]) 92 + :: 93 + (match inline_style with 94 + | None -> [] 95 + | Some inline_style -> 96 + [ 97 + El.txt 98 + @@ Jstr.of_string (":host{" ^ Jstr.to_string inline_style ^ "}"); 99 + ])); 100 + ]; 101 + match extra_style with 93 102 | None -> () 94 103 | Some src_style -> 95 104 El.append_children shadow ··· 102 111 At.type' (Jstr.of_string "text/css"); 103 112 ] 104 113 (); 105 - ]); 114 + ] 115 + 116 + let init ~id ?extra_style ?inline_style worker this = 117 + let shadow = Webcomponent.attach_shadow this in 118 + init_css shadow ~extra_style ~inline_style; 106 119 107 120 let run_btn = El.button [ El.txt (Jstr.of_string "Run") ] in 108 121 El.append_children shadow
+8 -1
src/cell.mli
··· 1 1 type t 2 2 3 - val init : id:int -> ?extra_style:Jstr.t -> Client.t -> Webcomponent.t -> t 3 + val init : 4 + id:int -> 5 + ?extra_style:Jstr.t -> 6 + ?inline_style:Jstr.t -> 7 + Client.t -> 8 + Webcomponent.t -> 9 + t 10 + 4 11 val id : t -> int 5 12 val set_source : t -> string -> unit 6 13 val add_message : t -> int -> X_protocol.output list -> unit
+2 -1
src/x_ocaml.ml
··· 33 33 | Some name -> name 34 34 35 35 let extra_style = current_attribute "src-style" 36 + let inline_style = current_attribute "inline-style" 36 37 37 38 let _ = 38 39 Webcomponent.define elt_name @@ fun this -> 39 40 let prev = match !all with [] -> None | e :: _ -> Some e in 40 41 let id = List.length !all in 41 - let editor = Cell.init ~id ?extra_style worker this in 42 + let editor = Cell.init ~id ?extra_style ?inline_style worker this in 42 43 all := editor :: !all; 43 44 Cell.set_prev ~prev editor; 44 45 ()