Skip to content

Commit

Permalink
Improve ButtonWithMenu types
Browse files Browse the repository at this point in the history
  • Loading branch information
ravicious authored and github-actions committed Dec 2, 2024
1 parent 2d1f837 commit 1f06c5f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions web/packages/design/src/ButtonWithMenu/ButtonWithMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

import { ComponentType, ReactElement, useRef, useState } from 'react';
import {
ComponentPropsWithoutRef,
ComponentType,
ElementType,
ReactElement,
useRef,
useState,
} from 'react';

import { ButtonBorder, Flex, Menu, MenuItem } from 'design';
import * as icons from 'design/Icon';
Expand Down Expand Up @@ -46,13 +53,15 @@ import { ButtonSize } from 'design/Button';
* <MenuItem>Bar</MenuItem>
* </ButtonWithMenu>
*/
export const ButtonWithMenu = (props: {
text: string;
children: MenuItemComponent | MenuItemComponent[];
MenuIcon?: ComponentType<IconProps>;
size?: ButtonSize;
[buttonBorderProp: string]: any;
}) => {
export const ButtonWithMenu = <Element extends ElementType = 'button'>(
props: {
text: string;
children: MenuItemComponent | MenuItemComponent[];
MenuIcon?: ComponentType<IconProps>;
size?: ButtonSize;
forwardedAs?: Element;
} & ComponentPropsWithoutRef<typeof ButtonBorder<Element>>
) => {
const {
text,
MenuIcon = icons.MoreVert,
Expand Down

0 comments on commit 1f06c5f

Please sign in to comment.