create component library for shared components
This commit is contained in:
parent
80ff760388
commit
840829e47a
15
leptos_components/.gitignore
vendored
Normal file
15
leptos_components/.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
node_modules/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
7
leptos_components/Cargo.toml
Normal file
7
leptos_components/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "leptos_components"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
leptos = { version = "0.7.0", features = ["csr", "ssr", "hydrate"] }
|
||||
11
leptos_components/src/lib.rs
Normal file
11
leptos_components/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use leptos::prelude::*;
|
||||
|
||||
|
||||
#[component]
|
||||
pub fn Button(
|
||||
children: Children,
|
||||
) -> impl IntoView {
|
||||
view! {
|
||||
<button>{children()}</button>
|
||||
}
|
||||
}
|
||||
@ -19,6 +19,7 @@ tower-http = { version = "0.5", features = ["fs"], optional = true }
|
||||
wasm-bindgen = "=0.2.99"
|
||||
thiserror = "1"
|
||||
http = "1"
|
||||
leptos_components = {path="../leptos_components"}
|
||||
|
||||
[features]
|
||||
hydrate = ["leptos/hydrate"]
|
||||
|
||||
@ -4,6 +4,7 @@ use leptos_router::{
|
||||
components::{Route, Router, Routes},
|
||||
StaticSegment,
|
||||
};
|
||||
use leptos_components::Button;
|
||||
|
||||
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||
view! {
|
||||
@ -57,5 +58,6 @@ fn HomePage() -> impl IntoView {
|
||||
view! {
|
||||
<h1>"Welcome to Leptos!"</h1>
|
||||
<button on:click=on_click>"Click Me: " {count}</button>
|
||||
<Button on:click=on_click>"Click Me: " {count}</Button>
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user