@@ -25,6 +25,35 @@ export interface BottomNavigationItemProps extends Omit<ComponentProps<"button">
25
25
showLabel ?: boolean ;
26
26
}
27
27
28
+ interface BottomNavItemBtnProps {
29
+ reactId : string ;
30
+ customClassName : string ;
31
+ icon : FC < ComponentProps < "svg" > > ;
32
+ theme : DeepPartial < FlowbiteBottomNavigationItemTheme > ;
33
+ label : string ;
34
+ showLabel : boolean ;
35
+ }
36
+
37
+ const BottomNavItemBtn : FC < BottomNavItemBtnProps > = ( props ) => {
38
+ const { icon : Icon , customClassName = "" , reactId, label, showLabel, theme : customTheme = { } , ...rest } = props ;
39
+
40
+ const theme = mergeDeep ( getTheme ( ) . bottomNavigation . item , customTheme ) ;
41
+
42
+ return (
43
+ < button
44
+ type = "button"
45
+ id = { reactId }
46
+ data-testid = "flowbite-bottom-nav-item"
47
+ className = { twMerge ( theme . base , customClassName ) }
48
+ { ...rest }
49
+ >
50
+ < Icon className = { theme . icon . base } data-testid = "flowbite-bottom-nav-icon" fill = "currentColor" aria-hidden = "true" />
51
+
52
+ { showLabel ? < span className = { theme . label } > { label } </ span > : null }
53
+ </ button >
54
+ ) ;
55
+ } ;
56
+
28
57
export const BottomNavigationItem : FC < BottomNavigationItemProps > = ( {
29
58
icon : Icon ,
30
59
label,
@@ -36,8 +65,6 @@ export const BottomNavigationItem: FC<BottomNavigationItemProps> = ({
36
65
} ) => {
37
66
const id = useId ( ) ;
38
67
39
- const theme = mergeDeep ( getTheme ( ) . bottomNavigation . item , customTheme ) ;
40
-
41
68
return (
42
69
< >
43
70
{ showTooltip ? (
@@ -49,56 +76,26 @@ export const BottomNavigationItem: FC<BottomNavigationItemProps> = ({
49
76
}
50
77
placement = "top"
51
78
>
52
- < button
53
- type = "button"
54
- id = { id }
55
- data-testid = "flowbite-bottom-nav-item"
56
- className = { twMerge ( theme . base , className ) }
79
+ < BottomNavItemBtn
80
+ icon = { Icon ? Icon : IoMdHome }
81
+ customClassName = { className as string }
82
+ label = { label }
83
+ reactId = { id }
84
+ showLabel = { showLabel }
85
+ theme = { customTheme }
57
86
{ ...props }
58
- >
59
- { Icon ? (
60
- < Icon
61
- className = { theme . icon . base }
62
- data-testid = "flowbite-bottom-nav-icon"
63
- fill = "currentColor"
64
- aria-hidden = "true"
65
- />
66
- ) : (
67
- < IoMdHome
68
- className = { theme . icon . base }
69
- data-testid = "flowbite-bottom-nav-icon"
70
- fill = "currentColor"
71
- aria-hidden = "true"
72
- />
73
- ) }
74
- { showLabel ? < span className = { theme . label } > { label } </ span > : null }
75
- </ button >
87
+ />
76
88
</ Tooltip >
77
89
) : (
78
- < button
79
- type = "button"
80
- id = { id }
81
- data-testid = "flowbite-bottom-nav-item"
82
- className = { twMerge ( theme . base , className ) }
90
+ < BottomNavItemBtn
91
+ icon = { Icon ? Icon : IoMdHome }
92
+ customClassName = { className as string }
93
+ label = { label }
94
+ reactId = { id }
95
+ showLabel = { showLabel }
96
+ theme = { customTheme }
83
97
{ ...props }
84
- >
85
- { Icon ? (
86
- < Icon
87
- className = { theme . icon . base }
88
- data-testid = "flowbite-bottom-nav-icon"
89
- fill = "currentColor"
90
- aria-hidden = "true"
91
- />
92
- ) : (
93
- < IoMdHome
94
- className = { theme . icon . base }
95
- data-testid = "flowbite-bottom-nav-icon"
96
- fill = "currentColor"
97
- aria-hidden = "true"
98
- />
99
- ) }
100
- { showLabel ? < span className = { theme . label } > { label } </ span > : null }
101
- </ button >
98
+ />
102
99
) }
103
100
</ >
104
101
) ;
0 commit comments