Skip to content

Commit c47c822

Browse files
committed
release 0.3
1 parent 49ae96e commit c47c822

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3299
-1055
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let counter () =
4141
4242
let () =
4343
match Dom.Document.get_element_by_id "root" with
44-
| Some root -> Html.render root (counter ())
44+
| Some root -> Html.mount root (counter ())
4545
| None -> failwith "No #root element found"
4646
```
4747

TODO.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,63 @@
77
- [ ] Add Js.String module.
88
- [ ] Repeated attribute.
99
- [ ] View.toggle : on:('a signal -> bool) -> 'a signal -> attr -> attr
10-
- [ ] Html.Attr.join
10+
- [ ] Html.Attr.join
11+
- [ ] Html: append/insert have different insertion orders...
12+
- [ ] Signal.pair sync/transaction - prevent updates when both are firing sequentially. In the router this currently triggers a double work if both wars are needed as in /a/:int/:string for fetching. We need to sync/step emitting to the route var/args signals and emits should trigger only one pub to subs.
13+
- [ ] Add ?equal to Helix.show.
14+
- [ ] Rationale for using ppx: value restriction for route/path combinators.
15+
- [ ] When rendering links, should each link have vars as signals or is better to render N links at once from a single show?
16+
- [ ] Consider representing the path vars with Hmap to allow any view to obtain a typed signal var.
17+
- [ ] Do signals need to be resource aware and clean up subs on exn?
18+
- [ ] `Signal.sync s1 s2` to fully sync two signals?
19+
- [ ] When emitting to a routing var signal should we navigate?
20+
- [x] Is it worth adding `let$`? `let ( let$ ) s f = Helix.show (fun x -> f x) s`.
21+
- [ ] Should there be a way to create lazy signals? E.g. Mouse.position should only bind mouse events when someone is subbed.
22+
- [ ] Add prevent default handling to Html.on.
23+
- [ ] Check if Router.link ~absolute:true sets the active attr with a relative router.
24+
- [ ] Var from routes with spaces are not %-decoded when emited to signals.
25+
- [ ] Consider passing `path` instead of `rotuer`. This makes it easier to manage relative links.
26+
- Define base path ops for router paths (with prefix/rest).
27+
- [ ] Consider making Router.link relative by default to avoid having to pass router for absolute routes. Instead expose ~relative:router.
28+
- [ ] Repurpose Jx to a JS FFI module.
29+
- [ ] Http.get ~url
30+
- [ ] BUG? Sharing html references leads to problems (See shared_ref)
31+
32+
33+
## shared_ref
34+
35+
```
36+
37+
38+
let format_options_scalar_html =
39+
List.map
40+
(fun v -> Html.option [ Html.value v ] [ Html.text v ])
41+
[ "Int"; "Float"; "String"; "Binary"; "Enum" ]
42+
43+
44+
let render_format (format : Api_types.Format.t) =
45+
let open Html in
46+
let selected_sig = Signal.make format in
47+
Ui.column ~gap:`sm div []
48+
[
49+
Ui.row ~gap:`sm div []
50+
[
51+
Ui.flex (Ui.label "Type") []
52+
[
53+
Ui.select
54+
[ (*value (Dev_attr_fmt.name format);
55+
on Event.change (fun ev ->
56+
let value = Node.get_value (Event.target ev) in
57+
let new_format = default_format_of_string value |> or_invalid_arg value in
58+
Signal.emit new_format selected_sig
59+
);*) ]
60+
format_options_all_html;
61+
];
62+
...
63+
```
64+
65+
This leads to:
66+
67+
```
68+
Fatal error: exception Failure("bug: attempting to remove a text node without a parent: Int")
69+
```

default.nix

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22

33
let
44
onix = import (builtins.fetchGit {
5-
url = "https://github.com/odis-labs/onix.git";
6-
rev = "a5de90d3437848d048ed73b7e9aa18fb57702ae7";
5+
url = "https://github.com/rizo/onix.git";
6+
rev = "8d3ed79ae8875587a2bdcb9d3cbb445fcfbbf5ce";
77
}) { inherit pkgs; verbosity = "warning"; };
88

99
in onix.env {
1010
path = ./.;
11-
env-file = ./.onix.env;
12-
deps = {
13-
# "stdweb" = ./vendor/stdweb/stdweb.opam;
14-
# "jx" = ./vendor/jx/jx.opam;
15-
};
11+
deps = { "ocaml-base-compiler" = "5.1.0"; };
1612
vars = {
1713
with-dev-setup = true;
1814
with-test = true;
1915
with-doc = true;
2016
};
21-
}
17+
}

dune-project

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
(lang dune 3.7)
2-
;(using melange 0.1)
3-
;(using directory-targets 0.1)
2+
43
(implicit_transitive_deps false)

examples/7guis/Index.ml

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
open Helix
22
open Stdweb.Dom
3-
open Signal.Syntax
43

5-
let log = Stdweb.Console.log
64
let ( => ) a b = (a, b)
75
let ( >> ) g f x = f (g x)
86

@@ -22,7 +20,7 @@ let view_counter () =
2220
button
2321
[ on Event.click (fun _ -> Signal.emit (-1) incr) ]
2422
[ text "-" ];
25-
span [ style_list [ "margin-left" => "5px" ] ] [ View.show int count ];
23+
span [ style_list [ "margin-left" => "5px" ] ] [ show int count ];
2624
];
2725
]
2826

@@ -47,16 +45,10 @@ let view_temp_conv () =
4745
[ style_list [ "margin-bottom" => "20px" ] ]
4846
[ text "Bidirectional temperature converter." ];
4947
input
50-
[
51-
View.bind value c_signal;
52-
on Event.input (on_temp_input f_of_c f_signal);
53-
];
48+
[ bind value c_signal; on Event.input (on_temp_input f_of_c f_signal) ];
5449
text " Celsius = ";
5550
input
56-
[
57-
View.bind value f_signal;
58-
on Event.input (on_temp_input c_of_f c_signal);
59-
];
51+
[ bind value f_signal; on Event.input (on_temp_input c_of_f c_signal) ];
6052
text " Fahrenheit";
6153
]
6254

@@ -117,51 +109,44 @@ let view_flight_booker () =
117109
input
118110
[
119111
placeholder "YYYY-MM-DD";
120-
View.bind (fst >> value) dates;
112+
bind (fst >> value) dates;
121113
on Event.input (fun ev ->
122114
Signal.update
123115
(fun (_, d2) -> (Event.target ev |> Node.get_value, d2))
124116
dates
125117
);
126-
View.toggle
127-
~on:(Signal.map (fun (d1, _) -> not (is_valid_date d1)) dates)
128-
(style_list [ "outline" => "1px solid red" ]);
118+
toggle
119+
~on:(fun (d1, _) -> not (is_valid_date d1))
120+
(style_list [ "outline" => "1px solid red" ])
121+
dates;
129122
];
130123
input
131124
[
132125
placeholder "YYYY-MM-DD";
133-
View.bind (snd >> value) dates;
126+
bind (snd >> value) dates;
134127
on Event.input (fun ev ->
135128
Signal.update
136129
(fun (d1, _) -> (d1, Event.target ev |> Node.get_value))
137130
dates
138131
);
139-
View.toggle
140-
~on:(Signal.map (String.equal "oneway") flight_type)
141-
disabled;
142-
View.toggle
143-
~on:
144-
(Signal.map2
145-
(fun (_, d2) ft ->
146-
String.equal "return" ft && not (is_valid_date d2)
147-
)
148-
dates flight_type
149-
)
150-
(style_list [ "outline" => "1px solid red" ]);
132+
toggle ~on:(String.equal "oneway") (disabled true) flight_type;
133+
toggle
134+
~on:(fun ((_, d2), ft) ->
135+
String.equal "return" ft && not (is_valid_date d2)
136+
)
137+
(style_list [ "outline" => "1px solid red" ])
138+
(Signal.pair dates flight_type);
151139
];
152140
button
153141
[
154142
on Event.click click_submit;
155-
View.toggle
156-
~on:
157-
(Signal.map2
158-
(fun dates ft -> not (is_valid_book dates ft))
159-
dates flight_type
160-
)
161-
disabled;
143+
toggle
144+
~on:(fun (dates, ft) -> not (is_valid_book dates ft))
145+
(disabled true)
146+
(Signal.pair dates flight_type);
162147
]
163148
[ text "Book" ];
164-
View.show text msg_signal;
149+
show text msg_signal;
165150
];
166151
]
167152

@@ -228,5 +213,5 @@ let main () =
228213

229214
let () =
230215
match Document.get_element_by_id "root" with
231-
| Some root -> Html.render root (main ())
216+
| Some root -> Html.mount root (main ())
232217
| None -> failwith "No #root element found"

examples/7guis/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(executable
22
(name index)
3-
(libraries helix signal stdweb)
3+
(libraries helix jx.jsoo signal html stdweb)
44
(modes js))
55

66
(alias

examples/demo-jsoo/Demo.ml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let ( => ) a b = (a, b)
88
let view_mouse () =
99
(* Mouse position at 60fps *)
1010
let mouse =
11-
Mouse.position
11+
Mouse.position ()
1212
|> Signal.sample ~on:(Time.tick ~ms:(1000 / 60))
1313
|> Signal.map (fun (x, y) ->
1414
"x = " ^ string_of_float x ^ ", y = " ^ string_of_float y
@@ -23,7 +23,7 @@ let view_mouse () =
2323
div
2424
[ style_list [ "margin-bottom" => "20px" ] ]
2525
[ text "Render mouse position." ];
26-
View.show text mouse;
26+
show text mouse;
2727
]
2828

2929
let view_timer () =
@@ -35,7 +35,7 @@ let view_timer () =
3535
div
3636
[ style_list [ "margin-bottom" => "20px" ] ]
3737
[ text "Render a timer." ];
38-
View.show int timer;
38+
show int timer;
3939
]
4040

4141
let view_input_bind () =
@@ -56,11 +56,9 @@ let view_input_bind () =
5656
];
5757
ul []
5858
[
59-
li [] [ View.show text input_signal ];
59+
li [] [ show text input_signal ];
6060
li []
61-
[
62-
View.show text (input_signal |> Signal.map String.uppercase_ascii);
63-
];
61+
[ show text (input_signal |> Signal.map String.uppercase_ascii) ];
6462
];
6563
]
6664

@@ -80,7 +78,7 @@ let view_counter () =
8078
button
8179
[ on Event.click (fun _ -> Signal.emit (-1) incr) ]
8280
[ text "-" ];
83-
span [ style_list [ "margin-left" => "5px" ] ] [ View.show int count ];
81+
span [ style_list [ "margin-left" => "5px" ] ] [ show int count ];
8482
];
8583
]
8684

@@ -92,7 +90,7 @@ let view_show () =
9290
div
9391
[ style_list [ "margin-bottom" => "20px" ] ]
9492
[ text "Render signal value with function." ];
95-
div [] [ View.show int (Signal.make 5) ];
93+
div [] [ show int (Signal.make 5) ];
9694
]
9795

9896
let view_toggle () =
@@ -109,7 +107,9 @@ let view_toggle () =
109107
[ text "Style/unstyle element!" ];
110108
div
111109
[
112-
View.toggle ~on:stylish (style_list [ "background-color" => "cyan" ]);
110+
toggle ~on:Fun.id
111+
(style_list [ "background-color" => "cyan" ])
112+
stylish;
113113
]
114114
[ text "This element has show attributes!" ];
115115
]
@@ -130,15 +130,15 @@ let view_visibility () =
130130
);
131131
]
132132
[
133-
View.show text
133+
show text
134134
(Signal.map
135135
(fun (editing, text) -> if editing then "Save!" else text)
136136
editing_state
137137
);
138138
];
139139
input
140140
[
141-
View.visible ~on:(Signal.map fst editing_state);
141+
visible ~on:(Signal.map fst editing_state);
142142
style_list [ "margin-left" => "5px" ];
143143
on Event.input (fun ev ->
144144
let target = Event.target ev in
@@ -157,8 +157,8 @@ let view_visibility_simple () =
157157
h2 [ style_list [ "font-family" => "monospace" ] ] [ text "Html.visible" ];
158158
button
159159
[ on Event.click (fun _ -> Signal.update not is_visible) ]
160-
[ View.show text (Signal.map (bool "Hide" "Show") is_visible) ];
161-
span [ View.visible ~on:is_visible ] [ text "HELLO" ];
160+
[ show text (Signal.map (bool "Hide" "Show") is_visible) ];
161+
span [ visible ~on:is_visible ] [ text "HELLO" ];
162162
]
163163

164164
let view_each () =
@@ -182,8 +182,8 @@ let view_each () =
182182
]
183183
[
184184
li [] [ Html.text "fixed li before 1" ];
185-
View.each (fun item -> li [] [ Html.text ("each-1: " ^ item) ]) items;
186-
View.each (fun item -> li [] [ Html.text ("each-2: " ^ item) ]) items;
185+
each (fun item -> li [] [ Html.text ("each-1: " ^ item) ]) items;
186+
each (fun item -> li [] [ Html.text ("each-2: " ^ item) ]) items;
187187
li [] [ Html.text "fixed li after 2" ];
188188
];
189189
]
@@ -207,5 +207,5 @@ let main () =
207207

208208
let () =
209209
match Document.get_element_by_id "root" with
210-
| Some root -> Html.render root (main ())
210+
| Some root -> Html.mount root (main ())
211211
| None -> failwith "No #root element found"

examples/demo-jsoo/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(executable
22
(name demo)
3-
(libraries helix signal stdweb)
3+
(libraries helix signal html jx.jsoo stdweb)
44
(modes js))
55

66
(alias

0 commit comments

Comments
 (0)