100 lines
3.3 KiB
Rust
100 lines
3.3 KiB
Rust
use time::{
|
|
macros::{datetime, format_description},
|
|
OffsetDateTime,
|
|
};
|
|
use yew::{classes, function_component, html, Html, Properties};
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
struct Meeting {
|
|
date: OffsetDateTime,
|
|
location: String,
|
|
description: String,
|
|
}
|
|
|
|
#[function_component]
|
|
fn MeetingBox(props: &Meeting) -> Html {
|
|
let format = format_description!("[year]-[month]-[day] [hour]:[minute]");
|
|
let upcoming = props.date > OffsetDateTime::now_local().unwrap();
|
|
|
|
html! {
|
|
<div class={classes!("card", if upcoming { vec!["has-background-info", "has-text-info-invert"] } else { vec!["has-background-dark", "has-text-dark-invert"] })}>
|
|
<div class={classes!("card-header", if upcoming { "has-background-info-30" } else { "has-background-info-10" })}>
|
|
<p class={classes!("card-header-title", if upcoming { "has-text-grey-lighter" } else { "has-text-grey-dark" })}>{ props.date.format(&format).unwrap_or("something went utterly wrong".into()) }</p>
|
|
</div>
|
|
<div class="card-content">
|
|
<p>{ &props.description }</p>
|
|
</div>
|
|
<div class="card-footer">
|
|
<p class="ml-5 my-1">{ &props.location }</p>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
#[derive(Properties, PartialEq)]
|
|
struct Meetings {
|
|
meetings: Vec<Meeting>,
|
|
}
|
|
|
|
#[function_component]
|
|
fn MeetingsTable(props: &Meetings) -> Html {
|
|
html! {
|
|
<div class="grid">
|
|
{
|
|
props.meetings.iter().map(|row| {
|
|
html!{<MeetingBox date={row.date.clone()} location={row.location.clone()} description={row.description.clone()} />}
|
|
}).collect::<Html>()
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
#[function_component]
|
|
fn App() -> Html {
|
|
let meetings = vec![
|
|
Meeting {
|
|
date: datetime!(2024-05-23 18:00 +2:00),
|
|
location: "CCCSBG Space".into(),
|
|
description: "Something.await?".into(),
|
|
},
|
|
Meeting {
|
|
date: datetime!(2024-04-30 18:00 +2:00),
|
|
location: "CCCSBG Space".into(),
|
|
description: "All your web are belong to us!".into(),
|
|
},
|
|
Meeting {
|
|
date: datetime!(2024-01-23 18:00 +1:00),
|
|
location: "CCCSBG Space".into(),
|
|
description: "Hello World, again!".into(),
|
|
},
|
|
Meeting {
|
|
date: datetime!(2023-11-28 18:30 +1:00),
|
|
location: "CCCSBG Space".into(),
|
|
description: "Hello World!".into(),
|
|
},
|
|
];
|
|
|
|
html! {
|
|
<>
|
|
<div id="wrapper">
|
|
<div class="hero">
|
|
<div class="hero-body">
|
|
<h1 class="title">{ "¯\\_(ツ)_/¯ SRUG: Salzburg Rust User Group" }</h1>
|
|
</div>
|
|
</div>
|
|
<div class="section">
|
|
<p class="mb-6 is-family-monospace">{ "lazy_static!(std::collection::VecDeque<Wesen>), die gerne |etwas| unsafe { mit Rust machen } würde.await?;" }</p>
|
|
<MeetingsTable meetings={meetings} />
|
|
</div>
|
|
</div>
|
|
<footer class="footer has-text-centered">
|
|
<p>{ "CCCSBG Space in der Arge Kultur, Ulrike-Gschwandtner-Straße 5, 5020 Salzburg" }</p>
|
|
<a href="https://cccsbg.at">{ "CCCSBG" }</a>
|
|
</footer>
|
|
</>
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
yew::Renderer::<App>::new().render();
|
|
}
|