diff --git a/packages/js/product-editor/changelog/add-38489 b/packages/js/product-editor/changelog/add-38489 new file mode 100644 index 00000000000..0ab116b64de --- /dev/null +++ b/packages/js/product-editor/changelog/add-38489 @@ -0,0 +1,4 @@ +Significance: minor +Type: add + +Add the list view component and button to the modal editor diff --git a/packages/js/product-editor/src/components/iframe-editor/context.ts b/packages/js/product-editor/src/components/iframe-editor/context.ts index ce1518769c8..7703387d989 100644 --- a/packages/js/product-editor/src/components/iframe-editor/context.ts +++ b/packages/js/product-editor/src/components/iframe-editor/context.ts @@ -6,8 +6,10 @@ import { createContext } from '@wordpress/element'; type EditorContextType = { hasRedo: boolean; hasUndo: boolean; + isDocumentOverviewOpened: boolean; isInserterOpened: boolean; redo: () => void; + setIsDocumentOverviewOpened: ( value: boolean ) => void; setIsInserterOpened: ( value: boolean ) => void; undo: () => void; }; @@ -15,8 +17,10 @@ type EditorContextType = { export const EditorContext = createContext< EditorContextType >( { hasRedo: false, hasUndo: false, + isDocumentOverviewOpened: false, isInserterOpened: false, redo: () => {}, + setIsDocumentOverviewOpened: () => {}, setIsInserterOpened: () => {}, undo: () => {}, } ); diff --git a/packages/js/product-editor/src/components/iframe-editor/header-toolbar/document-overview/document-overview.tsx b/packages/js/product-editor/src/components/iframe-editor/header-toolbar/document-overview/document-overview.tsx new file mode 100644 index 00000000000..7811333fbc2 --- /dev/null +++ b/packages/js/product-editor/src/components/iframe-editor/header-toolbar/document-overview/document-overview.tsx @@ -0,0 +1,41 @@ +/** + * External dependencies + */ +import { Button } from '@wordpress/components'; +import { createElement, forwardRef, useContext } from '@wordpress/element'; +import { listView as listViewIcon } from '@wordpress/icons'; +import { __ } from '@wordpress/i18n'; +import { Ref } from 'react'; + +/** + * Internal dependencies + */ +import { DocumentOverviewProps } from './types'; +import { EditorContext } from '../../context'; + +export const DocumentOverview = forwardRef( + function ForwardedRefDocumentOverview( + props: DocumentOverviewProps, + ref: Ref< HTMLButtonElement > + ) { + const { isDocumentOverviewOpened, setIsDocumentOverviewOpened } = + useContext( EditorContext ); + + function handleClick() { + setIsDocumentOverviewOpened( ! isDocumentOverviewOpened ); + } + + return ( +