Skip to content

Commit

Permalink
Update to leptos 6.14
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveCookTU committed Sep 3, 2024
1 parent 84ce543 commit eaaf0ab
Show file tree
Hide file tree
Showing 12 changed files with 1,030 additions and 650 deletions.
1,464 changes: 958 additions & 506 deletions Cargo.lock

Large diffs are not rendered by default.

66 changes: 11 additions & 55 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@ name = "sports_time_puller"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[dependencies]
leptos = { version = "0.1.3", default-features = false, features = [
leptos = { version = "0.6.14", default-features = false, features = [
"serde",
"csr"
"csr",
"nightly"
] }
leptos_meta = { version = "0.1.3", default-features = false, features = ['csr'] }
leptos_router = { version = "0.1.3", default-features = false, features = ['csr'] }
leptos_meta = { version = "0.6.14", default-features = false, features = ['csr', 'nightly'] }
leptos_router = { version = "0.6.14", default-features = false, features = ['csr', 'nightly'] }
log = "0.4"
serde = {version = "1.0.152", features = ['derive']}
serde_json = "1.0.91"
wasm-bindgen = "0.2.83"
console_log = "1.0.0"
console_error_panic_hook = "0.1.7"
reqwest = { version = "0.11.14", features = ['json'] }
reqwest = { version = "0.12.7", features = ['json'] }
chrono = "0.4.23"
num_enum = "0.6.1"
num_enum = "0.7.3"
num-traits = "0.2.15"
lazy_static = "1.4.0"

Expand All @@ -41,48 +38,7 @@ denylist = [
]

[profile.release]
opt-level = 2 # fast and small wasm

[package.metadata.leptos]
# The name used by wasm-bindgen/cargo-leptos for the JS/WASM bundle. Defaults to the crate name
output-name = "sports_time_puller"
# The site root folder is where cargo-leptos generate all output. WARNING: all content of this folder will be erased on a rebuild. Use it in your server setup.
site-root = "target/site"
# The site-root relative folder where all compiled output (JS, WASM and CSS) is written
# Defaults to pkg
site-pkg-dir = "pkg"
# [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to <site-root>/<site-pkg>/app.css
style-file = "style/output.css"
# [Optional] Files in the asset-dir will be copied to the site-root directory
assets-dir = "public"
# The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup.
site-addr = "127.0.0.1:3000"
# The port to use for automatic reload monitoring
reload-port = 3001
# [Optional] Command to use when running end2end tests. It will run in the end2end dir.
end2end-cmd = "npx playwright test"
# The browserlist query used for optimizing the CSS.
browserquery = "defaults"
# Set by cargo-leptos watch when building with tha tool. Controls whether autoreload JS will be included in the head
watch = false
# The environment Leptos will run in, usually either "DEV" or "PROD"
env = "PROD"
# The features to use when compiling the bin target
#
# Optional. Can be over-ridden with the command line parameter --bin-features
bin-features = []

# If the --no-default-features flag should be used when compiling the bin target
#
# Optional. Defaults to false.
bin-default-features = false

# The features to use when compiling the lib target
#
# Optional. Can be over-ridden with the command line parameter --lib-features
lib-features = []

# If the --no-default-features flag should be used when compiling the lib target
#
# Optional. Defaults to false.
lib-default-features = false
opt-level = 'z'
lto = true
codegen-units = 1
panic = "abort"
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Sports Time Puller</title>
<link data-trunk rel="css" href="./style/output.css" />
<link data-trunk rel="icon" type="image/png" href="./public/icon.png"/>
<link data-trunk rel="rust" data-wasm-opt="z" data-weak-refs />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- INJECT HEAD -->
Expand Down
21 changes: 7 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,40 @@ use leptos::*;
use leptos_router::*;

#[component]
pub fn app(cx: Scope) -> impl IntoView {
pub fn app() -> impl IntoView {
view! {
cx,
<Router>
<Routes>
<Route path="" view= move |cx| view! {
cx,
<Route path="" view= move || view! {
<main class="my-0 mx-auto max-w-3xl text-center">
<h2 class="p-6 text-4xl">"Welcome to the Sports Time Puller"</h2>
<p class="px-10 pb-10 text-center">"Click an option on the navigation bar above to get started."</p>
</main>
}/>
</Routes>
<Routes base={"sports_time_puller".to_string()}>
<Route path="" view= move |cx| view! {
cx,
<Route path="" view= move || view! {
<main class="my-0 mx-auto max-w-3xl text-center">
<h2 class="p-6 text-4xl">"Welcome to the Sports Time Puller"</h2>
<p class="px-10 pb-10 text-center">"Click an option on the navigation bar above to get started."</p>
</main>
}/>
<Route path="cfb" view= move |cx| view! {
cx,
<Route path="cfb" view= move || view! {
<main>
<Cfb />
</main>
}/>
<Route path="mlb" view= move |cx| view! {
cx,
<Route path="mlb" view= move || view! {
<main>
<Mlb />
</main>
}/>
<Route path="nhl" view= move |cx| view! {
cx,
<Route path="nhl" view= move || view! {
<main>
<Nhl />
</main>
}/>
<Route path="soccer" view= move |cx| view! {
cx,
<Route path="soccer" view= move || view! {
<main>
<Soccer />
</main>
Expand Down
25 changes: 10 additions & 15 deletions src/components/cfb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::components::time_zone::*;
use crate::components::RequestParams;
use crate::time_zone::TimeZone as Tz;
use chrono::{DateTime, Datelike, Local, NaiveDate};
use leptos::logging::log;
use leptos::*;
use serde::Deserialize;
use std::str::FromStr;
Expand Down Expand Up @@ -74,26 +75,23 @@ async fn load_results(params: RequestParams<u8>) -> Vec<GameResult> {
}

#[component]
pub fn cfb(cx: Scope) -> impl IntoView {
let (date, set_date) =
create_signal(cx, Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(cx, Tz::Edt as i8);
let (outlet, set_outlet) = create_signal(cx, 0);
let retrieve_results =
create_action(cx, |value: &RequestParams<u8>| load_results(value.clone()));
pub fn cfb() -> impl IntoView {
let (date, set_date) = create_signal(Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(Tz::Edt as i8);
let (outlet, set_outlet) = create_signal(0);
let retrieve_results = create_action(|value: &RequestParams<u8>| load_results(value.clone()));

view! {
cx,
<div class="flex flex-col">
<div class="flex h-12 justify-around items-center m-4 bg-gray-300 rounded-lg shadow-sm shadow-gray-400">
<Teams value={outlet.get()} on_change=move |ev| {
set_outlet(event_target_value(&ev).parse::<u8>().unwrap_or_default());
set_outlet.set(event_target_value(&ev).parse::<u8>().unwrap_or_default());
}
get_teams=|| {get_outlets()}
/>
<TimeZone value={time_zone.get()} set_time_zone={set_time_zone}/>
<input class="bg-transparent border border-gray-600 rounded-md text-right" type="date" value={date} on:input=move |ev| {
set_date(event_target_value(&ev));
set_date.set(event_target_value(&ev));
}/>
<button class="bg-transparent border border-gray-600 rounded-md transition-colors hover:bg-gray-200 px-2 py-1" on:click=move |_| retrieve_results.dispatch(RequestParams {
team: outlet.get(), date: date.get(), time_zone: time_zone.get()
Expand All @@ -116,11 +114,9 @@ pub fn cfb(cx: Scope) -> impl IntoView {
{ move || retrieve_results.value().with(|results: &Option<Vec<GameResult>>| {
if let Some(results) = results {
view ! {
cx,
{
results.iter().map(|r| {
view! {
cx,
<tr>
<td class="table-cell bg-gray-300">{&r.team}</td>
<td class="table-cell bg-gray-300">{&r.date}</td>
Expand All @@ -132,14 +128,13 @@ pub fn cfb(cx: Scope) -> impl IntoView {
<td class="table-cell bg-gray-300">{&r.end_trans}</td>
</tr>
}
}).collect::<Vec<_>>().into_view(cx)
}).collect::<Vec<_>>().into_view()
}
}
} else {
view! {
cx,
<></>
}.into_view(cx)
}.into_view()
}
})
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ use leptos::*;
use leptos_meta::provide_meta_context;

#[component]
pub fn Common(cx: Scope) -> impl IntoView {
provide_meta_context(cx);
pub fn Common() -> impl IntoView {
provide_meta_context();
view! {
cx,
<div>
<div class="flex bg-gray-500 h-16 w-screen drop-shadow-xl justify-around items-center">
<a class="nav-button" href="/sports_time_puller/cfb">"CFB"</a>
Expand Down
24 changes: 9 additions & 15 deletions src/components/mlb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,23 @@ async fn get_live_game_data(
}

#[component]
pub fn mlb(cx: Scope) -> impl IntoView {
let (date, set_date) =
create_signal(cx, Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(cx, Tz::Edt as i8);
let (team, set_team) = create_signal(cx, 0);
let retrieve_results =
create_action(cx, |value: &RequestParams<u16>| load_results(value.clone()));
pub fn mlb() -> impl IntoView {
let (date, set_date) = create_signal(Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(Tz::Edt as i8);
let (team, set_team) = create_signal(0);
let retrieve_results = create_action(|value: &RequestParams<u16>| load_results(value.clone()));

view! {
cx,
<div class="flex flex-col">
<div class="flex h-12 justify-around items-center m-4 bg-gray-300 rounded-lg shadow-sm shadow-gray-400">
<Teams value={team.get()} on_change=move |ev| {
set_team(event_target_value(&ev).parse::<u16>().unwrap_or_default());
set_team.set(event_target_value(&ev).parse::<u16>().unwrap_or_default());
}
get_teams=|| {get_teams()}
/>
<TimeZone value={time_zone.get()} set_time_zone={set_time_zone}/>
<input class="bg-transparent border border-gray-600 rounded-md text-right" type="date" value={date} on:input=move |ev| {
set_date(event_target_value(&ev));
set_date.set(event_target_value(&ev));
}/>
<button class="bg-transparent border border-gray-600 rounded-md transition-colors hover:bg-gray-200 px-2 py-1" on:click=move |_| retrieve_results.dispatch(RequestParams {
team: team.get(), date: date.get(), time_zone: time_zone.get()
Expand All @@ -268,11 +265,9 @@ pub fn mlb(cx: Scope) -> impl IntoView {
{ move || retrieve_results.value().with(|results: &Option<Vec<GameResult>>| {
if let Some(results) = results {
view ! {
cx,
{
results.iter().map(|r| {
view! {
cx,
<tr>
<td class="table-cell bg-gray-300">{&r.title}</td>
<td class="table-cell bg-gray-300">{&r.date}</td>
Expand All @@ -286,14 +281,13 @@ pub fn mlb(cx: Scope) -> impl IntoView {
<td class="table-cell bg-gray-300">{&r.broadcasts}</td>
</tr>
}
}).collect::<Vec<_>>().into_view(cx)
}).collect::<Vec<_>>().into_view()
}
}
} else {
view! {
cx,
<></>
}.into_view(cx)
}.into_view()
}
})
}
Expand Down
24 changes: 9 additions & 15 deletions src/components/nhl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,23 @@ async fn get_live_game_data(
}

#[component]
pub fn nhl(cx: Scope) -> impl IntoView {
let (date, set_date) =
create_signal(cx, Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(cx, Tz::Edt as i8);
let (team, set_team) = create_signal(cx, 0);
let retrieve_results =
create_action(cx, |value: &RequestParams<u8>| load_results(value.clone()));
pub fn nhl() -> impl IntoView {
let (date, set_date) = create_signal(Local::now().date_naive().format("%Y-%m-%d").to_string());
let (time_zone, set_time_zone) = create_signal(Tz::Edt as i8);
let (team, set_team) = create_signal(0);
let retrieve_results = create_action(|value: &RequestParams<u8>| load_results(value.clone()));

view! {
cx,
<div class="flex flex-col">
<div class="flex h-12 justify-around items-center m-4 bg-gray-300 rounded-lg shadow-sm shadow-gray-400">
<Teams value={team.get()} on_change=move |ev| {
set_team(event_target_value(&ev).parse::<u8>().unwrap_or_default());
set_team.set(event_target_value(&ev).parse::<u8>().unwrap_or_default());
}
get_teams=|| {get_teams()}
/>
<TimeZone value={time_zone.get()} set_time_zone={set_time_zone}/>
<input class="bg-transparent border border-gray-600 rounded-md text-right" type="date" value={date} on:input=move |ev| {
set_date(event_target_value(&ev));
set_date.set(event_target_value(&ev));
}/>
<button class="bg-transparent border border-gray-600 rounded-md transition-colors hover:bg-gray-200 px-2 py-1" on:click=move |_| retrieve_results.dispatch(RequestParams {
team: team.get(), date: date.get(), time_zone: time_zone.get()
Expand All @@ -208,11 +205,9 @@ pub fn nhl(cx: Scope) -> impl IntoView {
{ move || retrieve_results.value().with(|results: &Option<Vec<GameResult>>| {
if let Some(results) = results {
view ! {
cx,
{
results.iter().map(|r| {
view! {
cx,
<tr>
<td class="table-cell bg-gray-300">{&r.title}</td>
<td class="table-cell bg-gray-300">{&r.date}</td>
Expand All @@ -224,14 +219,13 @@ pub fn nhl(cx: Scope) -> impl IntoView {
<td class="table-cell bg-gray-300">{&r.broadcasts}</td>
</tr>
}
}).collect::<Vec<_>>().into_view(cx)
}).collect::<Vec<_>>().into_view()
}
}
} else {
view! {
cx,
<></>
}.into_view(cx)
}.into_view()
}
})
}
Expand Down
Loading

0 comments on commit eaaf0ab

Please sign in to comment.