Exporting some stuff from stdweb
This commit is contained in:
parent
7e2bef52d8
commit
f3eff1f088
|
@ -5,13 +5,11 @@ extern crate dominator;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate futures_signals;
|
extern crate futures_signals;
|
||||||
|
|
||||||
use stdweb::traits::*;
|
|
||||||
use stdweb::web::{document, HtmlElement};
|
|
||||||
use stdweb::web::event::{MouseOverEvent, MouseOutEvent};
|
|
||||||
use futures_signals::signal::Signal;
|
use futures_signals::signal::Signal;
|
||||||
use futures_signals::signal_vec::unsync::MutableVec;
|
use futures_signals::signal_vec::unsync::MutableVec;
|
||||||
use dominator::traits::*;
|
use dominator::traits::*;
|
||||||
use dominator::Dom;
|
use dominator::Dom;
|
||||||
|
use dominator::events::{MouseOverEvent, MouseOutEvent};
|
||||||
use dominator::animation::{Percentage, easing};
|
use dominator::animation::{Percentage, easing};
|
||||||
use dominator::animation::unsync::MutableAnimation;
|
use dominator::animation::unsync::MutableAnimation;
|
||||||
|
|
||||||
|
@ -117,9 +115,6 @@ fn main() {
|
||||||
boxes: MutableVec::new_with_values(vec![0]),
|
boxes: MutableVec::new_with_values(vec![0]),
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO this should be in stdweb
|
|
||||||
let body = document().query_selector("body").unwrap().unwrap();
|
|
||||||
|
|
||||||
let mut color = 10;
|
let mut color = 10;
|
||||||
|
|
||||||
let f = clone!(state => move || {
|
let f = clone!(state => move || {
|
||||||
|
@ -154,7 +149,7 @@ fn main() {
|
||||||
);*/
|
);*/
|
||||||
|
|
||||||
for _ in 0..1 {
|
for _ in 0..1 {
|
||||||
dominator::append_dom(&body,
|
dominator::append_dom(&dominator::body(),
|
||||||
html!("div", {
|
html!("div", {
|
||||||
style("display", "flex");
|
style("display", "flex");
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,9 @@ extern crate serde_json;
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use stdweb::web::{window, document, HtmlElement};
|
|
||||||
|
// TODO replace most of these with dominator
|
||||||
|
use stdweb::web::{window, document};
|
||||||
use stdweb::web::event::{InputEvent, ClickEvent, HashChangeEvent, KeyDownEvent, ChangeEvent, DoubleClickEvent, BlurEvent};
|
use stdweb::web::event::{InputEvent, ClickEvent, HashChangeEvent, KeyDownEvent, ChangeEvent, DoubleClickEvent, BlurEvent};
|
||||||
use stdweb::web::html_element::InputElement;
|
use stdweb::web::html_element::InputElement;
|
||||||
use stdweb::unstable::TryInto;
|
use stdweb::unstable::TryInto;
|
||||||
|
@ -176,8 +178,7 @@ fn main() {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
// TODO this should be in stdweb
|
let body = dominator::body();
|
||||||
let body = document().query_selector("body").unwrap().unwrap();
|
|
||||||
|
|
||||||
dominator::append_dom(&body,
|
dominator::append_dom(&body,
|
||||||
html!("section", {
|
html!("section", {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std;
|
use std;
|
||||||
use stdweb::{Reference, Value, ReferenceType};
|
use stdweb::{Reference, Value, ReferenceType};
|
||||||
use stdweb::unstable::{TryFrom, TryInto};
|
use stdweb::unstable::{TryFrom, TryInto};
|
||||||
use stdweb::web::{IEventTarget, INode, IElement, IHtmlElement, Node};
|
use stdweb::web::{IEventTarget, INode, IElement, IHtmlElement, HtmlElement, Node};
|
||||||
use stdweb::web::event::ConcreteEvent;
|
use stdweb::web::event::ConcreteEvent;
|
||||||
use callbacks::Callbacks;
|
use callbacks::Callbacks;
|
||||||
use traits::*;
|
use traits::*;
|
||||||
|
@ -49,6 +49,13 @@ pub const HTML_NAMESPACE: &str = "http://www.w3.org/1999/xhtml";
|
||||||
pub const SVG_NAMESPACE: &str = "http://www.w3.org/2000/svg";
|
pub const SVG_NAMESPACE: &str = "http://www.w3.org/2000/svg";
|
||||||
|
|
||||||
|
|
||||||
|
// TODO this should be in stdweb
|
||||||
|
// TODO this should return HtmlBodyElement
|
||||||
|
pub fn body() -> HtmlElement {
|
||||||
|
js! ( return document.body; ).try_into().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct DomHandle {
|
pub struct DomHandle {
|
||||||
parent: Node,
|
parent: Node,
|
||||||
dom: Dom,
|
dom: Dom,
|
||||||
|
|
|
@ -24,6 +24,12 @@ pub use dom::*;
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
pub mod animation;
|
pub mod animation;
|
||||||
|
|
||||||
|
pub use stdweb::web::HtmlElement;
|
||||||
|
|
||||||
|
pub mod events {
|
||||||
|
pub use stdweb::web::event::*;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -10,12 +10,10 @@ macro_rules! html {
|
||||||
}};
|
}};
|
||||||
|
|
||||||
($kind:expr) => {
|
($kind:expr) => {
|
||||||
// TODO need better hygiene for HtmlElement
|
html!($kind => $crate::HtmlElement)
|
||||||
html!($kind => HtmlElement)
|
|
||||||
};
|
};
|
||||||
($kind:expr, { $( $name:ident( $( $args:expr ),* ); )* }) => {{
|
($kind:expr, { $( $name:ident( $( $args:expr ),* ); )* }) => {{
|
||||||
// TODO need better hygiene for HtmlElement
|
html!($kind => $crate::HtmlElement, { $( $name( $( $args ),* ); )* })
|
||||||
html!($kind => HtmlElement, { $( $name( $( $args ),* ); )* })
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue