sketch layout

This commit is contained in:
Adam 2024-01-31 21:24:17 -05:00
parent b066b4fe74
commit f37ebd0445
10 changed files with 128 additions and 109 deletions

88
Cargo.lock generated
View file

@ -974,7 +974,7 @@ dependencies = [
"futures-sink", "futures-sink",
"futures-util", "futures-util",
"http 1.0.0", "http 1.0.0",
"indexmap 2.2.1", "indexmap 2.2.2",
"slab", "slab",
"tokio", "tokio",
"tokio-util", "tokio-util",
@ -1176,12 +1176,11 @@ dependencies = [
[[package]] [[package]]
name = "hyper-util" name = "hyper-util"
version = "0.1.2" version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel",
"futures-util", "futures-util",
"http 1.0.0", "http 1.0.0",
"http-body", "http-body",
@ -1189,7 +1188,6 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
"tracing",
] ]
[[package]] [[package]]
@ -1226,9 +1224,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.2.1" version = "2.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown 0.14.3", "hashbrown 0.14.3",
@ -1290,9 +1288,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos" name = "leptos"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13156caccc40bb71d687bed455b7d644ac69ecb5a5c180c2809ba52df863a99a" checksum = "0c115de7c6fca2164133e18328777d02c371434ace38049ac02886b5cffd22dc"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"leptos_config", "leptos_config",
@ -1312,9 +1310,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_axum" name = "leptos_axum"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47756bd25127a3cc5eb33535cafe7199d669fffd5f12d2a9a37757b7399556c9" checksum = "933ce9f409dd29ce429eb457f928d1cb48ebd39386d2dfe2f78d366e78cf7842"
dependencies = [ dependencies = [
"axum", "axum",
"cfg-if", "cfg-if",
@ -1336,9 +1334,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_config" name = "leptos_config"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99cee343145b16836df6847d7da0db6f7f0a3f53f860e6b771bdeebb6da7f0ed" checksum = "055262ff3660e95ec95cadd8a05a02070d624354e08e30b99c14a81023feb2dc"
dependencies = [ dependencies = [
"config", "config",
"regex", "regex",
@ -1349,9 +1347,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_dom" name = "leptos_dom"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf6c02444169c390660bb8975adf064daf3f24f40b2d3f25618e5c0bbbe89cb5" checksum = "adfea7feb9c488448db466ca0673b691ec2a05efb0b2bc6626b7248ee04bb39c"
dependencies = [ dependencies = [
"async-recursion", "async-recursion",
"cfg-if", "cfg-if",
@ -1359,7 +1357,7 @@ dependencies = [
"futures", "futures",
"getrandom", "getrandom",
"html-escape", "html-escape",
"indexmap 2.2.1", "indexmap 2.2.2",
"itertools", "itertools",
"js-sys", "js-sys",
"leptos_reactive", "leptos_reactive",
@ -1379,13 +1377,13 @@ dependencies = [
[[package]] [[package]]
name = "leptos_hot_reload" name = "leptos_hot_reload"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11bf126e9ac0597cda4156f14dea23627d90d53ade182a537b234b7e131e0096" checksum = "3ba8f68f7c3135975eb34ed19210272ebef2d6f422d138ff87a726b8793fe105"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
"indexmap 2.2.1", "indexmap 2.2.2",
"parking_lot", "parking_lot",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1397,9 +1395,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_integration_utils" name = "leptos_integration_utils"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55eb3cbc78aa67790799ef480270bef3d10e23f0a38e6fa3e4e42d797f931a13" checksum = "700bdb6d9d754964b576fa3b76a28a68adbd6ced6d7dc84a18e29e91a82c2376"
dependencies = [ dependencies = [
"futures", "futures",
"leptos", "leptos",
@ -1411,9 +1409,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_macro" name = "leptos_macro"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b859592ff768b01122733ac03a72507849e7ea2f640c63bb1c3487a5dc7a0891" checksum = "039c510dafb7d9997e4b8accfcced5675fabc65720caf544592df32432d6d65a"
dependencies = [ dependencies = [
"attribute-derive", "attribute-derive",
"cfg-if", "cfg-if",
@ -1434,12 +1432,12 @@ dependencies = [
[[package]] [[package]]
name = "leptos_meta" name = "leptos_meta"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4705c24a835c3e8a158a351fee971d9efb0060a9817f719a79e22666dd112558" checksum = "4bbbbd77839b4d3189c06319b32aaa3bc43510fb43f9c1bffb8e124a33decd6c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"indexmap 2.2.1", "indexmap 2.2.2",
"leptos", "leptos",
"tracing", "tracing",
"wasm-bindgen", "wasm-bindgen",
@ -1448,14 +1446,14 @@ dependencies = [
[[package]] [[package]]
name = "leptos_reactive" name = "leptos_reactive"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c5f08f2392b01cc5fc9223eeb92c70b40d366354ffbfb1c6761c9e621a8f966" checksum = "b30c5bc7f3496d6ba399578171cf133c50d2172f9791fe292db4da2fd0d8cec4"
dependencies = [ dependencies = [
"base64", "base64",
"cfg-if", "cfg-if",
"futures", "futures",
"indexmap 2.2.1", "indexmap 2.2.2",
"js-sys", "js-sys",
"paste", "paste",
"pin-project", "pin-project",
@ -1476,9 +1474,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_router" name = "leptos_router"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28334116fab9b903b31c8f6d2be254e86dd35265db6e0c0f5cfbc7b6c18ea0ef" checksum = "498159479603569e1d7c969cffa0817b73249e96f825c295743f8f4607a68cbe"
dependencies = [ dependencies = [
"cached", "cached",
"cfg-if", "cfg-if",
@ -1508,9 +1506,9 @@ dependencies = [
[[package]] [[package]]
name = "leptos_server" name = "leptos_server"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d6baa84d07a5869261e1dc606058886f1a79d6bf89b7b138cf25bae30983b76" checksum = "f06b9b860479385991fad54cbee372382aee3c1e75ca78b5da6f8bda90c153e1"
dependencies = [ dependencies = [
"inventory", "inventory",
"lazy_static", "lazy_static",
@ -1524,9 +1522,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.152" version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]] [[package]]
name = "libm" name = "libm"
@ -2430,9 +2428,9 @@ dependencies = [
[[package]] [[package]]
name = "server_fn" name = "server_fn"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f27208122b0fa6d2b90b7dc25de60294e28647efd43b4c8abaf7df86227931a5" checksum = "97fab54d9dd2d7e9eba4efccac41d2ec3e7c6e9973d14c0486d662a32662320c"
dependencies = [ dependencies = [
"axum", "axum",
"bytes", "bytes",
@ -2465,9 +2463,9 @@ dependencies = [
[[package]] [[package]]
name = "server_fn_macro" name = "server_fn_macro"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8d7a5a1c0f78f261dbb8cf16281020552a1d518dbcb8501b33b8edae02b781b" checksum = "3be6011b586a0665546b7ced372b0be690d9e005d3f8524795da2843274d7720"
dependencies = [ dependencies = [
"const_format", "const_format",
"convert_case", "convert_case",
@ -2479,9 +2477,9 @@ dependencies = [
[[package]] [[package]]
name = "server_fn_macro_default" name = "server_fn_macro_default"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29d13a68cc5b1ff8a3259e3ae984b91559268f0e5a7a8b0216f55b05307df5cb" checksum = "752ed78ec49132d154b922cf5ab6485680cab039a75740c48ea2db621ad481da"
dependencies = [ dependencies = [
"server_fn_macro", "server_fn_macro",
"syn 2.0.48", "syn 2.0.48",
@ -2650,7 +2648,7 @@ dependencies = [
"futures-util", "futures-util",
"hashlink", "hashlink",
"hex", "hex",
"indexmap 2.2.1", "indexmap 2.2.2",
"log", "log",
"memchr", "memchr",
"once_cell", "once_cell",
@ -3024,7 +3022,7 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [ dependencies = [
"indexmap 2.2.1", "indexmap 2.2.2",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
@ -3664,9 +3662,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.5.35" version = "0.5.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View file

@ -1,17 +1,21 @@
use crate::components::ui::articles::*;
use leptos::*; use leptos::*;
use crate::components::ui::articles::Article;
#[server] #[server]
pub async fn get_blog_posts() -> Result<Vec<Article>, ServerFnError> { pub async fn get_articles(article_type: ArticleType) -> Result<Vec<Article>, ServerFnError> {
use sqlx::*; use sqlx::*;
let query = match article_type {
ArticleType::All => "select * from blog order by date",
ArticleType::Blog => "select * from blog where content_type like 'blog'",
ArticleType::Game => "select * from blog where content_type like 'game'",
ArticleType::Project => "select * from blog where content_type like 'project'",
};
let pool: SqlitePool = use_context::<SqlitePool>().expect("couldn't get pool context"); let pool: SqlitePool = use_context::<SqlitePool>().expect("couldn't get pool context");
let result = let result = sqlx::query_as::<_, Article>(query)
sqlx::query_as::<_, Article>("select * from blog where content_type like 'game'")
.fetch_all(&pool) .fetch_all(&pool)
.await?; .await?;
Ok(result) Ok(result)
} }

View file

@ -1,5 +1,5 @@
use crate::components::ui::containers::*;
use crate::components::api::*; use crate::components::api::*;
use crate::components::ui::containers::*;
use leptos::*; use leptos::*;
use serde::*; use serde::*;
@ -12,6 +12,14 @@ pub struct Article {
pub content: String, pub content: String,
} }
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub enum ArticleType {
All,
Blog,
Game,
Project,
}
#[component] #[component]
pub fn Article(data: Article) -> impl IntoView { pub fn Article(data: Article) -> impl IntoView {
view! { view! {
@ -29,12 +37,9 @@ pub fn Article(data: Article) -> impl IntoView {
} }
#[component] #[component]
pub fn ArticleBuilder() -> impl IntoView { pub fn ArticleBuilder(article_type: ArticleType) -> impl IntoView {
let data_resource = create_local_resource( let data_resource =
|| (), create_local_resource(|| (), move |_| async move { get_articles(article_type).await });
|_| async move { get_blog_posts().await },
// |_| async move { slingshot("./public/blog".to_string()).await },
);
let articles_view = move || { let articles_view = move || {
data_resource.and_then(|data| { data_resource.and_then(|data| {

View file

@ -1,17 +1,21 @@
use crate::components::ui::articles::*;
use leptos::*; use leptos::*;
use crate::components::api::get_articles;
#[component] #[component]
pub fn Card(children: Children) -> impl IntoView { pub fn Card(data: Article) -> impl IntoView {
view! { view! {
<div class="p-7 my-5 mx-2 w-80 rounded-lg shadow-inner min-w-3/12 max-w-3/12 bg-zinc-900 shadow-zinc-950"> <div class="p-7 my-5 mx-2 w-80 rounded-lg shadow-inner min-w-3/12 max-w-3/12 bg-zinc-900 shadow-zinc-950">
<h1 class="text-2xl font-light text-orange-600 max-6-xs"> <h1 class="text-2xl font-light text-orange-600 max-6-xs">
"Card Header" {&data.title}
</h1> </h1>
<hr class="opacity-50"/> <hr class="opacity-50"/>
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span>
<p class="text-center"> <p class="text-center">
"[image]" "[image]"
</p> </p>
{children()} <div inner_html=&data.content></div>
<p class="text-right"> <p class="text-right">
<a class="text-orange-300 hover:underline" href="https://lickmysa.cc" >Read more...</a> <a class="text-orange-300 hover:underline" href="https://lickmysa.cc" >Read more...</a>
</p> </p>
@ -20,6 +24,22 @@ pub fn Card(children: Children) -> impl IntoView {
} }
#[component] #[component]
pub fn CardHolder(children: Children) -> impl IntoView { pub fn CardBuilder(article_type: ArticleType) -> impl IntoView {
view! { <div class="flex flex-wrap place-content-evenly mx-auto w-11/12">{children()}</div> } let data_resource = create_local_resource(
|| (),
move |_| async move { get_articles(article_type).await },
);
let cards_view = move || {
data_resource.and_then(|data| {
data.iter()
.map(|article| view! {<Card data=article.clone()/> })
.collect_view()
})
};
view! {
<div class="flex flex-wrap place-content-evenly mx-auto max-w-8/12">
{cards_view}
</div>
}
} }

View file

@ -8,7 +8,7 @@ pub mod components;
pub mod error_template; pub mod error_template;
pub mod routes; pub mod routes;
use crate::routes::{blog::Blog, home::Home, projects::Projects}; use crate::routes::{blog::Blog, games::Games, home::Home, projects::Projects};
#[component] #[component]
pub fn App() -> impl IntoView { pub fn App() -> impl IntoView {
@ -38,6 +38,9 @@ pub fn App() -> impl IntoView {
<li> <li>
<A href="/projects">"Projects"</A> <A href="/projects">"Projects"</A>
</li> </li>
<li>
<A href="/games">"Games"</A>
</li>
<li> <li>
<a href="https://git.doordesk.net">"Git"</a> <a href="https://git.doordesk.net">"Git"</a>
</li> </li>
@ -48,6 +51,7 @@ pub fn App() -> impl IntoView {
<Route path="" view=Home/> <Route path="" view=Home/>
<Route path="blog" view=Blog/> <Route path="blog" view=Blog/>
<Route path="projects" view=Projects/> <Route path="projects" view=Projects/>
<Route path="games" view=Games/>
</Routes> </Routes>
</main> </main>
<p class="m-auto w-8 text-center duration-200 hover:rotate-180"> <p class="m-auto w-8 text-center duration-200 hover:rotate-180">

View file

@ -1,3 +1,4 @@
pub mod home;
pub mod blog; pub mod blog;
pub mod games;
pub mod home;
pub mod projects; pub mod projects;

View file

@ -12,7 +12,7 @@ pub fn Blog() -> impl IntoView {
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }
}> }>
<ArticleBuilder/> <ArticleBuilder article_type={ArticleType::Blog} />
</ErrorBoundary> </ErrorBoundary>
</Suspense> </Suspense>
} }

20
app/src/routes/games.rs Normal file
View file

@ -0,0 +1,20 @@
use crate::components::ui::articles::*;
use crate::components::ui::cards::*;
use crate::error_template::*;
use leptos::*;
#[island]
pub fn Games() -> impl IntoView {
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
}>
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<CardBuilder article_type={ArticleType::Game} />
</ErrorBoundary>
</Suspense>
}
}

View file

@ -1,9 +1,11 @@
use crate::components::ui::articles::*;
use crate::components::ui::cards::*; use crate::components::ui::cards::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
#[component] #[island]
pub fn Home() -> impl IntoView { pub fn Home() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <p>"Loading..."</p> }
@ -11,26 +13,8 @@ pub fn Home() -> impl IntoView {
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }
}> }>
<h1>Latest Stuff or whatever</h1> <CardBuilder article_type={ArticleType::Game} />
<ArticleBuilder article_type={ArticleType::All} />
<CardHolder>
<Card>
<p>{"home1"}</p>
</Card>
<Card>
<p>{"home2"}</p>
</Card>
<Card>
<p>{"home3"}</p>
</Card>
<Card>
<p>{"home4"}</p>
</Card>
<Card>
<p>{"home5"}</p>
</Card>
</CardHolder>
</ErrorBoundary> </ErrorBoundary>
</Suspense> </Suspense>
} }

View file

@ -1,9 +1,10 @@
use crate::components::ui::cards::*; use crate::components::ui::articles::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
#[component] #[island]
pub fn Projects() -> impl IntoView { pub fn Projects() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <p>"Loading..."</p> }
@ -11,25 +12,7 @@ pub fn Projects() -> impl IntoView {
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }
}> }>
<ArticleBuilder article_type={ArticleType::Project} />
<CardHolder>
<Card>
<p>{"project1"}</p>
</Card>
<Card>
<p>{"project2"}</p>
</Card>
<Card>
<p>{"project3"}</p>
</Card>
<Card>
<p>{"project4"}</p>
</Card>
<Card>
<p>{"project5"}</p>
</Card>
</CardHolder>
</ErrorBoundary> </ErrorBoundary>
</Suspense> </Suspense>
} }