All checks were successful
CI / Format (push) Successful in 30s
CI / Clippy (push) Successful in 2m36s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Format (pull_request) Successful in 3s
CI / Clippy (pull_request) Successful in 2m15s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
CI / Deploy (push) Has been skipped
CI / Deploy (pull_request) Has been skipped
Add a compile-time i18n system with 270 translation keys across 5 locales (EN, DE, FR, ES, PT). Translations are embedded via include_str! and parsed lazily into flat HashMaps with English fallback for missing keys. - Add src/i18n module with Locale enum, t()/tw() lookup functions, and tests - Add JSON translation files for all 5 locales under assets/i18n/ - Provide locale Signal via Dioxus context in App, persisted to localStorage - Replace all hardcoded UI strings across 33 component/page files - Add compact locale picker (globe icon + ISO alpha-2 code) in sidebar header - Add click-outside backdrop dismissal for locale dropdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
2.5 KiB
Rust
74 lines
2.5 KiB
Rust
use crate::i18n::{t, Locale};
|
|
use dioxus::prelude::*;
|
|
|
|
/// Chat input bar with a textarea and send button.
|
|
///
|
|
/// Enter sends the message; Shift+Enter inserts a newline.
|
|
/// The input is disabled during streaming.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `input_text` - Two-way bound input text signal
|
|
/// * `on_send` - Callback fired with the message text when sent
|
|
/// * `is_streaming` - Whether to disable the input (streaming in progress)
|
|
#[component]
|
|
pub fn ChatInputBar(
|
|
input_text: Signal<String>,
|
|
on_send: EventHandler<String>,
|
|
is_streaming: bool,
|
|
) -> Element {
|
|
let locale = use_context::<Signal<Locale>>();
|
|
let l = *locale.read();
|
|
|
|
let mut input = input_text;
|
|
|
|
rsx! {
|
|
div { class: "chat-input-bar",
|
|
textarea {
|
|
class: "chat-input",
|
|
placeholder: "{t(l, \"chat.type_message\")}",
|
|
disabled: is_streaming,
|
|
rows: "1",
|
|
value: "{input}",
|
|
oninput: move |e: Event<FormData>| {
|
|
input.set(e.value());
|
|
},
|
|
onkeypress: move |e: Event<KeyboardData>| {
|
|
// Enter sends, Shift+Enter adds newline
|
|
if e.key() == Key::Enter && !e.modifiers().shift() {
|
|
e.prevent_default();
|
|
let text = input.read().trim().to_string();
|
|
if !text.is_empty() {
|
|
on_send.call(text);
|
|
input.set(String::new());
|
|
}
|
|
}
|
|
},
|
|
}
|
|
button {
|
|
class: "btn-primary chat-send-btn",
|
|
disabled: is_streaming || input.read().trim().is_empty(),
|
|
onclick: move |_| {
|
|
let text = input.read().trim().to_string();
|
|
if !text.is_empty() {
|
|
on_send.call(text);
|
|
input.set(String::new());
|
|
}
|
|
},
|
|
if is_streaming {
|
|
// Stop icon during streaming
|
|
dioxus_free_icons::Icon {
|
|
icon: dioxus_free_icons::icons::fa_solid_icons::FaStop,
|
|
width: 16, height: 16,
|
|
}
|
|
} else {
|
|
dioxus_free_icons::Icon {
|
|
icon: dioxus_free_icons::icons::fa_solid_icons::FaPaperPlane,
|
|
width: 16, height: 16,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|