Skip to content

Commit

Permalink
chore(fuselage): Add forwardRef to TopBarAction and SidebarAction (#777)
Browse files Browse the repository at this point in the history
Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz>
  • Loading branch information
guijun13 and ggazzo committed Jul 14, 2022
1 parent bed0de7 commit add569d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
13 changes: 8 additions & 5 deletions packages/fuselage/src/components/Sidebar/SidebarActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentProps } from 'react';
import React from 'react';
import type { ComponentProps, Ref } from 'react';
import React, { forwardRef } from 'react';

import { IconButton } from '../Button';
import { ButtonGroup } from '../ButtonGroup';
Expand All @@ -12,6 +12,9 @@ export const SidebarActions = (props: SidebarActionsProps) => (

type SidebarActionProps = ComponentProps<typeof IconButton>;

export const SidebarAction = (props: SidebarActionProps) => (
<IconButton small {...props} />
);
export const SidebarAction = forwardRef(function SidebarAction(
props: SidebarActionProps,
ref: Ref<HTMLElement>
) {
return <IconButton small ref={ref} {...props} />;
});
14 changes: 9 additions & 5 deletions packages/fuselage/src/components/Sidebar/TopBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ComponentProps, ReactNode } from 'react';
import React from 'react';
import type { ComponentProps, ReactNode, Ref } from 'react';
import React, { forwardRef } from 'react';

import Box from '../Box';
import { Divider } from '../Divider';
Expand Down Expand Up @@ -79,9 +79,13 @@ export const TopBarAvatar = Avatar;
export const TopBarActions = SidebarActions;

type TopBarActionProps = ComponentProps<typeof SidebarAction>;
export const TopBarAction = (props: TopBarActionProps) => (
<SidebarAction {...props} />
);

export const TopBarAction = forwardRef(function TopBarAction(
props: TopBarActionProps,
ref: Ref<HTMLElement>
) {
return <SidebarAction ref={ref} {...props} />;
});

export const TopBarDivider = () => <Divider mbs='neg-x2' mbe={0} />;

Expand Down

0 comments on commit add569d

Please sign in to comment.