44 lines
1.0 KiB
Rust
44 lines
1.0 KiB
Rust
use wasm_bindgen::prelude::*;
|
|
use yew::prelude::*;
|
|
use yew::web_sys::console;
|
|
|
|
pub struct Controls {
|
|
link: ComponentLink<Self>,
|
|
}
|
|
|
|
pub enum Msg {
|
|
SubmitForm,
|
|
}
|
|
|
|
impl Component for Controls {
|
|
type Message = Msg;
|
|
type Properties = ();
|
|
|
|
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
|
|
Self { link }
|
|
}
|
|
|
|
fn update(&mut self, msg: Self::Message) -> ShouldRender {
|
|
match msg {
|
|
Msg::SubmitForm => console::log_1(&"Handle submit form".into()),
|
|
}
|
|
true
|
|
}
|
|
|
|
fn change(&mut self, _: Self::Properties) -> ShouldRender {
|
|
false
|
|
}
|
|
|
|
fn view(&self) -> Html {
|
|
html! {
|
|
<section id="controls" style="width: 800px; height: 100px; border: 1px solid grey">
|
|
<label>
|
|
{"Select an audio file"}
|
|
<input type="file"/>
|
|
</label>
|
|
<button onclick=self.link.callback(move |_| Msg::SubmitForm)>{"Open file"}</button>
|
|
</section>
|
|
}
|
|
}
|
|
}
|