From 4e9acb524d8c9a8c8b4efa1909a2f23de4c3836a Mon Sep 17 00:00:00 2001 From: Jan Jakes Date: Thu, 7 Jul 2022 11:33:44 +0200 Subject: [PATCH] Add step card component and render it in step sidebar [MAILPOET-4420] --- .../_step-card.scss | 33 +++++++++++++++ .../css/src/mailpoet-automation-editor.scss | 1 + .../editor/components/sidebar/step/index.tsx | 40 ++++++++++++------- .../editor/components/step-card/index.tsx | 24 +++++++++++ .../js/src/automation/editor/store/types.ts | 2 + 5 files changed, 85 insertions(+), 15 deletions(-) create mode 100644 mailpoet/assets/css/src/components-automation-editor/_step-card.scss create mode 100644 mailpoet/assets/js/src/automation/editor/components/step-card/index.tsx diff --git a/mailpoet/assets/css/src/components-automation-editor/_step-card.scss b/mailpoet/assets/css/src/components-automation-editor/_step-card.scss new file mode 100644 index 0000000000..3bcc5c3457 --- /dev/null +++ b/mailpoet/assets/css/src/components-automation-editor/_step-card.scss @@ -0,0 +1,33 @@ +// See: https://github.com/WordPress/gutenberg/blob/af7da80dd54d7fe52772890e2cc1b65073db9655/packages/block-editor/src/components/block-card/style.scss + +.block-editor-block-card { + align-items: flex-start; + display: flex; + padding: 16px; +} + +.block-editor-block-card__content { + flex-grow: 1; + margin-bottom: 4px; +} + +.block-editor-block-card__title { + font-weight: 500; + + &.block-editor-block-card__title { + line-height: 24px; + margin: 0 0 4px; + } +} + +.block-editor-block-card__description { + font-size: 13px; +} + +.block-editor-block-card .block-editor-block-icon { + flex: 0 0 24px; + height: 24px; + margin-left: 0; + margin-right: 12px; + width: 24px; +} diff --git a/mailpoet/assets/css/src/mailpoet-automation-editor.scss b/mailpoet/assets/css/src/mailpoet-automation-editor.scss index 77aa858426..015b89c5cd 100644 --- a/mailpoet/assets/css/src/mailpoet-automation-editor.scss +++ b/mailpoet/assets/css/src/mailpoet-automation-editor.scss @@ -10,4 +10,5 @@ @import './components-automation-editor/separator'; @import './components-automation-editor/status'; @import './components-automation-editor/step'; +@import './components-automation-editor/step-card'; @import './components-automation-editor/workflow'; diff --git a/mailpoet/assets/js/src/automation/editor/components/sidebar/step/index.tsx b/mailpoet/assets/js/src/automation/editor/components/sidebar/step/index.tsx index da9a6cc8d6..f5593ab929 100644 --- a/mailpoet/assets/js/src/automation/editor/components/sidebar/step/index.tsx +++ b/mailpoet/assets/js/src/automation/editor/components/sidebar/step/index.tsx @@ -1,11 +1,13 @@ import { PanelBody } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; import { store } from '../../../store'; +import { StepCard } from '../../step-card'; export function StepSidebar(): JSX.Element { - const { selectedStep } = useSelect( + const { selectedStep, selectedStepType } = useSelect( (select) => ({ selectedStep: select(store).getSelectedStep(), + selectedStepType: select(store).getSelectedStepType(), }), [], ); @@ -15,19 +17,27 @@ export function StepSidebar(): JSX.Element { } return ( - -
- ID: {selectedStep.id} -
-
- Type: {selectedStep.type} -
-
- Key: {selectedStep.key} -
-
- Args: {JSON.stringify(selectedStep.args)} -
-
+
+ + + +
+ ID: {selectedStep.id} +
+
+ Type: {selectedStep.type} +
+
+ Key: {selectedStep.key} +
+
+ Args: {JSON.stringify(selectedStep.args)} +
+
+
); } diff --git a/mailpoet/assets/js/src/automation/editor/components/step-card/index.tsx b/mailpoet/assets/js/src/automation/editor/components/step-card/index.tsx new file mode 100644 index 0000000000..863988ce7d --- /dev/null +++ b/mailpoet/assets/js/src/automation/editor/components/step-card/index.tsx @@ -0,0 +1,24 @@ +import { ComponentType } from 'react'; +import { StepIcon } from '../step-icon'; + +// See: https://github.com/WordPress/gutenberg/blob/af7da80dd54d7fe52772890e2cc1b65073db9655/packages/block-editor/src/components/block-card/index.js + +type Props = { + title: string; + description: string; + icon: ComponentType; +}; + +export function StepCard({ title, description, icon }: Props): JSX.Element { + return ( +
+ +
+

{title}

+ + {description} + +
+
+ ); +} diff --git a/mailpoet/assets/js/src/automation/editor/store/types.ts b/mailpoet/assets/js/src/automation/editor/store/types.ts index 341a32dccb..448651f222 100644 --- a/mailpoet/assets/js/src/automation/editor/store/types.ts +++ b/mailpoet/assets/js/src/automation/editor/store/types.ts @@ -1,3 +1,4 @@ +import { ComponentType } from 'react'; import { Item } from '../components/inserter/item'; import { Step, Workflow } from '../components/workflow/types'; @@ -9,6 +10,7 @@ export type StepType = { key: string; title: string; description: string; + icon: ComponentType; }; export type State = {