-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
352425e
commit b7cf604
Showing
8 changed files
with
207 additions
and
218 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,16 +1,39 @@ | ||
use cfg_if::cfg_if; | ||
use leptos::*; | ||
use leptos_meta::*; | ||
|
||
#[server(HelloWorld, "/api")] | ||
pub async fn server_hello_world() -> Result<(), ServerFnError> { | ||
server_api::hello_world(); | ||
Ok(()) | ||
} | ||
|
||
#[component] | ||
pub fn App(cx: Scope) -> impl IntoView { | ||
provide_meta_context(cx); | ||
|
||
let hello_world = create_action(cx, |_| server_hello_world()); | ||
|
||
view! { | ||
cx, | ||
<Stylesheet id="leptos" href="pkg/project.css"/> | ||
<Title text="Cargo Leptos Workspace" /> | ||
<div class="bg-green-300 py-32"> | ||
<h1 class="w-full text-3xl text-center">"Hi from your Leptos app with Tailwind!"</h1> | ||
<div class="flex flex-col bg-green-300 py-32 space-y-8"> | ||
<h1 class="text-3xl text-center">"Hi from your Leptos app with Tailwind!"</h1> | ||
<button | ||
class="px-3 py-2 mx-auto border border-black bg-white hover:bg-yellow-200 focus:bg-yellow-200 rounded" | ||
on:click=move |_| hello_world.dispatch(()) | ||
> | ||
"Print Hello on the server" | ||
</button> | ||
</div> | ||
} | ||
} | ||
|
||
cfg_if! { | ||
if #[cfg(feature = "ssr")] { | ||
pub fn register_server_functions() { | ||
_ = HelloWorld::register(); | ||
} | ||
} | ||
} |
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,8 @@ | ||
[package] | ||
name = "server-api" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] |
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,3 @@ | ||
pub fn hello_world() { | ||
println!("Hello World!"); | ||
} |
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