Skip to content

Commit

Permalink
Move virtual-dom-rs into workspace crate
Browse files Browse the repository at this point in the history
  • Loading branch information
chinedufn committed Jul 16, 2018
1 parent 25e3058 commit 73cb93b
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 36 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Expand Up @@ -5,13 +5,11 @@ authors = ["Chinedu Francis Nwafili <frankie.nwafili@gmail.com>"]
description = "A modular toolkit for building client side web ui's with server side rendering in Rust."
keywords = ["virtual", "dom", "wasm", "css", "webassembly"]

[dependencies]
wasm-bindgen = { version = "0.2" }

[workspace]
members = [
"tests/jsdom",
"examples/isomorphic/app",
"examples/isomorphic/client",
"examples/isomorphic/server"
"examples/isomorphic/server",
"virtual-dom-rs"
]
2 changes: 1 addition & 1 deletion examples/isomorphic/app/Cargo.toml
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Chinedu Francis Nwafili <frankie.nwafili@gmail.com>"]

[dependencies]
virtual-dom-rs = { path = "../../../" }
virtual-dom-rs = { path = "../../../virtual-dom-rs" }
serde = "1"
serde_derive = "1"
serde_json = "1"
6 changes: 3 additions & 3 deletions examples/isomorphic/app/src/lib.rs
Expand Up @@ -74,10 +74,10 @@ mod tests {

#[test]
fn click_msg() {
let mut app = App::new();
let mut app = App::new(5);

assert_eq!(app.state.borrow().click_count(), 0);
assert_eq!(app.state.borrow().click_count(), 5);
app.state.borrow_mut().msg(Msg::Click);
assert_eq!(app.state.borrow().click_count(), 1);
assert_eq!(app.state.borrow().click_count(), 6);
}
}
2 changes: 1 addition & 1 deletion examples/isomorphic/server/Cargo.toml
Expand Up @@ -5,5 +5,5 @@ authors = ["Chinedu Francis Nwafili <frankie.nwafili@gmail.com>"]
private = true

[dependencies]
virtual-dom-rs = { path = "../../../" }
virtual-dom-rs = { path = "../../../virtual-dom-rs" }
isomorphic-app = { path = "../app" }
21 changes: 0 additions & 21 deletions src/lib.rs
@@ -1,22 +1 @@
//!

#![feature(proc_macro, wasm_custom_section, wasm_import_module)]

extern crate wasm_bindgen;
pub use wasm_bindgen::prelude::Closure;

#[macro_use]
pub mod html_macro;
pub use html_macro::*;

pub mod virtual_node;
pub use virtual_node::*;

// TODO: Replace with web-sys crate when it gets released
pub mod webapis;

mod diff;
pub use diff::*;

mod patch;
pub use patch::*;
2 changes: 1 addition & 1 deletion tests/jsdom/Cargo.toml
Expand Up @@ -9,4 +9,4 @@ crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
virtual-dom-rs = { path = "../../" }
virtual-dom-rs = { path = "../../virtual-dom-rs" }
9 changes: 9 additions & 0 deletions virtual-dom-rs/Cargo.toml
@@ -0,0 +1,9 @@
[package]
name = "virtual-dom-rs"
version = "0.0.1"
authors = ["Chinedu Francis Nwafili <frankie.nwafili@gmail.com>"]
description = "A Virtual DOM diffing and patching implementation"
keywords = ["virtual", "dom", "wasm", "web assembly", "webassembly"]

[dependencies]
wasm-bindgen = { version = "0.2" }
File renamed without changes.
9 changes: 5 additions & 4 deletions src/html_macro.rs → virtual-dom-rs/src/html_macro.rs
Expand Up @@ -22,7 +22,7 @@ pub enum TagType {
Close,
}

/// A macro which returns a root `VirtualNode` given some HTML and Rust expressions.
/// A macro which returns a root VirtualNode given some HTML and Rust expressions.
///
/// # Examples
///
Expand All @@ -42,10 +42,11 @@ pub enum TagType {
/// </div>
/// };
/// # }
/// ```
///
/// # TODO
///
/// Create a separate macro that works with anything that implements `VNode`
/// Create a separate macro that works with anything that implements VNode
///
/// ```ignore
/// struct MyCustomVirtualNode;
Expand All @@ -56,9 +57,9 @@ pub enum TagType {
/// html_generic ! { MyCustomVirtualNode <div> <span></span> </div> };
/// ```
///
/// Then make `html! <div></div>` call `html_generic! $crate::VirtualNode <div></div>`.
/// Then make html! { <div></div> } call html_generic! { $crate::VirtualNode <div></div> }.
///
/// This would allow anyone to use the `html_generic!` macro to power their own virtual dom
/// This would allow anyone to use the html_generic! macro to power their own virtual dom
/// implementation!
#[macro_export]
macro_rules! html {
Expand Down
22 changes: 22 additions & 0 deletions virtual-dom-rs/src/lib.rs
@@ -0,0 +1,22 @@
//!

#![feature(proc_macro, wasm_custom_section, wasm_import_module)]

extern crate wasm_bindgen;
pub use wasm_bindgen::prelude::Closure;

#[macro_use]
pub mod html_macro;
pub use html_macro::*;

pub mod virtual_node;
pub use virtual_node::*;

// TODO: Replace with web-sys crate when it gets released
pub mod webapis;

mod diff;
pub use diff::*;

mod patch;
pub use patch::*;
File renamed without changes.
6 changes: 5 additions & 1 deletion src/virtual_node.rs → virtual-dom-rs/src/virtual_node.rs
Expand Up @@ -26,7 +26,9 @@ impl VirtualNode {
/// These get patched into the DOM using `document.createElement`
///
/// ```
/// let div = VirtualNode::tag("div");
/// use virtual_dom_rs::VirtualNode;
///
/// let div = VirtualNode::new("div");
/// ```
pub fn new(tag: &str) -> VirtualNode {
let props = HashMap::new();
Expand All @@ -46,6 +48,8 @@ impl VirtualNode {
/// These get patched into the DOM using `document.createTextNode`
///
/// ```
/// use virtual_dom_rs::VirtualNode;
///
/// let div = VirtualNode::text("div");
/// ```
pub fn text(text: &str) -> VirtualNode {
Expand Down
File renamed without changes.

0 comments on commit 73cb93b

Please sign in to comment.