mirror of
https://github.com/inventree/InvenTree.git
synced 2026-01-31 10:25:06 +00:00
Refactor more UI components out into lib directory (#9994)
* Refactor table column types * Offloading more component type definitions * Remove unused funcs * Move conversion functions * ActionButton * Refactor YesNoButton * ProgressBar * make row actions available * search input * ButtonMenu * Bump UI version * Tweak function defs
This commit is contained in:
33
src/frontend/lib/components/ButtonMenu.tsx
Normal file
33
src/frontend/lib/components/ButtonMenu.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { ActionIcon, Menu, Tooltip } from '@mantine/core';
|
||||
|
||||
/**
|
||||
* A ButtonMenu is a button that opens a menu when clicked.
|
||||
* It features a number of actions, which can be selected by the user.
|
||||
*/
|
||||
export function ButtonMenu({
|
||||
icon,
|
||||
actions,
|
||||
tooltip = '',
|
||||
label = ''
|
||||
}: Readonly<{
|
||||
icon: any;
|
||||
actions: React.ReactNode[];
|
||||
label?: string;
|
||||
tooltip?: string;
|
||||
}>) {
|
||||
return (
|
||||
<Menu shadow='xs'>
|
||||
<Menu.Target>
|
||||
<ActionIcon variant='default'>
|
||||
<Tooltip label={tooltip}>{icon}</Tooltip>
|
||||
</ActionIcon>
|
||||
</Menu.Target>
|
||||
<Menu.Dropdown>
|
||||
{label && <Menu.Label>{label}</Menu.Label>}
|
||||
{actions.map((action, i) => (
|
||||
<Menu.Item key={`${i}-${action}`}>{action}</Menu.Item>
|
||||
))}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user