island
look
An app's own component, its props in and events out.
Drawn
No HTML view yet: this is its fallback
Downloads by weekthe chart needs JS; 1,204 last week
The sample
fn others() -> Vec<Block> {
let settings = Form::new(vec![
picker("region", "Region", &["eu-west", "us-east"]),
field("retries", "Retries", FieldValue::Number(3.into())),
toggle("notify", "Notify", false),
])
.id("settings")
.action("save-settings");
let hunk = Hunk {
at: "@@ -12,3 +12,4 @@".into(),
lines: vec![
" fn total(rows: &[Row]) -> u64 {".into(),
"- rows.len()".into(),
"+ let n = rows.len();".into(),
"+ n.try_into().unwrap_or(u64::MAX)".into(),
" }".into(),
],
};
let lane = |id: &str, title: &str, stage: &str, state: LaneState| Lane {
id: id.into(),
title: title.into(),
stage: Some(stage.into()),
state,
..Lane::default()
};
let island = Island::new(
"x-chart",
Fallback {
title: "Downloads by week".into(),
subtitle: Some("the chart needs JS; 1,204 last week".into()),
tap: None,
},
)
.id("chart")
.events(vec!["pick".to_string()])
.size(IslandSize {
aspect: Some("16:7".into()),
..IslandSize::default()
});
vec![
b!(Config(settings)),
b!(Secret(
Secret::new("token", "save-token")
.id("token")
.label("API token")
.placeholder("paste a token")
.set(true)
)),
b!(Diff(Diff::new("src/lib.rs", vec![hunk]).id("change").summary("+2 −1"))),
b!(Editor(
Editor::new("notes", "# Notes\n\nShip on Friday.\nCheck the bench\n", "save-notes")
.id("editor")
.errors(vec![LineError {
line: 4,
message: "a line ends with no full stop".into(),
}])
)),
b!(Web(Web::new("media/sample.svg", 240_u32).id("doc"))),
b!(Scene(Scene::new().id("crew").label("Workers").lanes(vec![
lane("w1", "build", "compile", LaneState::Working),
lane("w2", "review", "read the diff", LaneState::Needs),
lane("w3", "docs", "publish", LaneState::Done),
lane("w4", "bench", "wait", LaneState::Idle),
]))),
b!(Island(island)),
]
}{
"blocks": [
{
"events": [
"pick"
],
"fallback": {
"subtitle": "the chart needs JS; 1,204 last week",
"title": "Downloads by week"
},
"id": "chart",
"name": "x-chart",
"size": {
"aspect": "16:7"
},
"type": "island"
}
],
"fallback": {
"title": "screen"
},
"id": "island",
"type": "screen"
}Its fallback
What a renderer without
island draws: a row from the fallback the block carries.Downloads by weekthe chart needs JS; 1,204 last week
Style hooks
.b-islandthe block
[data-block=island]every block of the kind
[data-id=chart]this one block
Every page here is a blocks
Screen, written by site::page: no hand-written HTML. Source: https://github.com/jirathip-dev/blocks