package quickterface
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Quick-to-program app interfaces in OCaml for terminal and web
Install
dune-project
Dependency
Authors
Maintainers
Sources
quickterface-0.1.0.tbz
sha256=8261e3819564fb5d05f1f313e62b73382152591d7a4349ae5b1b08a4fc2469f3
sha512=e739a971bb0e696ab716c168419c59a3d195922d2d1e4963106a845e3442ffa085b05106f36cceeec9b806bf7d6ef2c31e98db04911fbf73c5ac0ce626449d0f
doc/src/quickterface_web_app_backend/stylesheet.ml.html
Source file stylesheet.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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240open! Core module Style = struct module Entry = struct type t = { name : string; value : string } let to_css_string { name; value } = Printf.sprintf "%s: %s" name value end type t = Style of Entry.t list let to_css_string (Style entries) = String.concat ~sep:";" (List.map entries ~f:Entry.to_css_string) end module Selector_atom = struct type t = Body | Button | Input | Select | Class of Class.t [@@deriving enumerate] let to_css_string = function | Body -> "body" | Button -> "button" | Input -> "input" | Select -> "select" | Class class_ -> Printf.sprintf ".%s" (Class.to_prefixed_string class_) end module Selector = struct type t = { atom : Selector_atom.t; pseudo_class : string option } let of_atom atom = { atom; pseudo_class = None } let to_css_string { atom; pseudo_class } = Printf.sprintf "%s%s" (Selector_atom.to_css_string atom) (Option.value_map pseudo_class ~default:"" ~f:(fun pseudo_class -> Printf.sprintf ":%s" pseudo_class)) end module Entry = struct type t = { selector : Selector.t; style : Style.t } let font_style_entries = Style.Entry. [ { name = "font-size"; value = "16px" }; { name = "font-family"; value = "\"Fira Code\", Menlo, Consolas, monospace"; }; ] let body_style = Style.Style (Style.Entry. [ { name = "background-color"; value = "#0b1d40ff" }; { name = "width"; value = "100vw" }; { name = "height"; value = "100vh" }; { name = "max-width"; value = "100vw" }; { name = "max-height"; value = "100vh" }; { name = "margin"; value = "0" }; { name = "padding-bottom"; value = "env(safe-area-inset-bottom)" }; { name = "overflow-x"; value = "hidden" }; { name = "box-sizing"; value = "border-box" }; { name = "touch-action"; value = "manipulation" }; ] @ font_style_entries) let = Style.Style (Style.Entry. [ { name = "min-height"; value = "50px" }; { name = "margin"; value = "4px 0px" }; { name = "border-width"; value = "0px" }; { name = "border-radius"; value = "4px" }; { name = "padding"; value = "8px 16px" }; { name = "background-color"; value = "#2563eb" }; { name = "cursor"; value = "pointer" }; ] @ font_style_entries) let input_style = Style.Style (Style.Entry. [ { name = "min-height"; value = "35px" }; { name = "margin"; value = "4px 0px" }; { name = "padding"; value = "2px 4px" }; { name = "border-radius"; value = "4px" }; ] @ font_style_entries) let select_style = input_style let class_style = let open Style.Entry in let log_item_style_items = [ { name = "margin"; value = "4px" }; { name = "border-radius"; value = "4px" }; { name = "padding"; value = "2px 6px 2px 6px" }; { name = "overflow-wrap"; value = "break-word" }; { name = "word-break"; value = "break-word" }; ] in function | Class.Main_container -> Style.Style [ { name = "position"; value = "fixed" }; { name = "inset"; value = "0" }; { name = "width"; value = "100%" }; { name = "height"; value = "100%" }; { name = "max-width"; value = "100vw" }; { name = "max-height"; value = "100vh" }; { name = "display"; value = "flex" }; { name = "flex-direction"; value = "column" }; ] | Log_container -> Style [ { name = "height"; value = "100vh" }; { name = "max-width"; value = "100%" }; { name = "display"; value = "flex" }; { name = "flex-direction"; value = "column" }; { name = "overflow-y"; value = "auto" }; { name = "justify-content"; value = "flex-end" }; { name = "color"; value = "#eee" }; { name = "padding"; value = "8px" }; ] | Text_prompt_label -> Style [ { name = "width"; value = "10px" } ] | Log_item -> Style (log_item_style_items @ [ { name = "background-color"; value = "#444" } ]) | Input_container_form -> Style [ { name = "display"; value = "flex" }; { name = "flex-direction"; value = "row" }; { name = "gap"; value = "8px" }; { name = "align-items"; value = "center" }; ] | Input_submit_button -> Style [ { name = "flex"; value = "0 0 auto" }; { name = "padding"; value = "8px 16px" }; { name = "cursor"; value = "pointer" }; ] | Input_multiselect_container -> Style [ { name = "display"; value = "flex" }; { name = "flex-direction"; value = "row" }; { name = "gap"; value = "16px" }; ] | Output_math -> Style [ { name = "padding"; value = "4px 0px" } ] | Progress_bar_item -> Style [ { name = "width"; value = "100%" }; { name = "display"; value = "flex" }; { name = "flex-direction"; value = "row" }; { name = "align-items"; value = "center" }; { name = "gap"; value = "8px" }; ] | Progress_bar_label -> Style [ { name = "flex"; value = "20" }; { name = "font-size"; value = "12px" }; ] | Progress_bar_bar_container -> Style [ { name = "flex"; value = "60" }; { name = "width"; value = "100%" }; { name = "height"; value = "14px" }; { name = "border-radius"; value = "4px" }; { name = "background-color"; value = "#222" }; ] | Progress_bar_bar_fill_in_progress -> Style [ { name = "width"; value = "0%" }; { name = "height"; value = "100%" }; { name = "border-radius"; value = "4px" }; { name = "background-color"; value = "#2196f3" }; ] | Progress_bar_bar_fill_completed -> Style [ { name = "width"; value = "100%" }; { name = "height"; value = "100%" }; { name = "border-radius"; value = "4px" }; { name = "background-color"; value = "#4caf50" }; ] | Progress_bar_progress_label -> Style [ { name = "flex"; value = "20" } ] let selector_atom_style = function | Selector_atom.Body -> body_style | Button -> button_style | Input -> input_style | Select -> select_style | Class c -> class_style c let of_selector_atom selector_atom = { selector = Selector.of_atom selector_atom; style = selector_atom_style selector_atom; } let to_css_string { selector; style } = [%string {|%{Selector.to_css_string selector} { %{Style.to_css_string style} }|}] let custom_entries = List.map ~f:(fun (selector, style) -> { selector; style }) [ ( Selector.{ atom = Button; pseudo_class = Some "disabled" }, Style.Style [ Style.Entry.{ name = "background-color"; value = "#888" } ] ); ] end let css_string = let atom_entries = List.map ~f:(fun selector -> Entry.of_selector_atom selector) Selector_atom.all in let custom_entries = Entry.custom_entries in let all_entries = atom_entries @ custom_entries in List.map all_entries ~f:Entry.to_css_string |> String.concat ~sep:"\n\n"
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>