this repo has no description

support external css stylesheet

ArthurW f2a12a2f 997a3bd6

+20 -3
+16 -1
src/cell.ml
··· 84 invalidate_from ~editor; 85 Client.fmt ~id:editor.id editor.worker doc 86 87 - let init ~id worker this = 88 let shadow = Webcomponent.attach_shadow this in 89 90 El.append_children shadow 91 [ El.style [ El.txt @@ Jstr.of_string [%blob "style.css"] ] ]; 92 let run_btn = El.button [ El.txt (Jstr.of_string "Run") ] in 93 El.append_children shadow 94 [ El.div ~at:[ At.class' (Jstr.of_string "run_btn") ] [ run_btn ] ];
··· 84 invalidate_from ~editor; 85 Client.fmt ~id:editor.id editor.worker doc 86 87 + let init ~id ?extra_style worker this = 88 let shadow = Webcomponent.attach_shadow this in 89 90 El.append_children shadow 91 [ El.style [ El.txt @@ Jstr.of_string [%blob "style.css"] ] ]; 92 + (match extra_style with 93 + | None -> () 94 + | Some src_style -> 95 + El.append_children shadow 96 + [ 97 + El.link 98 + ~at: 99 + [ 100 + At.href src_style; 101 + At.rel (Jstr.of_string "stylesheet"); 102 + At.type' (Jstr.of_string "text/css"); 103 + ] 104 + (); 105 + ]); 106 + 107 let run_btn = El.button [ El.txt (Jstr.of_string "Run") ] in 108 El.append_children shadow 109 [ El.div ~at:[ At.class' (Jstr.of_string "run_btn") ] [ run_btn ] ];
+1 -1
src/cell.mli
··· 1 type t 2 3 - val init : id:int -> Client.t -> Webcomponent.t -> t 4 val id : t -> int 5 val set_source : t -> string -> unit 6 val add_message : t -> int -> X_protocol.output list -> unit
··· 1 type t 2 3 + val init : id:int -> ?extra_style:Jstr.t -> Client.t -> Webcomponent.t -> t 4 val id : t -> int 5 val set_source : t -> string -> unit 6 val add_message : t -> int -> X_protocol.output list -> unit
+3 -1
src/x_ocaml.ml
··· 32 | None -> Jstr.of_string "x-ocaml" 33 | Some name -> name 34 35 let _ = 36 Webcomponent.define elt_name @@ fun this -> 37 let prev = match !all with [] -> None | e :: _ -> Some e in 38 let id = List.length !all in 39 - let editor = Cell.init ~id worker this in 40 all := editor :: !all; 41 Cell.set_prev ~prev editor; 42 ()
··· 32 | None -> Jstr.of_string "x-ocaml" 33 | Some name -> name 34 35 + let extra_style = current_attribute "src-style" 36 + 37 let _ = 38 Webcomponent.define elt_name @@ fun this -> 39 let prev = match !all with [] -> None | e :: _ -> Some e in 40 let id = List.length !all in 41 + let editor = Cell.init ~id ?extra_style worker this in 42 all := editor :: !all; 43 Cell.set_prev ~prev editor; 44 ()