|
| 1 | +## v3.1.0 - 2025-06-04 |
| 2 | + |
| 3 | +Sketch Lustre adds a new function, `construct`, to let you inject initial |
| 4 | +styling in the stylesheet. Most of the time, so initial style should be |
| 5 | +injected, whether to style `<body>`, add some keyframe, some font-faces, or |
| 6 | +anything else. Before any use of the stylsheet, `construct` allows you to set |
| 7 | +all those things you need! |
| 8 | + |
| 9 | +You can use it to build something like `normalize.css`, but also to build your |
| 10 | +very own stylesheet, tailored to your needs! |
| 11 | + |
| 12 | +An example : |
| 13 | + |
| 14 | +```gleam |
| 15 | +import lustre |
| 16 | +import lustre/element/html |
| 17 | +import sketch |
| 18 | +import sketch/css |
| 19 | +import sketch/css/length.{percent, px} |
| 20 | +import sketch/lustre as sl |
| 21 | +
|
| 22 | +pub fn main() { |
| 23 | + let assert Ok(stylesheet) = setup_sketch_lustre() |
| 24 | + let view = view(_, stylesheet) |
| 25 | + lustre.application(init, view, update) |
| 26 | + |> lustre.start("#root", Nil) |
| 27 | +} |
| 28 | +
|
| 29 | +/// Inject default styling in the initial stylesheet. |
| 30 | +fn setup_sketch_lustre() { |
| 31 | + use stylesheet <- sl.construct |
| 32 | + stylesheet |
| 33 | + |> sketch.global(css.global("body", [css.margin(px(0))])) |
| 34 | + |> sketch.global(css.global("html", [css.height(percent(100))])) |
| 35 | + // Add any initial style you want here, `sketch.at_rule`, etc. |
| 36 | +} |
| 37 | +
|
| 38 | +fn view(model: Model, stylesheet: sketch.StyleSheet) { |
| 39 | + use <- sl.render(stylesheet, in: [sl.node()]) |
| 40 | + html.div([], []) |
| 41 | +} |
| 42 | +``` |
| 43 | + |
| 44 | +In a nutshell : if you need to instanciate a quick and easy stylesheet, use |
| 45 | +`setup()`, if you need to customize your stylesheet, use `construct()`! |
| 46 | + |
1 | 47 | ## v3.0.0 - 2025-05-09 |
2 | 48 |
|
3 | 49 | Sketch Lustre Experimental is now official, and become the official way to use |
|
0 commit comments