mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 08:34:15 -05:00
feat: MenuItem adds icon prop (#200)
This commit is contained in:
parent
5320793ca9
commit
cb37d9cfe9
4 changed files with 30 additions and 8 deletions
|
@ -5,8 +5,12 @@ let value = create_rw_signal(String::from("o"));
|
|||
|
||||
view! {
|
||||
<Menu value>
|
||||
<MenuItem key="a" label="and"/>
|
||||
<MenuItem key="o" label="or"/>
|
||||
<MenuItem key="a" label="And"/>
|
||||
<MenuItem key="o" label="Or"/>
|
||||
<MenuItem icon=icondata::AiAreaChartOutlined key="area" label="Area Chart"/>
|
||||
<MenuItem icon=icondata::AiPieChartOutlined key="pie" label="Pie Chart"/>
|
||||
<MenuItem icon=icondata::AiGithubOutlined key="github" label="Github"/>
|
||||
<MenuItem icon=icondata::AiChromeOutlined key="chrome" label="Chrome"/>
|
||||
</Menu>
|
||||
}
|
||||
```
|
||||
|
@ -29,8 +33,9 @@ view! {
|
|||
|
||||
### MenuItem Props
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| ----- | ----------------------------------- | -------------------- | -------------------------------------------- |
|
||||
| Name | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| class | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Addtional classes for the menu item element. |
|
||||
| label | `MaybeSignal<String>` | `Default::default()` | The label of the menu item. |
|
||||
| key | `MaybeSignal<String>` | `Default::default()` | The indentifier of the menu item. |
|
||||
| label | `MaybeSignal<String>` | `Default::default()` | The label of the menu item. |
|
||||
| key | `MaybeSignal<String>` | `Default::default()` | The indentifier of the menu item. |
|
||||
| icon | `OptionalMaybeSignal<icondata_core::Icon>` | `None` | The icon of the menu item. |
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
.thaw-menu-item__content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 0.3rem 0.4rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: var(--thaw-font-color);
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
use super::use_menu;
|
||||
use crate::{theme::use_theme, Theme};
|
||||
use crate::{theme::use_theme, Icon, Theme};
|
||||
use leptos::*;
|
||||
use thaw_utils::{class_list, mount_style, OptionalProp};
|
||||
use thaw_components::OptionComp;
|
||||
use thaw_utils::{class_list, mount_style, OptionalMaybeSignal, OptionalProp};
|
||||
|
||||
#[component]
|
||||
pub fn MenuItem(
|
||||
#[prop(into)] key: MaybeSignal<String>,
|
||||
#[prop(optional, into)] icon: OptionalMaybeSignal<icondata_core::Icon>,
|
||||
#[prop(into)] label: MaybeSignal<String>,
|
||||
#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>,
|
||||
) -> impl IntoView {
|
||||
|
@ -46,6 +48,15 @@ pub fn MenuItem(
|
|||
on:click=on_click
|
||||
style=move || css_vars.get()
|
||||
>
|
||||
{
|
||||
move || {
|
||||
view! {
|
||||
<OptionComp value=icon.get() let:icon>
|
||||
<Icon icon=icon style="font-size: 18px;margin-right: 8px"/>
|
||||
</OptionComp>
|
||||
}
|
||||
}
|
||||
}
|
||||
{move || label.get()}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -50,6 +50,10 @@ where
|
|||
});
|
||||
on_cleanup(move || listener.remove());
|
||||
}
|
||||
#[cfg(not(any(feature = "csr", feature = "hydrate")))]
|
||||
{
|
||||
let _ = hide_menu;
|
||||
}
|
||||
|
||||
let theme = use_theme(Theme::light);
|
||||
let css_vars = create_memo(move |_| {
|
||||
|
|
Loading…
Add table
Reference in a new issue