11import { Button , type ButtonProps , Icon , IconButton } from "@chakra-ui/react"
22import type React from "react"
33import { forwardRef } from "react"
4+ import { chakraAny } from "../../utils"
45
56interface NavbarItemProps extends Omit < ButtonProps , "variant" | "size" > {
67 icon ?: React . ReactElement
@@ -13,6 +14,8 @@ export const NavbarItem = forwardRef<HTMLButtonElement, NavbarItemProps>(
1314 { icon, label, variant = "button" , children, ...props } ,
1415 ref ,
1516 ) {
17+ const ButtonAny = chakraAny ( Button )
18+ const IconButtonAny = chakraAny ( IconButton )
1619 const commonStyles = {
1720 variant : "ghost" as const ,
1821 borderRadius : "md" as const ,
@@ -21,35 +24,39 @@ export const NavbarItem = forwardRef<HTMLButtonElement, NavbarItemProps>(
2124 mx : "2" as const ,
2225 fontSize : "sm" as const ,
2326 fontWeight : "medium" as const ,
27+ color : "editorBattleshipGrey.700" ,
2428 _hover : {
25- bg : "editorBattleshipGrey.50 " ,
29+ bg : "gray.100 " ,
2630 } ,
2731 }
2832
2933 // If only icon is provided (no children or label to display), use icon variant
3034 if ( variant === "icon" || ( ! children && icon && ! label ) ) {
3135 return (
32- < IconButton
36+ < IconButtonAny
3337 ref = { ref }
3438 aria-label = { label }
35- icon = { icon ? < Icon as = { icon . type } boxSize = { 5 } /> : undefined }
36- color = "editorBattleshipGrey.500"
39+ icon = {
40+ icon ? (
41+ < Icon as = { icon . type as React . ElementType } boxSize = { 5 } />
42+ ) : undefined
43+ }
3744 { ...commonStyles }
38- { ...props }
45+ { ...( props as unknown as Record < string , unknown > ) }
3946 />
4047 )
4148 }
4249
4350 return (
44- < Button
51+ < ButtonAny
4552 ref = { ref }
4653 leftIcon = { icon }
4754 aria-label = { label }
4855 { ...commonStyles }
49- { ...props }
56+ { ...( props as unknown as Record < string , unknown > ) }
5057 >
5158 { children || label }
52- </ Button >
59+ </ ButtonAny >
5360 )
5461 } ,
5562)
0 commit comments