From ca2241fad08272e208d1218f3779ed253dc833c4 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Sun, 28 Jan 2024 23:39:50 -0500 Subject: [PATCH] ui stuff --- Cargo.lock | 22 +++++----- app/src/components.rs | 2 +- app/src/components/article.rs | 41 ------------------ app/src/components/slingshot.rs | 15 +++++-- app/src/components/ui.rs | 73 +++++++++++++++++++++++++++++++++ app/src/routes/blog.rs | 3 +- app/src/routes/home.rs | 25 +++++++++-- app/src/routes/projects.rs | 23 +++++++++-- style/tailwind.css | 2 +- 9 files changed, 139 insertions(+), 67 deletions(-) delete mode 100644 app/src/components/article.rs create mode 100644 app/src/components/ui.rs diff --git a/Cargo.lock b/Cargo.lock index 0e17acb..cfc9057 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -779,7 +779,7 @@ dependencies = [ "futures-sink", "futures-util", "http 1.0.0", - "indexmap 2.1.0", + "indexmap 2.2.1", "slab", "tokio", "tokio-util", @@ -980,9 +980,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1110,7 +1110,7 @@ dependencies = [ "futures", "getrandom", "html-escape", - "indexmap 2.1.0", + "indexmap 2.2.1", "itertools", "js-sys", "leptos_reactive", @@ -1136,7 +1136,7 @@ checksum = "273d7f2f1823a70944a72c8b47f925c489e38f6121808cd4c7f759b1b5efd5e6" dependencies = [ "anyhow", "camino", - "indexmap 2.1.0", + "indexmap 2.2.1", "parking_lot", "proc-macro2", "quote", @@ -1190,7 +1190,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6ae4f0934d77239f57dec8b438a2c7e8662a46c4704fed8d831f5329c6fcfb" dependencies = [ "cfg-if", - "indexmap 2.1.0", + "indexmap 2.2.1", "leptos", "tracing", "wasm-bindgen", @@ -1206,7 +1206,7 @@ dependencies = [ "base64", "cfg-if", "futures", - "indexmap 2.1.0", + "indexmap 2.2.1", "js-sys", "paste", "pin-project", @@ -1626,11 +1626,11 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +checksum = "80eb9f69aec5cd8828765a75f739383fbbe3e8b9d84370bde1cc90487700794a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "getopts", "memchr", "unicase", @@ -2263,7 +2263,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.1", "serde", "serde_spanned", "toml_datetime", diff --git a/app/src/components.rs b/app/src/components.rs index 39d2056..229c7c7 100644 --- a/app/src/components.rs +++ b/app/src/components.rs @@ -1,2 +1,2 @@ -pub mod article; +pub mod ui; pub mod slingshot; diff --git a/app/src/components/article.rs b/app/src/components/article.rs deleted file mode 100644 index 4f8e4a1..0000000 --- a/app/src/components/article.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::components::slingshot::*; -use leptos::*; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ArticleData { - pub content_type: String, - pub title: String, - pub date: String, // make datetime? - pub content: String, -} - -#[component] -pub fn ArticleBuilder() -> impl IntoView { - let data_resource = create_local_resource( - || (), - |_| async move { slingshot("./public/blog".to_string()).await }, - ); - - let articles_view = move || { - data_resource.and_then(|data| { - data.iter() - .map(|article| view! {
}) - .collect_view() - }) - }; - - articles_view -} - -#[component] -pub fn Article(data: ArticleData) -> impl IntoView { - view! { -
-

{&data.title}

-
- {&data.date} -
-
- } -} diff --git a/app/src/components/slingshot.rs b/app/src/components/slingshot.rs index 83fc3cc..ebd1e91 100644 --- a/app/src/components/slingshot.rs +++ b/app/src/components/slingshot.rs @@ -1,6 +1,13 @@ -use crate::components::article::ArticleData; use leptos::*; -use serde::Deserialize; +use serde::*; + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct ArticleData { + pub content_type: String, + pub title: String, + pub date: String, // make datetime? + pub content: String, +} #[derive(Deserialize)] struct ArticleFrontmatter { @@ -30,7 +37,7 @@ pub async fn slingshot(path: String) -> Result, ServerFnError> if let Some(front_code) = front_raw.code_block { let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?; - println!("{} {}", &toml.date, &toml.title); + // println!("{} {}", &toml.date, &toml.title); articles.push(ArticleData { content_type: toml.content_type, title: toml.title, @@ -43,6 +50,6 @@ pub async fn slingshot(path: String) -> Result, ServerFnError> } } - println!("iran"); + // println!("iran"); Ok(articles) } diff --git a/app/src/components/ui.rs b/app/src/components/ui.rs new file mode 100644 index 0000000..7c07223 --- /dev/null +++ b/app/src/components/ui.rs @@ -0,0 +1,73 @@ +// +// Pile of UI stuff +// + +use crate::components::slingshot::*; +use leptos::*; + +#[component] +pub fn Article(data: ArticleData) -> impl IntoView { + view! { + +
+

+ {&data.title} +

+
+ {&data.date} +
+
+
+ } +} + +#[component] +pub fn ArticleBuilder() -> impl IntoView { + let data_resource = create_local_resource( + || (), + |_| async move { slingshot("./public/blog".to_string()).await }, + ); + + let articles_view = move || { + data_resource.and_then(|data| { + data.iter() + .map(|article| view! {
}) + .collect_view() + }) + }; + + articles_view +} + +#[component] +pub fn Card(children: Children) -> impl IntoView { + view! { +
+

+ "Card Header" +

+
+

+ "[image]" +

+ {children()} +

+ Read more... +

+
+ } +} + +#[component] +pub fn CardHolder(children: Children) -> impl IntoView { + view! {
{children()}
} +} + +#[component] +pub fn Container(children: Children) -> impl IntoView { + view! { +
+ {children()} +
+ } +} diff --git a/app/src/routes/blog.rs b/app/src/routes/blog.rs index d95e782..1e185bc 100644 --- a/app/src/routes/blog.rs +++ b/app/src/routes/blog.rs @@ -1,5 +1,4 @@ -use crate::components::article::*; -use crate::components::slingshot::*; +use crate::components::ui::*; use crate::error_template::*; use leptos::*; diff --git a/app/src/routes/home.rs b/app/src/routes/home.rs index 9015acd..4e76d43 100644 --- a/app/src/routes/home.rs +++ b/app/src/routes/home.rs @@ -1,11 +1,9 @@ -use crate::components::article::*; -use crate::components::slingshot::*; +use crate::components::ui::*; use crate::error_template::*; use leptos::*; #[component] pub fn Home() -> impl IntoView { - view! { "Loading..."

} @@ -13,7 +11,26 @@ pub fn Home() -> impl IntoView { } }> - "Hello again" +

Latest Stuff or whatever

+ + + +

{"home1"}

+
+ +

{"home2"}

+
+ +

{"home3"}

+
+ +

{"home4"}

+
+ +

{"home5"}

+
+
+
} diff --git a/app/src/routes/projects.rs b/app/src/routes/projects.rs index b5e6912..098193b 100644 --- a/app/src/routes/projects.rs +++ b/app/src/routes/projects.rs @@ -1,11 +1,10 @@ -// use crate::components::article::*; +use crate::components::ui::*; // use crate::components::slingshot::*; use crate::error_template::*; use leptos::*; #[component] pub fn Projects() -> impl IntoView { - view! { "Loading..."

} @@ -13,7 +12,25 @@ pub fn Projects() -> impl IntoView { } }> - "Projects" + + + +

{"project1"}

+
+ +

{"project2"}

+
+ +

{"project3"}

+
+ +

{"project4"}

+
+ +

{"project5"}

+
+
+
} diff --git a/style/tailwind.css b/style/tailwind.css index ddbfc11..b89dcb5 100644 --- a/style/tailwind.css +++ b/style/tailwind.css @@ -24,7 +24,7 @@ nav li:has(> a[aria-current="page"]) { } /* Shadows don't work inline for some reason */ -article { +container-lg { @apply bg-zinc-900 shadow-inner shadow-zinc-950; }