Components / Playground
Playground
Code beside what it makes, with examples, a run key and the last result that worked kept while the code has problems.
Example
The component itself, running in WebAssembly, beside its code in a playground. Try it.
Code
use ravenrs::prelude::*;
fn playground() -> impl View {
let run = |code: &str| -> Result<AnyView, Vec<CodeDiagnostic>> {
match code.trim().strip_prefix("say ") {
Some(words) => Ok(Box::new(Text::new(words.to_owned()).style(TextStyle::Title))),
None => Err(vec![CodeDiagnostic::error(1, 1, 1, "Start with `say`").hint("Write `say hello`")]),
}
};
Playground::new(run)
.language(CodeLanguage::Plain)
.example("Hello", "say hello")
.example("Goodbye", "say goodbye")
.height(380.0)
}