Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search experiments UI #288

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/frontend/src/components/context_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ where
}
>

<i class="ri-delete-bin-2-line text-xl text-2xl font-bold"></i>
<i class="ri-delete-bin-2-line text-2xl font-bold"></i>
</button>
</Show>
</div>
Expand All @@ -413,7 +413,7 @@ where
{move || {
if last_idx.get() != idx {
view! {
<div class="my-3 ml-5 ml-6 ml-7">
<div class="my-3 ml-7">
<span class="font-mono text-xs">"&&"</span>
</div>
}
Expand Down
54 changes: 54 additions & 0 deletions crates/frontend/src/components/input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::time::Duration;

use chrono::{DateTime, Utc};
use leptos::*;
use serde_json::{json, Map, Value};

Expand All @@ -21,6 +22,7 @@ pub enum InputType {
Monaco,
Select(EnumVariants),
Disabled,
Date,
}

impl InputType {
Expand All @@ -33,6 +35,8 @@ impl InputType {
| InputType::Select(_) => "text",

InputType::Number | InputType::Integer => "number",

InputType::Date => "datetime-local",
}
}
}
Expand Down Expand Up @@ -415,6 +419,56 @@ pub fn monaco_input(
}
}

#[component]
pub fn date_input(
id: String,
class: String,
name: String,
on_change: Callback<DateTime<Utc>, ()>,
#[prop(into, default = Utc::now().format("%Y-%m-%d").to_string())] value: String,
#[prop(default = false)] disabled: bool,
#[prop(default = false)] required: bool,
#[prop(into, default = String::from("2020-01-01"))] min: String,
#[prop(into, default = Utc::now().format("%Y-%m-%d").to_string())] max: String,
) -> impl IntoView {
let (error_rs, error_ws) = create_signal::<String>(String::new());
view! {
<div class="flex flex-col gap-1">
<input
id=id
name=name
type="date"
class=format!("input input-bordered {}", class)
required=required
disabled=disabled
min=min
max=max
value=value
on:change=move |e| {
let date = format!("{}T00:00:00Z", event_target_value(&e));
logging::log!("The date selected is: {}", date);
match DateTime::parse_from_rfc3339(&date) {
Ok(v) => {
on_change.call(v.to_utc());
}
Err(e) => {
logging::log!("error occurred: {:?}", e);
error_ws.set(e.to_string());
},
}
}
/>
<Show when=move || !error_rs.get().is_empty() >
<span class="flex gap-2 px-4 text-xs font-semibold text-red-600">
<i class="ri-close-circle-line"></i>
{move || error_rs.get()}
</span>
</Show>

</div>
}
}

#[component]
pub fn input(
value: Value,
Expand Down
4 changes: 2 additions & 2 deletions crates/frontend/src/components/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub fn table(
{
match (currently_sorted, sort_by) {
(false, _) => view! { <i class="ri-expand-up-down-line"></i> },
(_, SortBy::Desc) => view! { <i class="ri-arrow-down-s-line"></i> },
(_, SortBy::Asc) => view! { <i class="ri-arrow-up-s-line"></i> },
(true, SortBy::Desc) => view! { <i class="ri-arrow-down-s-line"></i> },
(true, SortBy::Asc) => view! { <i class="ri-arrow-up-s-line"></i> },
}
}

Expand Down
Loading
Loading