From 972d62a5cf2d12c7f0fd71923b51bb6ea0faf713 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Sat, 22 Jan 2022 22:20:12 -0500 Subject: [PATCH] Add initial block controls --- src/edit.tsx | 103 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/src/edit.tsx b/src/edit.tsx index f00e35c..ade1e83 100644 --- a/src/edit.tsx +++ b/src/edit.tsx @@ -2,7 +2,13 @@ import * as React from 'react'; import { __ } from '@wordpress/i18n'; import { BlockEditProps } from '@wordpress/blocks'; -import { Placeholder, ExternalLink } from '@wordpress/components'; +import { Placeholder, ExternalLink, ToolbarButton } from '@wordpress/components'; +import { edit } from '@wordpress/icons'; + +import { + BlockControls, + InspectorControls, +} from '@wordpress/block-editor'; import CogIcon from '@/assets/cogicon'; import SelectDialog from '@/components/select-dialog'; @@ -20,36 +26,83 @@ const Edit: React.FC> = ( { attributes, setAttri } ); }; + const resetForm = () => { + // Create a new object which sets all attributes to null + const nullAttributes = Object.keys( attributes ).reduce( + ( accumulator, current ) => { + // @ts-ignore + accumulator[ current ] = null; + return accumulator; + }, {} ); + + setAttributes( nullAttributes ); + }; + if ( ! attributes.formId ) { return ( - - -
-
- - { __( 'Learn more about embeds' ) } - -
-
+
+ + +
+
+ + { __( 'Learn more about embeds' ) } + +
+
+
); } return ( - +
+ { + + resetForm() } + /> + + } + + +
+
+ + { __( 'Background color', 'gutenpride' ) } + + {/* */} +
+
+ + { __( 'Text color', 'gutenpride' ) } + + {/* */} +
+
+
+ + +
); };