From 94fbc400b05e6cb70ec0ec39a03569fdce7f7bf2 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 7 Jul 2023 17:20:49 +0300 Subject: [PATCH] chore: design changes for field preview --- src/blocks/blocks/content-generator/edit.js | 16 ++++--- src/blocks/components/prompt/editor.scss | 46 ++++++++++----------- src/blocks/components/prompt/index.tsx | 28 ++++++++----- 3 files changed, 50 insertions(+), 40 deletions(-) diff --git a/src/blocks/blocks/content-generator/edit.js b/src/blocks/blocks/content-generator/edit.js index 8448e6226..a06af730f 100644 --- a/src/blocks/blocks/content-generator/edit.js +++ b/src/blocks/blocks/content-generator/edit.js @@ -31,6 +31,7 @@ import Inspector from './inspector.js'; import PromptPlaceholder from '../../components/prompt'; import { parseFormPromptResponseToBlocks } from '../../helpers/prompt'; import { useDispatch, useSelect } from '@wordpress/data'; +import { __ } from '@wordpress/i18n'; const { attributes: defaultAttributes } = metadata; @@ -159,13 +160,16 @@ const ContentGenerator = ({ onSuccess={onSuccess} /> - - - - + { + hasInnerBlocks ? ( + + + + ) : '' + } { - showActionsButton && ( + showActionsButton ? (
- ) + ) : '' } diff --git a/src/blocks/components/prompt/editor.scss b/src/blocks/components/prompt/editor.scss index cd69b185f..7a780fcdc 100644 --- a/src/blocks/components/prompt/editor.scss +++ b/src/blocks/components/prompt/editor.scss @@ -4,36 +4,34 @@ flex-direction: column; } - .prompt-placeholder__block-generation__container { - margin: 10px; - display: flex; - flex-direction: column; - padding: 10px; - border-radius: 10px; - gap: 10px; + + + .history-display { + padding: 0px 20px; font-size: 1.2em; + } +} - background-color: #FAA26A; +.prompt-fields { + margin: 10px; + display: grid; + grid-template-columns: 1fr 1fr; + padding: 10px; + border-radius: 10px; + gap: 10px; + font-size: 13px; - .prompt-placeholder__block-generation__field { - display: flex; - flex-direction: row; - gap: 10px; - align-items: center; - } + .prompt-column-title { + text-transform: uppercase; + } - .prompt-placeholder__block-generation__field__type { - padding: 1px 5px; - background-color: azure; - border-radius: 5px; - min-width: 100px; - text-align: center; - } + .prompt-field__label, .prompt-field__type { + padding: 12px 16px; } - .history-display { - padding: 0px 20px; - font-size: 1.2em; + .prompt-field__label { + border-radius: 3px; + background: rgba(159, 171, 178, 0.20); } } diff --git a/src/blocks/components/prompt/index.tsx b/src/blocks/components/prompt/index.tsx index 86b495a12..d8977d1b5 100644 --- a/src/blocks/components/prompt/index.tsx +++ b/src/blocks/components/prompt/index.tsx @@ -35,17 +35,23 @@ export const apiKeyName = 'themeisle_open_ai_api_key'; const BlockGenerationArea = ( props: { result?: string }) => { return ( -
+
+
+ { __( 'Label', 'otter-blocks' ) } +
+
+ { __( 'Field Type', 'otter-blocks' ) } +
{ props.result?.length && parseToDisplayPromptResponse( props.result ).map( field => { return ( -
-
- { field.type } -
-
+ +
{ field.label }
-
+
+ { field.type } +
+ ); }) }
@@ -104,6 +110,7 @@ const PromptResultArea = ( variant={'tertiary'} icon={undo} onClick={ props.onPrevResult } + disabled={ 1 === props.currentResultIndex } />
@@ -114,6 +121,7 @@ const PromptResultArea = ( variant={'tertiary'} icon={redo} onClick={ props.onNextResult } + disabled={ props.totalResults === props.currentResultIndex } /> ) @@ -139,7 +147,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => { const [ resultHistory, setResultHistory ] = useState([]); const [ resultHistoryIndex, setResultHistoryIndex ] = useState( 0 ); - const [ showResultArea, setShowResultArea ] = useState( true ); + const [ showResultArea, setShowResultArea ] = useState( false ); const onSuccessActions = { clearHistory: () => { @@ -312,7 +320,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => { onSuccess?.( result, onSuccessActions ); } } - currentResultIndex={ resultHistoryIndex } + currentResultIndex={ resultHistoryIndex + 1 } totalResults={ resultHistory.length } onPrevResult={() => { setResultHistoryIndex( resultHistoryIndex - 1 ); @@ -323,7 +331,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => { onClose={() => { setShowResultArea( false ); }} - mainActionName={props.resultAreaTitle} + mainActionName={props.resutActionLabel} >