Implement function for date range enum in date.rs
This commit is contained in:
1 parent
38a0482b8c
commit
fab172c4d1
1 file changed
+17
-4
+17
-4
@@ -1,4 +1,5 @@
|
|||||||
use crate::common::DateInfo;
|
use crate::common::{DateInfo, DateRange};
|
||||||
|
use leptos::either::Either;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
/// # Date Component
|
/// # Date Component
|
||||||
///
|
///
|
||||||
@@ -7,6 +8,18 @@ use leptos::prelude::*;
|
|||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
/// ```
|
/// ```
|
||||||
|
|
||||||
|
fn render_dates(dates: DateRange) -> impl IntoView {
|
||||||
|
match dates {
|
||||||
|
DateRange::Single(date) => Either::Left(view! {
|
||||||
|
<p> {date} </p>
|
||||||
|
}),
|
||||||
|
DateRange::Range(start_date, end_date) => Either::Right(view! {
|
||||||
|
<p> {start_date} " - " {end_date} </p>
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Date(
|
pub fn Date(
|
||||||
/// Struct of title, date, and description
|
/// Struct of title, date, and description
|
||||||
@@ -31,11 +44,11 @@ pub fn Date(
|
|||||||
<div class="flex-1 min-w-0">
|
<div class="flex-1 min-w-0">
|
||||||
<div class="flex items-start justify-between">
|
<div class="flex items-start justify-between">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<h3 class="font-semibold text-md text-base">
|
<h3 class="font-bold text-md text-base">
|
||||||
{info.title}
|
{info.title}
|
||||||
</h3>
|
</h3>
|
||||||
<h3 class="font-bold text-md text-base mt-1">
|
<h3 class="text-md text-base mt-1">
|
||||||
{info.date}
|
{render_dates(info.date)}
|
||||||
</h3>
|
</h3>
|
||||||
<p class="text-sm text-gray-600">
|
<p class="text-sm text-gray-600">
|
||||||
{info.description}
|
{info.description}
|
||||||
|
|||||||
Reference in new issue
Block a user