File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ use components_core:: { BASE_CLASS , concat} ;
2
+ use leptos:: prelude:: * ;
3
+ use leptos:: { IntoView , component, view} ;
4
+
5
+ #[ component]
6
+ pub fn Input (
7
+ #[ prop( into) ] has_error : ReadSignal < bool > ,
8
+ #[ prop( into) ] disabled : ReadSignal < bool > ,
9
+ #[ prop( into, optional) ] class : String ,
10
+ #[ prop( into, optional) ] error_message : String ,
11
+ #[ prop( into) ] icon : Option < Children > ,
12
+ ) -> impl IntoView {
13
+ let input_class = crate :: tw!(
14
+ concat!( BASE_CLASS , "-input" ) ,
15
+ has_error
16
+ . get( )
17
+ . then_some( concat!( BASE_CLASS , "-input--error" ) ) ,
18
+ class
19
+ ) ;
20
+
21
+ view ! {
22
+ <div class={ concat!( BASE_CLASS , "-input__container" ) } >
23
+ <div class=input_class>
24
+ { icon. map( |icon| view! { <span class={ concat!( BASE_CLASS , "-input__icon" ) } >{ icon( ) } </span> } ) }
25
+ <input
26
+ class={ concat!( BASE_CLASS , "-input__inner" ) }
27
+ disabled=disabled
28
+ />
29
+ </div>
30
+ { has_error. get( ) . then_some(
31
+ view! { <span class={ concat!( BASE_CLASS , "-input__error" ) } >{ error_message} </span> }
32
+ ) }
33
+ </div>
34
+ }
35
+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ pub mod card;
7
7
pub mod chip;
8
8
pub mod flap;
9
9
pub mod icons;
10
+ pub mod input;
10
11
pub mod level;
11
12
pub mod progress_bar;
12
13
pub mod radio;
@@ -23,6 +24,7 @@ pub mod prelude {
23
24
pub use crate :: card:: Card ;
24
25
pub use crate :: chip:: { Chip , Variant as ChipVariant } ;
25
26
pub use crate :: flap:: Flap ;
27
+ pub use crate :: input:: Input ;
26
28
pub use crate :: level:: { Level , Variant as LevelVariant } ;
27
29
pub use crate :: progress_bar:: ProgressBar ;
28
30
pub use crate :: tag:: Tag ;
You can’t perform that action at this time.
0 commit comments