-
Notifications
You must be signed in to change notification settings - Fork 315
Expand file tree
/
Copy pathmain.rs
More file actions
34 lines (28 loc) · 1018 Bytes
/
main.rs
File metadata and controls
34 lines (28 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![recursion_limit = "1024"]
use console_error_panic_hook::set_once as set_panic_hook;
use web_sys::window;
fn start_app() {
let document = window()
.and_then(|win| win.document())
.expect("could not access document");
let body = document.body().expect("could not access document.body");
let button_text_node = document.create_element("span").unwrap();
button_text_node
.set_attribute("class", "pf-v6-c-button__text")
.unwrap();
button_text_node.set_text_content(Some("Primary"));
let button_node = document.create_element("button").unwrap();
button_node
.set_attribute("class", "pf-v6-c-button pf-m-primary")
.unwrap();
button_node.set_attribute("type", "button").unwrap();
button_node
.append_child(button_text_node.as_ref())
.expect("failed to append button text");
body.append_child(button_node.as_ref())
.expect("failed to append button");
}
fn main() {
set_panic_hook();
start_app();
}