scene
look
Workers at work, each in its state.
Drawn
Workers
- buildworkingcompile
- reviewneedsread the diff
- docsdonepublish
- benchidlewait
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": [
{
"fallback": {
"title": "Workers"
},
"id": "crew",
"label": "Workers",
"lanes": [
{
"id": "w1",
"stage": "compile",
"state": "working",
"title": "build"
},
{
"id": "w2",
"stage": "read the diff",
"state": "needs",
"title": "review"
},
{
"id": "w3",
"stage": "publish",
"state": "done",
"title": "docs"
},
{
"id": "w4",
"stage": "wait",
"state": "idle",
"title": "bench"
}
],
"type": "scene"
}
],
"fallback": {
"title": "screen"
},
"id": "scene",
"type": "screen"
}Its fallback
What a renderer without
scene draws: a row from the fallback the block carries.Workers
Style hooks
.b-scenethe block
[data-block=scene]every block of the kind
[data-id=crew]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