Skip to content

Commit

Permalink
update monaco-rust example to yew 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
SpanishPear authored and siku2 committed Dec 3, 2022
1 parent 82fc223 commit 7a4b358
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/yew/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2018"
[dependencies]
monaco = { path = "../..", features = ["yew-components"] }
wasm-bindgen = "0.2"
yew = "0.19"
yew = { version = "0.20", features = ["csr"] }
8 changes: 7 additions & 1 deletion examples/yew/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@
import init from "./yew.js";
init();
</script>

<style>
.full-height {
height: 100%;
}
</style>
</head>

<body style="height: 100vh; margin: 0; overflow: hidden;"></body>

</html>
</html>
7 changes: 4 additions & 3 deletions examples/yew/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn get_options() -> CodeEditorOptions {
.with_language("rust".to_owned())
.with_value(CONTENT.to_owned())
.with_builtin_theme(BuiltinTheme::VsDark)
.with_automatic_layout(true)
}

struct App {
Expand All @@ -24,17 +25,17 @@ impl Component for App {
}
}

fn changed(&mut self, _context: &Context<Self>) -> bool {
fn changed(&mut self, _context: &Context<Self>, _old_props: &Self::Properties) -> bool {
false
}

fn view(&self, _context: &Context<Self>) -> Html {
html! {
<CodeEditor options={ self.options.to_sys_options() } />
<CodeEditor classes={"full-height"} options={ self.options.to_sys_options() } />
}
}
}

fn main() {
yew::start_app::<App>();
yew::Renderer::<App>::new().render();
}

0 comments on commit 7a4b358

Please sign in to comment.