Commit cb37d9c 1 parent 5320793 commit cb37d9c Copy full SHA for cb37d9c
File tree 4 files changed +30
-8
lines changed
4 files changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ let value = create_rw_signal(String::from("o"));
5
5
6
6
view! {
7
7
<Menu value >
8
- <MenuItem key = " a" label = " and" / >
9
- <MenuItem key = " o" label = " or" / >
8
+ <MenuItem key = " a" label = " And" / >
9
+ <MenuItem key = " o" label = " Or" / >
10
+ <MenuItem icon = icondata :: AiAreaChartOutlined key = " area" label = " Area Chart" / >
11
+ <MenuItem icon = icondata :: AiPieChartOutlined key = " pie" label = " Pie Chart" / >
12
+ <MenuItem icon = icondata :: AiGithubOutlined key = " github" label = " Github" / >
13
+ <MenuItem icon = icondata :: AiChromeOutlined key = " chrome" label = " Chrome" / >
10
14
</ Menu >
11
15
}
12
16
```
@@ -29,8 +33,9 @@ view! {
29
33
30
34
### MenuItem Props
31
35
32
- | Name | Type | Default | Description |
33
- | ----- | ----------------------------------- | -------------------- | ----------------------------------------- --- |
36
+ | Name | Type | Default | Description |
37
+ | --- | --- | --- | --- |
34
38
| class | ` OptionalProp<MaybeSignal<String>> ` | ` Default::default() ` | Addtional classes for the menu item element. |
35
- | label | ` MaybeSignal<String> ` | ` Default::default() ` | The label of the menu item. |
36
- | key | ` MaybeSignal<String> ` | ` Default::default() ` | The indentifier of the menu item. |
39
+ | label | ` MaybeSignal<String> ` | ` Default::default() ` | The label of the menu item. |
40
+ | key | ` MaybeSignal<String> ` | ` Default::default() ` | The indentifier of the menu item. |
41
+ | icon | ` OptionalMaybeSignal<icondata_core::Icon> ` | ` None ` | The icon of the menu item. |
Original file line number Diff line number Diff line change 1
1
.thaw-menu-item__content {
2
+ display : flex;
3
+ align-items : center;
2
4
margin : 0.3rem 0.4rem ;
3
5
padding : 0.5rem 0.75rem ;
4
6
color : var (--thaw-font-color );
Original file line number Diff line number Diff line change 1
1
use super :: use_menu;
2
- use crate :: { theme:: use_theme, Theme } ;
2
+ use crate :: { theme:: use_theme, Icon , Theme } ;
3
3
use leptos:: * ;
4
- use thaw_utils:: { class_list, mount_style, OptionalProp } ;
4
+ use thaw_components:: OptionComp ;
5
+ use thaw_utils:: { class_list, mount_style, OptionalMaybeSignal , OptionalProp } ;
5
6
6
7
#[ component]
7
8
pub fn MenuItem (
8
9
#[ prop( into) ] key : MaybeSignal < String > ,
10
+ #[ prop( optional, into) ] icon : OptionalMaybeSignal < icondata_core:: Icon > ,
9
11
#[ prop( into) ] label : MaybeSignal < String > ,
10
12
#[ prop( optional, into) ] class : OptionalProp < MaybeSignal < String > > ,
11
13
) -> impl IntoView {
@@ -46,6 +48,15 @@ pub fn MenuItem(
46
48
on: click=on_click
47
49
style=move || css_vars. get( )
48
50
>
51
+ {
52
+ move || {
53
+ view! {
54
+ <OptionComp value=icon. get( ) let : icon>
55
+ <Icon icon=icon style="font-size: 18px;margin-right: 8px" />
56
+ </OptionComp >
57
+ }
58
+ }
59
+ }
49
60
{ move || label. get( ) }
50
61
</div>
51
62
</div>
Original file line number Diff line number Diff line change 50
50
} ) ;
51
51
on_cleanup ( move || listener. remove ( ) ) ;
52
52
}
53
+ #[ cfg( not( any( feature = "csr" , feature = "hydrate" ) ) ) ]
54
+ {
55
+ let _ = hide_menu;
56
+ }
53
57
54
58
let theme = use_theme ( Theme :: light) ;
55
59
let css_vars = create_memo ( move |_| {
You can’t perform that action at this time.
0 commit comments