Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2648 from teamleadercrm/TIDAL-4585
Browse files Browse the repository at this point in the history
Spread all other props & add title prop
  • Loading branch information
driesd authored May 11, 2023
2 parents 01b619a + b4cd9f0 commit cbc3dca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

### Added

- `IconMenu`: Added a `title` prop and pass it to the IconButton ([@driesd](https://https://github.com/driesd) in [#2648](https://github.com/teamleadercrm/ui/pull/2648))

### Changed

- `IconMenu`: Spread all other props instead of only spreading the box props ([@driesd](https://https://github.com/driesd) in [#2648](https://github.com/teamleadercrm/ui/pull/2648))

### Deprecated

### Removed
Expand Down
15 changes: 11 additions & 4 deletions src/components/menu/IconMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IconMoreMediumOutline } from '@teamleader/ui-icons';
import IconButton from '../iconButton';
import Menu from './Menu';
import theme from './theme.css';
import Box, { pickBoxProps } from '../box';
import Box from '../box';
import { BoxProps } from '../box/Box';
import { GenericComponent } from '../../@types/types';

Expand All @@ -19,6 +19,7 @@ export interface IconMenuProps extends Omit<BoxProps, 'children' | 'className'>
position?: 'auto' | 'static' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
selectable?: boolean;
selected?: any;
title?: string;
}

const IconMenu: GenericComponent<IconMenuProps> = ({
Expand All @@ -32,14 +33,14 @@ const IconMenu: GenericComponent<IconMenuProps> = ({
selectable = false,
selected,
onClick,
title,
...others
}) => {
const [active, setActive] = useState(false);

const buttonRef = useRef<HTMLButtonElement>(null);

const buttonIcon = icon || <IconMoreMediumOutline />;
const boxProps = pickBoxProps(others);

const handleButtonClick = (event: MouseEvent) => {
setActive(!active);
Expand All @@ -60,8 +61,14 @@ const IconMenu: GenericComponent<IconMenuProps> = ({
}, [active, onHide, onShow]);

return (
<Box data-teamleader-ui="icon-menu" {...boxProps} className={cx(theme['icon-menu'], className)}>
<IconButton className={theme['icon']} icon={buttonIcon} onClick={handleButtonClick} ref={buttonRef} />
<Box data-teamleader-ui="icon-menu" {...others} className={cx(theme['icon-menu'], className)}>
<IconButton
className={theme['icon']}
icon={buttonIcon}
onClick={handleButtonClick}
ref={buttonRef}
title={title}
/>
<Menu
active={active}
onHide={handleMenuHide}
Expand Down

0 comments on commit cbc3dca

Please sign in to comment.