Dashboard button #25

Merged
meraghon merged 8 commits from feat/dashboard-button into main 2025-12-05 13:35:07 +00:00
6 changed files with 54 additions and 5 deletions
Showing only changes of commit 587b5ff48c - Show all commits

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7 20C7 17.2386 9.23858 15 12 15C14.7614 15 17 17.2386 17 20M7.2 20H16.8C17.9201 20 18.4802 20 18.908 19.782C19.2843 19.5903 19.5903 19.2843 19.782 18.908C20 18.4802 20 17.9201 20 16.8V7.2C20 6.0799 20 5.51984 19.782 5.09202C19.5903 4.71569 19.2843 4.40973 18.908 4.21799C18.4802 4 17.9201 4 16.8 4H7.2C6.0799 4 5.51984 4 5.09202 4.21799C4.71569 4.40973 4.40973 4.71569 4.21799 5.09202C4 5.51984 4 6.07989 4 7.2V16.8C4 17.9201 4 18.4802 4.21799 18.908C4.40973 19.2843 4.71569 19.5903 5.09202 19.782C5.51984 20 6.07989 20 7.2 20ZM14 10C14 11.1046 13.1046 12 12 12C10.8954 12 10 11.1046 10 10C10 8.89543 10.8954 8 12 8C13.1046 8 14 8.89543 14 10Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 968 B

+2 -1
View File
@@ -7,7 +7,7 @@ use leptos_router::{
}; };
use url::Url; use url::Url;
use crate::pages::{AboutPage, HomePage, UnauthenticatedPage}; use crate::pages::{AboutPage, HomePage, TestPage, UnauthenticatedPage};
pub fn shell(options: LeptosOptions) -> impl IntoView { pub fn shell(options: LeptosOptions) -> impl IntoView {
view! { view! {
@@ -67,6 +67,7 @@ pub fn App() -> impl IntoView {
<Routes fallback=|| "Page not found.".into_view()> <Routes fallback=|| "Page not found.".into_view()>
<Route path=StaticSegment("") view=HomePage/> <Route path=StaticSegment("") view=HomePage/>
<Route path=StaticSegment("about") view=AboutPage/> <Route path=StaticSegment("about") view=AboutPage/>
<Route path=StaticSegment("test_page") view=TestPage/>
</Routes> </Routes>
</main> </main>
</Router> </Router>
+30 -2
View File
@@ -1,5 +1,33 @@
use leptos::prelude::*; use leptos::prelude::*;
BobdaFett commented 2025-11-27 21:22:23 +00:00 (Migrated from github.com)
Review

These should not be Optional values. When we use #[prop(optional), it just means that we either have a value, or the default value. For something like this (a String) that would mean we either have a specific value passed in or just the empty string.

These should not be Optional values. When we use `#[prop(optional)`, it just means that we either have a value, or the default value. For something like this (a String) that would mean we either have a specific value passed in or just the empty string.
BobdaFett commented 2025-11-27 21:23:30 +00:00 (Migrated from github.com)
Review

Setting up the #[prop] the right way above should mean that you just print the string value here, no mapping needed.

Setting up the `#[prop]` the right way above should mean that you just print the string value here, no mapping needed.
BobdaFett commented 2025-11-27 21:26:03 +00:00 (Migrated from github.com)
Review

Depending on your desired behavior, leaving this as an Option<String> might be fine. What I'd like to know is the mindset behind it - if this is a None value, how are you handling it? Should this even be optional at all? Why?

I'd recommend documenting this properly (refer to Leptos documentation for how to add doc comments to components).

Depending on your desired behavior, leaving this as an `Option<String>` might be fine. What I'd like to know is the mindset behind it - if this is a `None` value, how are you handling it? Should this even be optional at all? Why? I'd recommend documenting this properly (refer to Leptos documentation for how to add doc comments to components).
BobdaFett commented 2025-12-05 13:07:30 +00:00 (Migrated from github.com)
Review

These props should also have comments. They just have the /// comment one line above.

These props should also have comments. They just have the `/// comment` one line above.
BobdaFett commented 2025-12-05 13:08:03 +00:00 (Migrated from github.com)
Review

There should always be a space after the # in headers.

There should always be a space after the `#` in headers.
use leptos_router::hooks::use_navigate;
#[component] #[component]
pub fn DashboardButton() -> impl IntoView { pub fn DashboardButton(
view! {} #[prop(into)] title: String,
#[prop(into, optional)] description: Option<String>,
#[prop(into, optional)] icon: Option<String>,
#[prop(into)] path: String,
) -> impl IntoView {
let navigate = use_navigate();
let on_click = move |_| navigate(&path, Default::default());
view! {
<button
type="button"
class="dashboard-button flex items-start gap-3 rounded-lg border p-4
hover:bg-gray-100 transition cursor-pointer w-full text-left"
on:click=on_click
>
{icon.as_ref().map(|src| view! {
<img src={src.clone()} class="h-8 w-8" alt="icon"/>
BobdaFett commented 2025-11-27 21:28:40 +00:00 (Migrated from github.com)
Review

This whole component needs documentation - at least give a title to the component, a brief description, explain the props, and a usage example. This is included with other components that have been created, specifically the selection lists (ChipsList, CheckboxList, etc.).

This whole component needs documentation - at least give a title to the component, a brief description, explain the props, and a usage example. This is included with other components that have been created, specifically the selection lists (`ChipsList`, `CheckboxList`, etc.).
})}
<div class="flex flex-col">
<h3 class="font-semibold text-base">{title.clone()}</h3>
{description.as_ref().map(|d| view! {
<p class="text-sm text-gray-600">{d.clone()}</p>
})}
</div>
</button>
}
} }
+1 -1
View File
@@ -1,7 +1,7 @@
mod action_button; mod action_button;
mod checkbox; mod checkbox;
mod chips; mod chips;
mod dashboard_button; pub(crate) mod dashboard_button;
mod loading; mod loading;
mod multi_entry; mod multi_entry;
mod panel; mod panel;
+2 -1
View File
@@ -1,5 +1,6 @@
mod about_page; mod about_page;
mod home_page; mod home_page;
mod test_page;
mod unauthenticated_page; mod unauthenticated_page;
pub use self::{about_page::*, home_page::*, unauthenticated_page::*}; pub use self::{about_page::*, home_page::*, test_page::*, unauthenticated_page::*};
+15
View File
@@ -0,0 +1,15 @@
use crate::components::dashboard_button::DashboardButton;
use leptos::prelude::*;
#[component]
pub fn TestPage() -> impl IntoView {
view! {
<div class="p-6 space-y-4">
<DashboardButton
title="Home Page"
description="Navigate to Home Page"
icon="/public/square-user.svg"
path="/"
/>
</div>
}
}