···19192020Okay, the intro is done, let me show you how easy it is for me to insert a Chilp widget.
21212222-This is just the example from <https://github.com/lustre-labs/lustre/blob/main/examples/01-basics/01-hello-world/src/app.gleam>, I added only about 12 lines to it!
2222+This is just the example from <https://github.com/lustre-labs/lustre/blob/main/examples/01-basics/01-hello-world/src/app.gleam>, I added only about 6 lines to it!
23232424### An example
252526262727```gleam
2828// IMPORTS --------------------------------------------------------------------------------------------------------------
2929+import chilp
2930import lustre
3031import lustre/element.{type Element}
3132import lustre/element/html
3233import lustre/event
3333-import chilp
3434-import chilp/widget
35343635// MAIN -----------------------------------------------------------------------------------------------------------------
37363837pub fn main() {
3939- let assert Ok(_) = widget.register()
3838+ let assert Ok(_) = chilp.register()
4039 let app = lustre.simple(init, update, view)
4140 let assert Ok(_) = lustre.start(app, "#app", Nil)
4241···7372 html.button([event.on_click(UserClickedDecrement)], [html.text("-")]),
7473 html.p([], [html.text("Count: "), html.text(count)]),
7574 html.button([event.on_click(UserClickedIncrement)], [html.text("+")]),
7676- // And then we place the widget itself here! under the counter.
7575+ // And then we place the widget itself here! under the counter.
7776 chilp.widget(
7877 // Anchoring this one to me mewing on the timeline
7979- mastodon: option.Some(chilp.mastodon(
8080- instance: "pony.social",
8181- postid: "115911235653686237",
8282- )),
8383- // And anchoring this one to a post about my hamster
8484- bluesky: option.Some(chilp.bluesky(
8585- did: "did:plc:jgtfsmv25thfs4zmydtbccnn",
8686- post_id: "3mjeg3m7fd22i",
8787- )),
7878+ mastodon: option.Some(chilp.mastodon(instance: "pony.social", postid: "115911235653686237")),
7979+ // And also anchoring it to a post about my hamster, sure!
8080+ bluesky: option.Some(chilp.bluesky(did: "did:plc:jgtfsmv25thfs4zmydtbccnn", post_id: "3mjeg3m7fd22i")),
8881 ),
8982 ])
9083}
9184```
92859393-The widget will be unstyled but is very easily styled into shape using for example DaisyUI, if you just want to see it alive, see the bottom of this post!
8686+Bamn! That's it!
8787+8888+The widget will be unstyled but is very easily [styled into shape using whatever you prefer](https://hexdocs.pm/chilp/2.0.1-rc1/styling.html), if you just want to see it alive, see the bottom of this post!
94899590### What it does
9691