composer
look
A message box, its pickers and its send action.
Drawn
rerun the bench on main
The sample
fn input() -> Vec<Block> {
let option = |value: &str, label: &str| ChoiceOption {
value: value.into(),
label: label.into(),
..ChoiceOption::default()
};
let choice = Choice::new(
"when",
vec![
option("friday", "Ship on Friday"),
option("now", "Ship now"),
option("later", "Hold for 0.5"),
],
)
.id("when")
.question("When do the 0.4 notes ship?")
.recommended("friday")
.other(Other {
placeholder: Some("other…".into()),
r#for: None,
});
let form = Form::new(vec![
field("name", "Name", FieldValue::Text("Ada Lovelace".into())),
field("email", "Email", FieldValue::Text("ada@example.com".into())),
picker("plan", "Plan", &["team", "solo", "school"]),
toggle("updates", "Updates", true),
])
.id("signup")
.submit(Submit {
label: "sign up".into(),
action: "sign-up".into(),
..Submit::default()
});
let pick = |name: &str, all: &[&str]| ComposerChip {
name: name.into(),
cur: all.first().map(|s| (*s).to_string()),
all: all.iter().map(|s| (*s).to_string()).collect(),
};
let composer = Composer::new("say")
.id("say")
.label("send")
.placeholder("message the team")
.chips(vec![
pick("model", &["fast", "deep"]),
pick("effort", &["medium", "high"]),
])
.queued(vec![Queued {
q: 1,
text: "rerun the bench on main".into(),
}]);
let run = Run::new("approve", "cargo test --workspace --release", "4f2a9c1")
.id("tests")
.dir("crates")
.touches("the test target only");
vec![
button("save", "save", ButtonStyle::Primary),
button("preview", "preview", ButtonStyle::Plain),
button("delete", "delete", ButtonStyle::Destructive),
b!(Choice(choice)),
b!(Form(form)),
b!(Composer(composer)),
b!(Run(run)),
]
}{
"blocks": [
{
"action": "say",
"chips": [
{
"all": [
"fast",
"deep"
],
"cur": "fast",
"name": "model"
},
{
"all": [
"medium",
"high"
],
"cur": "medium",
"name": "effort"
}
],
"fallback": {
"title": "send"
},
"id": "say",
"label": "send",
"placeholder": "message the team",
"queued": [
{
"q": 1,
"text": "rerun the bench on main"
}
],
"type": "composer"
}
],
"fallback": {
"title": "screen"
},
"id": "composer",
"type": "screen"
}Its fallback
What a renderer without
composer draws: a row from the fallback the block carries.send
Style hooks
.b-composerthe block
[data-block=composer]every block of the kind
[data-id=say]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