chore: add leptos fmt
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Kasper Juul Hermansen 2025-01-12 15:05:34 +01:00
parent 38e66419bc
commit c5ca5f3612
Signed by: kjuulh
SSH Key Fingerprint: SHA256:RjXh0p7U6opxnfd3ga/Y9TCo18FYlHFdSpRIV72S/QM
3 changed files with 100 additions and 58 deletions

31
.helix/languages.toml Normal file
View File

@ -0,0 +1,31 @@
[language-server.tailwindcss-ls]
command = "tailwindcss-language-server"
args = ["--stdio"]
config = { userLanguages = { rust = "html", "*.rs" = "html" } }
[[language]]
name = "html"
language-servers = ["vscode-html-language-server", "tailwindcss-ls"]
[[language]]
name = "css"
language-servers = ["vscode-css-language-server", "tailwindcss-ls"]
[[language]]
name = "jsx"
language-servers = ["typescript-language-server", "tailwindcss-ls"]
[[language]]
name = "tsx"
language-servers = ["typescript-language-server", "tailwindcss-ls"]
[[language]]
name = "svelte"
language-servers = ["svelteserver", "tailwindcss-ls"]
[[language]]
name = "rust"
language-servers = ["rust-analyzer", "tailwindcss-ls"]
[language-server.rust-analyzer.config.rustfmt]
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]

View File

@ -55,63 +55,66 @@ pub fn App() -> impl IntoView {
} }
} }
#[component] #[component]
pub fn HomePage() -> impl IntoView { pub fn HomePage() -> impl IntoView {
let messages = message::get_messages(); let messages = message::get_messages();
view! { view! {
<div class="flex flex-col h-screen bg-gray-50"> <div class="flex flex-col h-screen bg-gray-50">
<header class="bg-white border-b border-gray-200 px-4 py-4 flex items-center"> <header class="flex items-center py-4 px-4 bg-white border-b border-gray-200">
<div class="max-w-5xl mx-auto w-full flex items-center justify-between"> <div class="flex justify-between items-center mx-auto w-full max-w-5xl">
<h1 class="text-xl font-semibold text-gray-800">Medical Assistant</h1> <h1 class="text-xl font-semibold text-gray-800">Medical Assistant</h1>
<button class="flex items-center gap-2 px-4 py-2 text-sm text-gray-600 bg-white border border-gray-200 rounded-sm hover:bg-gray-50"> <button class="flex gap-2 items-center py-2 px-4 text-sm text-gray-600 bg-white rounded-sm border border-gray-200 hover:bg-gray-50">
New Chat New Chat
</button> </button>
</div> </div>
</header> </header>
<div class="flex-1 overflow-y-auto px-4"> <div class="overflow-y-auto flex-1 px-4">
<div class="max-w-5xl mx-auto py-6 space-y-6"> <div class="py-6 mx-auto space-y-6 max-w-5xl">
{ {messages
messages.iter().map(|message| view!{ .iter()
<div .map(|message| {
class={format!("flex {}", if message.role == "assistant" { "justify-start"} else {"justify-end"})} view! {
> <div class=format!(
<div "flex {}",
class=format!("max-w-[80%] rounded-sm px-4 py-3 {}", if message.role == "assistant" { if message.role == "assistant" {
"justify-start"
} else {
"justify-end"
},
)>
<div class=format!(
"max-w-[80%] rounded-sm px-4 py-3 {}",
if message.role == "assistant" {
"bg-white border border-gray-200" "bg-white border border-gray-200"
} else { } else {
"bg-blue-500 text-white" "bg-blue-500 text-white"
}) },
> )>{message.content.clone()}</div>
{message.content.clone()}
</div> </div>
</div>
}).collect_view()
} }
})
.collect_view()}
<div class="flex justify-start"> <div class="flex justify-start">
<div class="max-w-[80%] rounded-sm px-4 py-3 bg-white border border-gray-200"> <div class="py-3 px-4 bg-white rounded-sm border border-gray-200 max-w-[80%]">
"Loading..." "Loading..."
</div> </div>
</div> </div> <div />
<div />
</div> </div>
</div> </div>
<div class="border-t border-gray-200 bg-white px-4 py-4"> <div class="py-4 px-4 bg-white border-t border-gray-200">
<form class="max-w-5xl mx-auto"> <form class="mx-auto max-w-5xl">
<div class="flex gap-4"> <div class="flex gap-4">
<input <input
type="text" type="text"
placeholder="Type your medical question here..." placeholder="Type your medical question here..."
class="flex-1 rounded-sm border border-gray-200 px-4 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" class="flex-1 py-2 px-4 rounded-sm border border-gray-200 focus:border-transparent focus:ring-2 focus:ring-blue-500 focus:outline-none"
/> />
<button <button
type="submit" type="submit"
class="px-4 py-2 bg-blue-500 text-white rounded-sm hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2" class="flex gap-2 items-center py-2 px-4 text-white bg-blue-500 rounded-sm hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed"
> >
Send Send
</button> </button>

View File

@ -7,35 +7,43 @@ pub fn get_messages() -> Vec<Message> {
vec![ vec![
Message { Message {
role: "assistant".into(), role: "assistant".into(),
#[rustfmt::skip]
content: "Hello doctor, I've been experiencing severe headaches several times a month. They usually come with nausea and sensitivity to light. Sometimes I see flickering lights before they start. I've tried over-the-counter painkillers but they don't help much.".into() content: "Hello doctor, I've been experiencing severe headaches several times a month. They usually come with nausea and sensitivity to light. Sometimes I see flickering lights before they start. I've tried over-the-counter painkillers but they don't help much.".into()
}, },
Message { Message {
role: "user".into(), role: "user".into(),
#[rustfmt::skip]
content: "I understand how difficult migraines can be. From what you're describing - the visual aura, nausea, and light sensitivity - this sounds like classic migraine. Can you tell me how long these episodes typically last?".into() content: "I understand how difficult migraines can be. From what you're describing - the visual aura, nausea, and light sensitivity - this sounds like classic migraine. Can you tell me how long these episodes typically last?".into()
}, },
Message { Message {
role: "assistant".into(), role: "assistant".into(),
#[rustfmt::skip]
content: "They usually last anywhere from 4 to 24 hours. The worst part is that I have to stay in a dark room and can't work during these episodes. They seem to happen more often when I'm stressed at work.".into() content: "They usually last anywhere from 4 to 24 hours. The worst part is that I have to stay in a dark room and can't work during these episodes. They seem to happen more often when I'm stressed at work.".into()
}, },
Message { Message {
role: "user".into(), role: "user".into(),
#[rustfmt::skip]
content: "Thank you for those details. Stress is indeed a common trigger for migraines. I'd like to suggest a two-pronged approach: first, a preventive medication like propranolol to reduce frequency, and second, a triptan medication to take when you feel a migraine coming on. We should also start a headache diary to track your triggers. Would you be comfortable trying this treatment plan?".into() content: "Thank you for those details. Stress is indeed a common trigger for migraines. I'd like to suggest a two-pronged approach: first, a preventive medication like propranolol to reduce frequency, and second, a triptan medication to take when you feel a migraine coming on. We should also start a headache diary to track your triggers. Would you be comfortable trying this treatment plan?".into()
}, },
Message { Message {
role: "assistant".into(), role: "assistant".into(),
#[rustfmt::skip]
content: "Yes, I'd be willing to try that. I've heard about headache diaries - what exactly should I record in it?".into() content: "Yes, I'd be willing to try that. I've heard about headache diaries - what exactly should I record in it?".into()
}, },
Message { Message {
role: "user".into(), role: "user".into(),
#[rustfmt::skip]
content: "In your headache diary, please record: the date and time of each migraine, what you ate that day, stress levels, sleep patterns, and any other symptoms. This will help us identify patterns and triggers. Use your phone to note these details. I'll prescribe sumatriptan 50mg - take one tablet at the first sign of a migraine. For prevention, start with propranolol 40mg daily. Let's schedule a follow-up in 4 weeks to assess how you're responding to the treatment.".into() content: "In your headache diary, please record: the date and time of each migraine, what you ate that day, stress levels, sleep patterns, and any other symptoms. This will help us identify patterns and triggers. Use your phone to note these details. I'll prescribe sumatriptan 50mg - take one tablet at the first sign of a migraine. For prevention, start with propranolol 40mg daily. Let's schedule a follow-up in 4 weeks to assess how you're responding to the treatment.".into()
}, },
Message { Message {
role: "assistant".into(), role: "assistant".into(),
#[rustfmt::skip]
content: "That sounds good. Should I be aware of any side effects from these medications? And should I continue with my regular exercise routine?".into() content: "That sounds good. Should I be aware of any side effects from these medications? And should I continue with my regular exercise routine?".into()
}, },
Message { Message {
role: "user".into(), role: "user".into(),
#[rustfmt::skip]
content: "Common side effects of sumatriptan can include mild nausea, dizziness, or chest tightness. With propranolol, you might notice slight fatigue initially. Both are generally well-tolerated. Regular exercise is actually beneficial for migraine prevention - continue your routine but stay hydrated and avoid very intense workouts during a migraine attack. If you experience any concerning side effects, contact me immediately. Also, remember to avoid common migraine triggers like irregular meals and poor sleep patterns.".into() content: "Common side effects of sumatriptan can include mild nausea, dizziness, or chest tightness. With propranolol, you might notice slight fatigue initially. Both are generally well-tolerated. Regular exercise is actually beneficial for migraine prevention - continue your routine but stay hydrated and avoid very intense workouts during a migraine attack. If you experience any concerning side effects, contact me immediately. Also, remember to avoid common migraine triggers like irregular meals and poor sleep patterns.".into()
}, },
] ]
} }