diff --git a/src/modules/Header/HeaderLogo.tsx b/src/modules/Header/HeaderLogo.tsx index ae81dbb..e2a753a 100644 --- a/src/modules/Header/HeaderLogo.tsx +++ b/src/modules/Header/HeaderLogo.tsx @@ -1,4 +1,4 @@ -import { Box, type BoxProps, Image, Text } from "@chakra-ui/react"; +import { Box, type BoxProps, Image, Text, forwardRef } from "@chakra-ui/react"; export type HeaderLogoProps = BoxProps & { /** @@ -11,33 +11,41 @@ export type HeaderLogoProps = BoxProps & { alt: string; }; -export function HeaderLogo({ - children, - src, - alt, - title, - ...props -}: HeaderLogoProps) { - return ( - - {alt} - - {title} - - - ); -} +/** + * HeaderLogo component + * Second parameter of the forwardRef generic has to be of the component bound to `as` prop + */ +export const HeaderLogo = forwardRef( + ({ + children, + src, + alt, + title, + as = 'button', + ...props + }, ref) => { + return ( + + {alt} + + {title} + + + ); + } +) diff --git a/src/modules/Header/HeaderMenuButton.tsx b/src/modules/Header/HeaderMenuButton.tsx index 1aa3e23..5d7ecf2 100644 --- a/src/modules/Header/HeaderMenuButton.tsx +++ b/src/modules/Header/HeaderMenuButton.tsx @@ -1,4 +1,4 @@ -import { Icon, MenuButton, useMenuContext } from "@chakra-ui/react"; +import { Icon, MenuButton, forwardRef, useMenuContext } from "@chakra-ui/react"; import { XIcon, type LucideIcon } from "lucide-react"; export type HeaderMenuButtonProps = { @@ -9,7 +9,7 @@ const OPEN_MARGIN_IN_PIXEL = 4; const BORDER_WIDTH_IN_PIXEL = 2; const MAX_CONTAINER_SIZE_IN_PIXEL = 56; -export function HeaderMenuButton({ icon }: HeaderMenuButtonProps) { +export const HeaderMenuButton = forwardRef(({ icon, as, ...props }, ref) => { const { isOpen } = useMenuContext(); const containerSize = isOpen @@ -35,8 +35,11 @@ export function HeaderMenuButton({ icon }: HeaderMenuButtonProps) { margin: isOpen ? `${OPEN_MARGIN_IN_PIXEL}px` : "0px", borderRadius: "2px", }} + as={as} + ref={ref} + {...props} > ); -} +}) diff --git a/src/modules/Header/HeaderMenuContentItem.tsx b/src/modules/Header/HeaderMenuContentItem.tsx index aced8ac..6026699 100644 --- a/src/modules/Header/HeaderMenuContentItem.tsx +++ b/src/modules/Header/HeaderMenuContentItem.tsx @@ -1,8 +1,8 @@ -import { MenuItem, type MenuItemProps } from "@chakra-ui/react"; +import { MenuItem, type MenuItemProps, forwardRef } from "@chakra-ui/react"; export type HeaderMenuContentItemProps = MenuItemProps & {}; -export function HeaderMenuContentItem({ children, ...props }: HeaderMenuContentItemProps) { +export const HeaderMenuContentItem = forwardRef(({ children, ...props }, ref) => { return ( {children} ); -} +}) diff --git a/src/modules/Sidebar/SidebarListItem.tsx b/src/modules/Sidebar/SidebarListItem.tsx index 0d65f57..c2d5a05 100644 --- a/src/modules/Sidebar/SidebarListItem.tsx +++ b/src/modules/Sidebar/SidebarListItem.tsx @@ -1,4 +1,5 @@ -import { Box, ListItem, type BoxProps } from "@chakra-ui/react"; +import { Box, ListItem, type BoxProps, forwardRef } from "@chakra-ui/react"; + export type SidebarListItemProps = BoxProps & { /** @@ -7,11 +8,7 @@ export type SidebarListItemProps = BoxProps & { isActive?: boolean; }; -export function SidebarListItem({ - children, - isActive, - ...props -}: SidebarListItemProps) { +export const SidebarListItem = forwardRef(({ children, isActive, ...props }, ref) => { return ( {children} ); -} +})