From be29ee04a60ba2e3eeaf8fd175dbd24cd6ac0157 Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Fri, 13 May 2022 11:41:46 +0200 Subject: [PATCH] Add basic sidebar [MAILPOET-4287] --- .../editor/components/sidebar/index.tsx | 38 +++++++++++++++++++ .../assets/js/src/automation/editor/index.tsx | 17 ++++++--- .../assets/js/src/types/wordpress_modules.ts | 1 + 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 mailpoet/assets/js/src/automation/editor/components/sidebar/index.tsx diff --git a/mailpoet/assets/js/src/automation/editor/components/sidebar/index.tsx b/mailpoet/assets/js/src/automation/editor/components/sidebar/index.tsx new file mode 100644 index 0000000000..241df3f459 --- /dev/null +++ b/mailpoet/assets/js/src/automation/editor/components/sidebar/index.tsx @@ -0,0 +1,38 @@ +import { ComponentProps } from 'react'; +import { Platform } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; +import { cog } from '@wordpress/icons'; +import { ComplementaryArea } from '@wordpress/interface'; +import { storeName } from '../../store'; + +// See: +// https://github.com/WordPress/gutenberg/blob/5caeae34b3fb303761e3b9432311b26f4e5ea3a6/packages/edit-post/src/components/sidebar/plugin-sidebar/index.js +// https://github.com/WordPress/gutenberg/blob/5caeae34b3fb303761e3b9432311b26f4e5ea3a6/packages/edit-post/src/components/sidebar/settings-sidebar/index.js + +const sidebarActiveByDefault = Platform.select({ + web: true, + native: false, +}); + +type Props = ComponentProps; + +export function Sidebar(props: Props): JSX.Element { + const workflowName = 'Testing workflow'; + return ( + + Sidebar + + ); +} diff --git a/mailpoet/assets/js/src/automation/editor/index.tsx b/mailpoet/assets/js/src/automation/editor/index.tsx index 984e1e7db4..24ea8476af 100644 --- a/mailpoet/assets/js/src/automation/editor/index.tsx +++ b/mailpoet/assets/js/src/automation/editor/index.tsx @@ -1,9 +1,15 @@ import classnames from 'classnames'; import ReactDOM from 'react-dom'; +import { SlotFillProvider } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; -import { InterfaceSkeleton, FullscreenMode } from '@wordpress/interface'; +import { + ComplementaryArea, + InterfaceSkeleton, + FullscreenMode, +} from '@wordpress/interface'; import { Header } from './components/header'; -import { store } from './store'; +import { Sidebar } from './components/sidebar'; +import { store, storeName } from './store'; // See: https://github.com/WordPress/gutenberg/blob/9601a33e30ba41bac98579c8d822af63dd961488/packages/edit-post/src/components/layout/index.js @@ -21,16 +27,17 @@ function Editor(): JSX.Element { ); return ( - <> + + } content={
Content
} - sidebar={
Sidebar
} + sidebar={} secondarySidebar={
Secondary sidebar
} /> - +
); } diff --git a/mailpoet/assets/js/src/types/wordpress_modules.ts b/mailpoet/assets/js/src/types/wordpress_modules.ts index e742667c06..5cd526fe66 100644 --- a/mailpoet/assets/js/src/types/wordpress_modules.ts +++ b/mailpoet/assets/js/src/types/wordpress_modules.ts @@ -2,6 +2,7 @@ // there are no @types/wordpress__interface yet declare module '@wordpress/interface' { + export const ComplementaryArea: any; export const FullscreenMode: any; export const MoreMenuDropdown: any; export const InterfaceSkeleton: any;