woocommerce/packages/js/components/src/ellipsis-menu
Gabriel Manussakis 532f1beb02
[Accessibility] Fix misspelling in inline documentation in packages/js/* (#48640)
* Fix "colleciton" typo

* Fix "fomatting" typo

* Fix "elments" typo

* Fix "actuall" typo

* Fix "witth" typo

* Fix "varation" typo

* Fix "procesing" typo

* Fix "neigbouring" typo

* Fix "staticly" typo

* Fix "Curreny" typo

* Fix "addd" typo

* Fix "accessibile" typo

* Fix "avaiable" typo

* Fix "Resurce" typo

* Fix "curent" typo

* Fix "flakyness" typo

* Fix "flakyness" typo

* Fix "Shiping" typo

* Fix "specfically" and "Shiping" typos

* Fix "flakyness" typo

* Fix "avaliable" typo

* Fix "availble" typo

* Fix "oject" typo

* Fix "explict" typo

* Fix "sumary" typo

* Fix "whn" typo

* Fix "normaly" typo

* Add changelog files
2024-06-21 10:28:54 -07:00
..
stories Moved WCA Packages 2022-03-18 14:25:26 -07:00
test Moved WCA Packages 2022-03-18 14:25:26 -07:00
README.md Moved WCA Packages 2022-03-18 14:25:26 -07:00
index.tsx Address some deprecation warnings (#41845) 2023-12-15 09:45:06 -04:00
menu-item.tsx [Accessibility] Fix misspelling in inline documentation in packages/js/* (#48640) 2024-06-21 10:28:54 -07:00
menu-title.tsx Migrate Ellipsis Menu component to TS (#36405) 2023-04-27 17:00:35 -07:00
style.scss Moved WCA Packages 2022-03-18 14:25:26 -07:00

README.md

EllipsisMenu

This is a dropdown menu hidden behind a vertical ellipsis icon. When clicked, the inner MenuItems are displayed.

Usage

<EllipsisMenu label="Choose which analytics to display"
	renderContent={ ( { onToggle } )=> {
		return (
			<div>
				<MenuTitle>Display stats</MenuTitle>
				<MenuItem onInvoke={ () => setState( { showCustomers: ! showCustomers } ) }>
					<ToggleControl
						label="Show Customers"
						checked={ showCustomers }
						onChange={ () => setState( { showCustomers: ! showCustomers } ) }
					/>
				</MenuItem>
				<MenuItem onInvoke={ () => setState( { showOrders: ! showOrders } ) }>
					<ToggleControl
						label="Show Orders"
						checked={ showOrders }
						onChange={ () => setState( { showOrders: ! showOrders } ) }
					/>
				</MenuItem>
				<MenuItem onInvoke={ onToggle }>
					<Button
						label="Close menu"
						onClick={ onToggle }
					>
					Close Menu
					</Button>
				</MenuItem>
			</div>
		);
	} }
/>

Props

Name Type Default Description
label String null (required) The label shown when hovering/focusing on the icon button
renderContent Function null A function returning MenuTitle/MenuItem components as a render prop. Arguments from Dropdown passed as function arguments

MenuItem

MenuItem is used to give the item an accessible wrapper, with the menuitem role and added keyboard functionality (onInvoke). MenuItems can also be deemed "clickable", though this is disabled by default because generally the inner component handles the click event.

Usage

<MenuItem onInvoke={ onToggle }>
	<Button
		label="Close menu"
		onClick={ onToggle }
	>
	Close Menu
	</Button>
</MenuItem>

Props

Name Type Default Description
checked Boolean null Whether the menu item is checked or not. Only relevant for menu items with isCheckbox
children ReactNode null A renderable component (or string) which will be displayed as the content of this item. Generally a ToggleControl
isCheckbox Boolean false Whether the menu item is a checkbox (will render a FormToggle and use the menuitemcheckbox role)
isClickable Boolean false Boolean to control whether the MenuItem should handle the click event. Defaults to false, assuming your child component handles the click event
onInvoke Function null (required) A function called when this item is activated via keyboard ENTER or SPACE; or when the item is clicked (only if isClickable is set)

MenuTitle

MenuTitle is another valid Menu child, but this does not have any accessibility attributes associated (so this should not be used in place of the EllipsisMenu prop label).

Usage

<MenuTitle>Display stats</MenuTitle>

Props

Name Type Default Description
children ReactNode null A renderable component (or string) which will be displayed as the content of this item