Current section

9 Versions

Jump to

Compare versions

8 files changed
+653 additions
-659 deletions
  @@ -7,12 +7,6 @@
7 7
8 8 ## Setup
9 9
10 - Sketch focuses on the concept of generating CSS in a performant way. To do it,
11 - Sketch needs to use a cache. The cache allows to avoid repeating unneeded
12 - computations, and ensure consistency across repaints. Because the browser likes
13 - static CSS, using a cache make sure the browser will not undergo unneeded
14 - computations to recompute styles at every repaint.
15 -
16 10 If you're using Lustre (which is strongly recommended), `sketch_lustre` got you.
17 11 `sketch_lustre` exposes one entrypoint, `sketch/lustre`, containing everything
18 12 needed to get started.
  @@ -74,7 +68,7 @@ fn main_style() {
74 68
75 69 fn view(model: Int) {
76 70 html.div(main_style(), [], [
77 - html.div_([], [h.text(int.to_string(model)]),
71 + html.div_([], [h.text(int.to_string(model))]),
78 72 ])
79 73 }
80 74 ```
  @@ -1,5 +1,5 @@
1 1 name = "sketch_lustre"
2 - version = "1.0.0"
2 + version = "1.0.1"
3 3
4 4 description = "A Sketch runtime package, made to work with Lustre!"
5 5 internal_modules = ["sketch/internals", "sketch/internals/*"]
  @@ -1,6 +1,6 @@
1 1 {<<"name">>, <<"sketch_lustre">>}.
2 2 {<<"app">>, <<"sketch_lustre">>}.
3 - {<<"version">>, <<"1.0.0">>}.
3 + {<<"version">>, <<"1.0.1">>}.
4 4 {<<"description">>, <<"A Sketch runtime package, made to work with Lustre!"/utf8>>}.
5 5 {<<"licenses">>, [<<"MIT">>]}.
6 6 {<<"build_tools">>, [<<"gleam">>]}.
  @@ -9,16 +9,6 @@
9 9 {<<"Repository">>, <<"https://github.com/ghivert/sketch">>}
10 10 ]}.
11 11 {<<"requirements">>, [
12 - {<<"plinth">>, [
13 - {<<"app">>, <<"plinth">>},
14 - {<<"optional">>, false},
15 - {<<"requirement">>, <<">= 0.4.9 and < 1.0.0">>}
16 - ]},
17 - {<<"lustre">>, [
18 - {<<"app">>, <<"lustre">>},
19 - {<<"optional">>, false},
20 - {<<"requirement">>, <<">= 4.3.1 and < 5.0.0">>}
21 - ]},
22 12 {<<"gleam_stdlib">>, [
23 13 {<<"app">>, <<"gleam_stdlib">>},
24 14 {<<"optional">>, false},
  @@ -28,6 +18,16 @@
28 18 {<<"app">>, <<"sketch">>},
29 19 {<<"optional">>, false},
30 20 {<<"requirement">>, <<">= 3.0.0 and < 4.0.0">>}
21 + ]},
22 + {<<"plinth">>, [
23 + {<<"app">>, <<"plinth">>},
24 + {<<"optional">>, false},
25 + {<<"requirement">>, <<">= 0.4.9 and < 1.0.0">>}
26 + ]},
27 + {<<"lustre">>, [
28 + {<<"app">>, <<"lustre">>},
29 + {<<"optional">>, false},
30 + {<<"requirement">>, <<">= 4.3.1 and < 5.0.0">>}
31 31 ]}
32 32 ]}.
33 33 {<<"files">>, [
  @@ -163,7 +163,7 @@ pub fn unstyled(cache: Cache, element: Element(msg)) {
163 163 }
164 164
165 165 fn unstyled_children(cache, children) {
166 - list.fold_right(children, #(cache, []), fn(acc, child) {
166 + list.fold(list.reverse(children), #(cache, []), fn(acc, child) {
167 167 let #(cache, children) = acc
168 168 let #(cache, child) = unstyled(cache, child)
169 169 #(cache, [child, ..children])
  @@ -21,15 +21,15 @@ set_stylesheet(Content, Stylesheet) ->
21 21 to_stylesheet(Options) ->
22 22 node_style_sheet.
23 23
24 - -spec root(list(lustre@internals@vdom:element(QIK))) -> lustre@internals@vdom:element(QIK).
24 + -spec root(list(lustre@internals@vdom:element(QIL))) -> lustre@internals@vdom:element(QIL).
25 25 root(Children) ->
26 26 lustre@element@html:'div'([], Children).
27 27
28 28 -spec render_stylesheet(
29 29 binary(),
30 - lustre@internals@vdom:element(QIS),
30 + lustre@internals@vdom:element(QIT),
31 31 style_sheet()
32 - ) -> lustre@internals@vdom:element(QIS).
32 + ) -> lustre@internals@vdom:element(QIT).
33 33 render_stylesheet(Content, Node, Stylesheet) ->
34 34 case Stylesheet of
35 35 node_style_sheet ->
  @@ -49,9 +49,9 @@ render_stylesheet(Content, Node, Stylesheet) ->
49 49
50 50 -spec compose(
51 51 options(),
52 - fun((QHN) -> sketch@lustre@element:element(QHO)),
52 + fun((QHO) -> sketch@lustre@element:element(QHP)),
53 53 sketch:cache()
54 - ) -> fun((QHN) -> lustre@internals@vdom:element(QHO)).
54 + ) -> fun((QHO) -> lustre@internals@vdom:element(QHP)).
55 55 compose(Options, View, Cache) ->
56 56 Cache@1 = sketch@internals@ffi:wrap(Cache),
57 57 Stylesheet = to_stylesheet(Options),
  @@ -83,7 +83,7 @@ contains_head(El) ->
83 83 false
84 84 end.
85 85
86 - -spec put_in_head(lustre@internals@vdom:element(QIC), binary()) -> lustre@internals@vdom:element(QIC).
86 + -spec put_in_head(lustre@internals@vdom:element(QID), binary()) -> lustre@internals@vdom:element(QID).
87 87 put_in_head(El, Content) ->
88 88 case El of
89 89 {element, K, N, <<"head"/utf8>>, A, Children, S, V} ->
  @@ -106,7 +106,7 @@ put_in_head(El, Content) ->
106 106 Node
107 107 end.
108 108
109 - -spec ssr(sketch@lustre@element:element(QIF), sketch:cache()) -> lustre@internals@vdom:element(QIF).
109 + -spec ssr(sketch@lustre@element:element(QIG), sketch:cache()) -> lustre@internals@vdom:element(QIG).
110 110 ssr(El, Cache) ->
111 111 {Cache@1, El@1} = sketch@lustre@element:unstyled(Cache, El),
112 112 Stylesheet = sketch:render(Cache@1),
Loading more files…