Hello web

This commit is contained in:
finga 2024-04-30 21:59:40 +02:00
commit edfc102710
5 changed files with 1315 additions and 0 deletions

85
src/main.rs Normal file
View file

@ -0,0 +1,85 @@
use time::{macros::datetime, OffsetDateTime};
use yew::{function_component, html, Html, Properties};
#[derive(Properties, PartialEq)]
struct Meeting {
date: OffsetDateTime,
location: String,
description: String,
}
#[function_component]
fn MeetingRow(props: &Meeting) -> Html {
html! {
<tr>
<td>{ format!("{}", props.date) }</td>
<td>{ &props.location }</td>
<td>{ &props.description }</td>
</tr>
}
}
#[derive(Properties, PartialEq)]
struct Meetings {
meetings: Vec<Meeting>,
}
#[function_component]
fn MeetingsTable(props: &Meetings) -> Html {
html! {
<table>
<tr>
<th>{ "Date" }</th>
<th>{ "Location" }</th>
<th>{ "Description" }</th>
</tr>
{
props.meetings.iter().map(|row| {
html!{<MeetingRow date={row.date.clone()} location={row.location.clone()} description={row.description.clone()} />}
}).collect::<Html>()
}
</table>
}
}
// Date::from_calendar_date(2019, Month::January, 1)
// PrimitiveDateTime::new(date!(2019-01-01), time!(0:00)),
// datetime!(2000-01-01 0:00 UTC)
// .to_offset(offset!(-1))
#[function_component]
fn App() -> Html {
let meetings = vec![
Meeting {
date: datetime!(2023-11-28 18:30 +1:00),
location: "CCCSBG Space".into(),
description: "Hello World!".into(),
},
Meeting {
date: datetime!(2024-01-23 18:00 +1:00),
location: "CCCSBG Space".into(),
description: "Hello World, again!".into(),
},
Meeting {
date: datetime!(2024-04-30 18:00 +2:00),
location: "CCCSBG Space".into(),
description: "All your web are belong to us!".into(),
},
];
html! {
<>
<h1>{ "¯\\_(ツ)_/¯ SRUG: Salzburg Rust User Group" }</h1>
<p>{ "Eine Anhäufung von planlosen Wesen die was gerne etwas mit Rust machen würden." }</p>
<MeetingsTable meetings={meetings} />
<footer>
<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();
}