Skip to content

Commit

Permalink
update to 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Aug 31, 2024
1 parent 44846e4 commit 5de04dd
Show file tree
Hide file tree
Showing 20 changed files with 440 additions and 484 deletions.
580 changes: 318 additions & 262 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 6 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ console_log = "1.0.0"
console_error_panic_hook = "0.1.7"
futures = "0.3.25"
cfg-if = "1.0.0"
leptos = { version = "0.6.14", features = ["nightly", "experimental-islands"] }
leptos_axum = { version = "0.6.14", optional = true, features = [
leptos = { version = "0.7.0-beta", features = [
"nightly",
"experimental-islands",
] }
leptos_meta = { version = "0.6.14", features = ["nightly"] }
leptos_router = { version = "0.6.14", features = ["nightly"] }
leptos_axum = { version = "0.7.0-beta", optional = true }
leptos_meta = { version = "0.7.0-beta" }
leptos_router = { version = "0.7.0-beta", features = ["nightly"] }
log = "0.4.17"
simple_logger = "5.0.0"
serde = { version = "1", features = ["derive"] }
Expand All @@ -40,14 +41,7 @@ web-sys = { version = "0.3", optional = true, features = [
] }

[features]
default = ["csr"]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
hydrate = [
"leptos/hydrate",
"leptos_meta/hydrate",
"leptos_router/hydrate",
"dep:web-sys",
]
hydrate = ["leptos/hydrate", "dep:web-sys"]
ssr = [
"dep:axum",
"dep:tower",
Expand Down
40 changes: 30 additions & 10 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
use crate::pages::Home::*;
use leptos::*;
use leptos::prelude::*;
use leptos_meta::*;
use leptos_router::*;
use leptos_router::{
components::{Route, Router, Routes},
path, SsrMode, StaticSegment,
};

pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta
name="description"
content="Leptos is a cutting-edge Rust web framework designed for building fast, reliable, web applications."
/>
<link rel="stylesheet" id="leptos" href="/pkg/leptos_website.css"/>
<AutoReload options=options.clone()/>
<HydrationScripts options islands=true/>
<MetaTags/>
</head>
<body>
<App/>
</body>
</html>
}
}

#[component]
pub fn App() -> impl IntoView {
let formatter = |text| format!("{text} - Leptos");
provide_meta_context();

view! {
<Html lang="en"/>
<Stylesheet id="leptos" href="/pkg/leptos_website.css"/>
<Title formatter/>
<Meta
name="description"
content="Leptos is a cutting-edge Rust web framework designed for building fast, reliable, web applications."
/>
<Router>
<Routes>
<Route path="" view=Home ssr=SsrMode::Async/>
<Routes fallback=|| "Not found.">
<Route path=path!("") view=Home ssr=SsrMode::Async/>
</Routes>
</Router>
<script defer data-domain="leptos.dev" src="https://plausible.io/js/script.js"></script>
Expand Down
29 changes: 13 additions & 16 deletions src/components/CodeExample.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use leptos::*;
use leptos::{either::Either, prelude::*};
use tachys::view::any_view::AnyView;

use crate::pages::Home::perform_markdown_code_to_html;

Expand All @@ -10,7 +11,7 @@ pub fn CodeExample(
border: bool,
background: String,
) -> impl IntoView {
let code_resource = create_resource(
let code_resource = Resource::new(
|| false,
move |_| perform_markdown_code_to_html(code.clone()),
);
Expand All @@ -26,10 +27,9 @@ pub fn CodeExample(
}
}

#[derive(Clone)]
pub enum CodeExampleMode {
Html(Resource<bool, Result<String, ServerFnError>>),
View(View),
Html(Resource<Result<String, ServerFnError>>),
View(AnyView<Dom>),
}

#[component]
Expand All @@ -56,23 +56,20 @@ pub fn CodeExampleLayout(
)>
{match code {
CodeExampleMode::Html(code_resource) => {
view! {
let code_view = move || Suspend::new(async move {
let code = code_resource.await.unwrap_or_default();
view! { <div class=code_children_class inner_html=code></div> }
});
Either::Left(view! {
<Suspense fallback=move || {
view! { <div class=code_children_class>"fallback"</div> }
}>
{move || {
code_resource
.and_then(|code| {
view! { <div class=code_children_class inner_html=code></div> }
})
}}
{code_view}
</Suspense>
}
.into_view()
})
}
CodeExampleMode::View(child) => {
view! { <div class=code_children_class>{child}</div> }
.into_view()
Either::Right(view! { <div class=code_children_class>{child}</div> })
}
}}
<div class="w-full flex flex-col lg:max-w-md max-w-full border-black dark:border-eggshell border-opacity-30 items-center ">
Expand Down
2 changes: 1 addition & 1 deletion src/components/DarkModeToggle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;
use leptos_meta::Body;
use leptos_router::ActionForm;

Expand Down
5 changes: 2 additions & 3 deletions src/components/ExampleServerFunction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use leptos::*;
use leptos_router::ActionForm;
use leptos::prelude::*;

#[server(SaveFavorites, "/api")]
pub async fn save_favorites(
Expand Down Expand Up @@ -71,7 +70,7 @@ pub fn FavoritesForm() -> impl IntoView {

#[island]
pub fn ExampleServerFunction() -> impl IntoView {
let favorites = create_server_action::<SaveFavorites>();
let favorites = ServerAction::<SaveFavorites>::new();
let value = favorites.value();
view! {
<ActionForm action=favorites>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExampleTailwind.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

pub enum AlertType {
Info,
Expand Down
2 changes: 1 addition & 1 deletion src/components/FeatureList.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

#[component]
pub fn FeatureListItem(text: String) -> impl IntoView {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

#[component]
pub fn Footer() -> impl IntoView {
Expand Down
4 changes: 2 additions & 2 deletions src/components/HeroHeader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::components::SphereLogo::*;
use leptos::*;
use leptos::prelude::*;
use leptos_meta::Style;
use leptos_router::*;
use leptos_router::components::A;

#[component]
pub fn HeroHeader() -> impl IntoView {
Expand Down
76 changes: 46 additions & 30 deletions src/components/InteractiveCodeExample.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

#[island]
pub fn InteractiveCodeExample(children: Children) -> impl IntoView {
Expand Down Expand Up @@ -60,9 +60,8 @@ pub fn CodeView() -> impl IntoView {
}
};

view! {
<pre class="code-block-inner" data-lang="tsx">
"#"
let child1 = view! {
"#"
<i class="hh8">"["</i>
<i class="hh15">"component"</i>
<i class="hh8">"]"</i>
Expand All @@ -85,7 +84,10 @@ pub fn CodeView() -> impl IntoView {
"\n "
<i class="hh6">"let"</i>
" "
<i class="hh8">"("</i>

};
let child2 = view! {
<i class="hh8">"("</i>
<span class=getter_class>
<i class="hh17">"count"</i>
</span>
Expand All @@ -94,11 +96,11 @@ pub fn CodeView() -> impl IntoView {
<span class=setter_class>
<i class="hh17">"set_count"</i>
</span>
<i class="hh8">")"</i>
<i class="hh8">")"</i>
" "
<i class="hh5">"="</i>
" "
<i class="hh6">"create_signal"</i>
<i class="hh6">"signal"</i>
<i class="hh8">"("</i>
"0"
<i class="hh8">")"</i>
Expand All @@ -117,10 +119,13 @@ pub fn CodeView() -> impl IntoView {
<span class=callback_class>
<i class="hh15">"click"</i>
</span>
<i class="hh5">"="</i>

};
let child3 = view! {
<i class="hh5">"="</i>
<i class="hh15">"move"</i>
" "
<i class="hh5">"|"</i>
<i class="hh5">"|"</i>
<i class="hh15">"_"</i>
<i class="hh5">"|"</i>
" "
Expand All @@ -144,36 +149,47 @@ pub fn CodeView() -> impl IntoView {
"1"
<i class="hh8">")"</i>
<i class="hh9">";"</i>
"\n "
<i class="hh8">"}"</i>
"\n "
<i class="hh5">">"</i>
"\n "
"\"Click me: \""
"\n "
<i class="hh8">"{"</i>
<span class=getter_class>
<i class="hh17">"count"</i>
</span>

};
let child4 = view! {
"\n "
<i class="hh8">"}"</i>
"\n "
<i class="hh5">"<"</i>
<i class="hh5">"/"</i>
<i class="hh12">"button"</i>
<i class="hh5">">"</i>
"\n "
<i class="hh8">"}"</i>
"\n"
<i class="hh8">"}"</i>
<i class="hh5">">"</i>
"\n "
"\"Click me: \""
"\n "
<i class="hh8">"{"</i>
<span class=getter_class>
<i class="hh17">"count"</i>
</span>
<i class="hh8">"}"</i>
"\n "
<i class="hh5">"<"</i>
<i class="hh5">"/"</i>
<i class="hh12">"button"</i>
<i class="hh5">">"</i>
"\n "
<i class="hh8">"}"</i>
"\n"
<i class="hh8">"}"</i>
};

view! {
<pre class="code-block-inner" data-lang="tsx">
{child1}
{child2}
{child3}
{child4}
</pre>
}
}

#[island]
pub fn ExampleComponent() -> impl IntoView {
let (phase, set_phase) = expect_context::<RwSignal<OnStep>>().split();
let (count, set_count) = create_signal(0);
let (interactive, set_interactive) = create_signal(false);
let (count, set_count) = signal(0);
let (interactive, set_interactive) = signal(false);

view! {
<div class="px-2 py-6 h-full w-full flex flex-col justify-center items-center ">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Page.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::components::Footer::*;
// use crate::components::Header::*;
use leptos::*;
use leptos::prelude::*;

#[component]
pub fn Page(children: Children) -> impl IntoView {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SpeedStats.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

struct SpeedStat {
name: String,
Expand Down
2 changes: 1 addition & 1 deletion src/components/SphereLogo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::*;
use leptos::prelude::*;

#[component]
pub fn SphereLogo() -> impl IntoView {
Expand Down
50 changes: 0 additions & 50 deletions src/error_template.rs

This file was deleted.

Loading

0 comments on commit 5de04dd

Please sign in to comment.