Skip to content

Commit

Permalink
Remove unnecessary styles and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Dec 4, 2023
1 parent c2a9bb0 commit f8ee53e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 62 deletions.
30 changes: 1 addition & 29 deletions packages/block-library/src/form/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import {
useBlockProps,
useInnerBlocksProps,
InspectorControls,
__experimentalUseBorderProps as useBorderProps,
__experimentalUseColorProps as useColorProps,
__experimentalGetSpacingClassesAndStyles as useSpacingProps,
getTypographyClassesAndStyles as useTypographyProps,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { TextControl, SelectControl, PanelBody } from '@wordpress/components';
Expand All @@ -24,11 +20,6 @@ import {
formSubmissionNotificationError,
} from './utils.js';

/**
* External dependencies
*/
import classNames from 'classnames';

const ALLOWED_BLOCKS = [
'core/paragraph',
'core/heading',
Expand Down Expand Up @@ -69,7 +60,7 @@ const TEMPLATE = [
[ 'core/form-submit-button', {} ],
];

const Edit = ( { attributes, setAttributes, className, clientId } ) => {
const Edit = ( { attributes, setAttributes, clientId } ) => {
const { action, method, email, submissionMethod } = attributes;
const blockProps = useBlockProps();

Expand All @@ -92,11 +83,6 @@ const Edit = ( { attributes, setAttributes, className, clientId } ) => {
: InnerBlocks.ButtonBlockAppender,
} );

const borderProps = useBorderProps( attributes );
const colorProps = useColorProps( attributes );
const spacingProps = useSpacingProps( attributes );
const typographyProps = useTypographyProps( attributes );

return (
<>
<InspectorControls>
Expand Down Expand Up @@ -186,20 +172,6 @@ const Edit = ( { attributes, setAttributes, className, clientId } ) => {
) }
<form
{ ...innerBlocksProps }
style={ {
...borderProps.style,
...colorProps.style,
...spacingProps.style,
...typographyProps.style,
} }
className={ classNames(
className,
'wp-block-form',
colorProps.className,
borderProps.className,
spacingProps.className,
typographyProps.className
) }
encType={ submissionMethod === 'email' ? 'text/plain' : null }
/>
</>
Expand Down
35 changes: 2 additions & 33 deletions packages/block-library/src/form/save.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
/**
* WordPress dependencies
*/
import {
InnerBlocks,
useBlockProps,
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
__experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,
getTypographyClassesAndStyles as useTypographyProps,
} from '@wordpress/block-editor';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';

/**
* External dependencies
*/
import classNames from 'classnames';

const Save = ( { attributes, className } ) => {
const Save = ( { attributes } ) => {
const blockProps = useBlockProps.save();
const { submissionMethod } = attributes;

const borderProps = getBorderClassesAndStyles( attributes );
const colorProps = getColorClassesAndStyles( attributes );
const spacingProps = getSpacingClassesAndStyles( attributes );
const typographyProps = useTypographyProps( attributes );

return (
<form
{ ...blockProps }
style={ {
...borderProps.style,
...colorProps.style,
...spacingProps.style,
...typographyProps.style,
} }
className={ classNames(
className,
'wp-block-form',
colorProps.className,
borderProps.className,
spacingProps.className,
typographyProps.className
) }
encType={ submissionMethod === 'email' ? 'text/plain' : null }
>
<InnerBlocks.Content />
Expand Down

0 comments on commit f8ee53e

Please sign in to comment.