-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added node! convenience macro * added add_class and remove_class to * changed name from value to class * initial implementation of render-agnostic builder API * converted from self to &self * implemented add_dyn_child and add_dyn_only_child * added add_dyn_text * added all currently supported HTML tags * fixed type error when compiling with ssr * added top level component fn and ability to add child components * renamed all functions to be more declarative and concise * renamed add_dyn_class to dyn_class * added bool_attr and dyn_bool_attr * added fragment fn * fixed clippy warnings * fixed use of unstable feature, intersperse_with, and removed unneeded mut * gated builder mod behind feature flag * fully documented current iteration of the Builder API * Apply suggested changes * added #[allow(dead_code)] to unimplemented functions * Update packages/sycamore/src/generic_node/ssr_node.rs * Update packages/sycamore/src/builder/agnostic/mod.rs * Apply suggestions from review * Fix clippy * Add an example for builder API hello world Co-authored-by: Luke Chu <[email protected]> Co-authored-by: Luke Chu <[email protected]>
- Loading branch information
1 parent
82add18
commit 924ed0c
Showing
14 changed files
with
923 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
authors = ["Luke Chu <[email protected]>"] | ||
edition = "2018" | ||
name = "hello-builder" | ||
publish = false | ||
version = "0.1.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
console_error_panic_hook = "0.1.6" | ||
console_log = "0.2.0" | ||
log = "0.4.14" | ||
sycamore = {path = "../../packages/sycamore", features=["experimental-builder-html"]} | ||
wasm-bindgen = "0.2.78" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<title>Hello World!</title> | ||
|
||
<style> | ||
body { | ||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; | ||
} | ||
</style> | ||
</head> | ||
<body></body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use sycamore::builder::html::*; | ||
use sycamore::prelude::*; | ||
|
||
#[component(App<G>)] | ||
fn app() -> Template<G> { | ||
let name = Signal::new(String::new()); | ||
|
||
div() | ||
.child( | ||
h1().text("Hello ") | ||
.dyn_child(cloned!((name) => move || { | ||
if *create_selector(cloned!((name) => move || !name.get().is_empty())).get() { | ||
span() | ||
.dyn_text(cloned!((name) => move || name.get().to_string())) | ||
.build() | ||
} else { | ||
span().text("World").build() | ||
} | ||
})) | ||
.text("!") | ||
.build(), | ||
) | ||
.child(input().bind_value(name).build()) | ||
.build() | ||
} | ||
|
||
fn main() { | ||
console_error_panic_hook::set_once(); | ||
console_log::init_with_level(log::Level::Debug).unwrap(); | ||
|
||
sycamore::render(|| template! { App() }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.