mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added click to menu items in AdminX
rers. https://github.com/TryGhost/Team/issues/3318
This commit is contained in:
parent
6e7f974e7e
commit
7535fc73fc
2 changed files with 5 additions and 2 deletions
|
@ -16,7 +16,9 @@ type Story = StoryObj<typeof Menu>;
|
|||
const items = [
|
||||
{id: 'item-1', label: 'Item 1'},
|
||||
{id: 'item-2', label: 'Item 2'},
|
||||
{id: 'item-3', label: 'Item 3'}
|
||||
{id: 'item-3', label: 'Click me', onClick: () => {
|
||||
alert('Clicked!');
|
||||
}}
|
||||
];
|
||||
|
||||
const longItems = [
|
||||
|
|
|
@ -3,6 +3,7 @@ import React, {useState} from 'react';
|
|||
export type MenuItem = {
|
||||
id: string,
|
||||
label: string;
|
||||
onClick?: () => void
|
||||
}
|
||||
|
||||
type MenuPosition = 'left' | 'right';
|
||||
|
@ -55,7 +56,7 @@ const Menu: React.FC<MenuProps> = ({trigger, items, position, className}) => {
|
|||
<div aria-labelledby="menu-button" aria-orientation="vertical" className={menuListStyles} role="menu">
|
||||
<div className="py-1" role="none">
|
||||
{items.map(item => (
|
||||
<button key={item.id} className="block w-full cursor-pointer px-4 py-2 text-left text-sm text-grey-900 hover:bg-grey-100" type="button">{item.label}</button>
|
||||
<button key={item.id} className="block w-full cursor-pointer px-4 py-2 text-left text-sm text-grey-900 hover:bg-grey-100" type="button" onClick={item.onClick}>{item.label}</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue