Skip to content

Commit

Permalink
Draft ToolsPanel JSDoc example comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw authored and ciampo committed Feb 13, 2023
1 parent 8673259 commit 86d61c7
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/components/src/tools-panel/tools-panel/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,58 @@ const UnconnectedToolsPanel = (
);
};

/**
* The `ToolsPanel` is a container component that displays its children preceded
* by a header. The header includes a dropdown menu which is automatically
* generated from the panel's inner `ToolsPanelItems`.
*
* @example
* ```jsx
* import { __ } from '@wordpress/i18n';
* import {
* __experimentalToolsPanel as ToolsPanel,
* __experimentalToolsPanelItem as ToolsPanelItem,
* __experimentalUnitControl as UnitControl
* } from '@wordpress/components';
*
* function Example() {
* const [ height, setHeight ] = useState();
* const [ width, setWidth ] = useState();
*
* const resetAll = () => {
* setHeight();
* setWidth();
* }
*
* return (
* <ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
* <ToolsPanelItem
* hasValue={ () => !! height }
* label={ __( 'Height' ) }
* onDeselect={ () => setHeight() }
* >
* <UnitControl
* label={ __( 'Height' ) }
* onChange={ setHeight }
* value={ height }
* />
* </ToolsPanelItem>
* <ToolsPanelItem
* hasValue={ () => !! width }
* label={ __( 'Width' ) }
* onDeselect={ () => setWidth() }
* >
* <UnitControl
* label={ __( 'Width' ) }
* onChange={ setWidth }
* value={ width }
* />
* </ToolsPanelItem>
* </ToolsPanel>
* );
* }
* ```
*/
export const ToolsPanel = contextConnect( UnconnectedToolsPanel, 'ToolsPanel' );

export default ToolsPanel;

0 comments on commit 86d61c7

Please sign in to comment.