import { DemoStory } from '../demo/demo-types'; import { PopupMenuWithButton, PopupMenuWithLabel, PopupMenuWithIcon, ContentMenu, ContentMenuPosition, } from './popup-menu'; import { RefProps } from 'lupine.web'; export const popupMenuDemo: DemoStory = { id: 'popup-menu-demo', text: 'Popup Menu Demo', args: { label: 'Actions', defaultValue: 'Select...', align: 'right', }, argTypes: { label: { control: 'text', description: 'Label for button/text triggers' }, defaultValue: { control: 'text', description: 'Default selected text' }, align: { control: 'select', options: ['left', 'right'], description: 'Menu drop alignment' }, }, render: (args) => { const ref: RefProps = {}; const list = ['Edit Profile', 'Settings', '-', 'Log Out']; const handleShowMenu = (e: MouseEvent, list: any[], options: any = {}) => { const target = e.currentTarget as HTMLElement; ContentMenu.show(target, list, options); }; const listWithIcons = [ { text: 'Profile', icon: 'ma-account-cog-outline', id: '1', url: '' }, { text: 'Messages', icon: 'co-cil-chat-bubble', id: '2', url: '' }, '-', { text: 'Settings', icon: 'ma-tools', id: '3', url: '' }, { text: 'Logout', icon: 'ma-logout', id: '4', url: '' }, ]; const listMixedIcons = [ { text: 'Cut', icon: 'ma-close', id: '1', url: '' }, // reusing close icon as placeholder for demo { text: 'Copy', id: '2', url: '' }, // No icon, should align with text above { text: 'Paste', icon: 'ma-home-outline', id: '3', url: '' }, '-', { text: 'Select All', id: '4', url: '' }, ]; const listTextOnly = ['Option 1', 'Option 2', '-', 'Option 3', 'Option 4']; const longList = Array.from({ length: 30 }, (_, i) => `Menu Item ${i + 1}`); const showPositionDemo = (e: MouseEvent) => { const position = (ref.$('.&-position-select') as HTMLSelectElement).value as ContentMenuPosition; handleShowMenu(e, listWithIcons, { position }); }; const handleContextMenu = (e: MouseEvent) => { e.preventDefault(); ContentMenu.show(null, listMixedIcons, { x: e.clientX, y: e.clientY }); }; const simpleList = ['Edit Profile', 'Settings', '', 'Log Out']; return (

With Button

console.log('Selected:', val)} />

With Label

With Icon


ContentMenu Component API Usage

The ContentMenu class allows triggering menus from anywhere, including context menus.

Right Click Me to trigger Context Menu!
); }, code: `import { PopupMenuWithButton, PopupMenuWithLabel, PopupMenuWithIcon } from 'lupine.components/components/popup-menu'; const list = ['Edit Profile', 'Settings', '', 'Log Out']; {/* With Button */} console.log('Selected:', val)} /> {/* With Icon */} ⚙️} /> `, };