Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid class names for public API use and replace them with specific d…
…ata attrs
  • Loading branch information
Andrei Draganescu committed Jul 13, 2021
commit cd82bda6fd43dbcf5eab20186e37a467a948b8a9
15 changes: 2 additions & 13 deletions packages/edit-widgets/src/blocks/widget-area/edit/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
Expand All @@ -14,7 +9,6 @@ import {
Panel,
PanelBody,
} from '@wordpress/components';
import { cleanForSlug } from '@wordpress/url';

/**
* Internal dependencies
Expand All @@ -30,11 +24,6 @@ export default function WidgetAreaEdit( {
className,
attributes: { id, name },
} ) {
const areaClassName = classnames(
className,
'widget-area',
cleanForSlug( name )
);
const isOpen = useSelect(
( select ) =>
select( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),
Expand Down Expand Up @@ -66,7 +55,7 @@ export default function WidgetAreaEdit( {
}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );

return (
<Panel className={ areaClassName } ref={ wrapper }>
<Panel className={ className } ref={ wrapper }>
<PanelBody
title={ name }
opened={ isOpen }
Expand All @@ -89,7 +78,7 @@ export default function WidgetAreaEdit( {
type="postType"
id={ `widget-area-${ id }` }
>
<WidgetAreaInnerBlocks />
<WidgetAreaInnerBlocks id={ id } />
</EntityProvider>
</DisclosureContent>
) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { useRef } from '@wordpress/element';
*/
import useIsDraggingWithin from './use-is-dragging-within';

export default function WidgetAreaInnerBlocks() {
export default function WidgetAreaInnerBlocks( { id } ) {
const [ blocks, onInput, onChange ] = useEntityBlockEditor(
'root',
'postType'
Expand All @@ -40,6 +40,7 @@ export default function WidgetAreaInnerBlocks() {

return (
<div
data-widget-area-id={ id }
className={ classnames(
'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',
{
Expand Down
1 change: 0 additions & 1 deletion packages/widgets/src/blocks/legacy-widget/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ function NotEmpty( {
idBase={ idBase }
instance={ instance }
isVisible={ mode === 'preview' }
name={ widgetType.name }
/>
) }
{ hasPreview === false && mode === 'preview' && (
Expand Down
6 changes: 3 additions & 3 deletions packages/widgets/src/blocks/legacy-widget/edit/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import classnames from 'classnames';
* WordPress dependencies
*/
import { useRefEffect } from '@wordpress/compose';
import { addQueryArgs, cleanForSlug } from '@wordpress/url';
import { addQueryArgs } from '@wordpress/url';
import { useState } from '@wordpress/element';
import { Placeholder, Spinner, Disabled } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

export default function Preview( { idBase, instance, isVisible, name } ) {
export default function Preview( { idBase, instance, isVisible } ) {
const [ isLoaded, setIsLoaded ] = useState( false );

// Resize the iframe on either the load event, or when the iframe becomes visible.
Expand Down Expand Up @@ -77,8 +77,8 @@ export default function Preview( { idBase, instance, isVisible, name } ) {
</Placeholder>
) }
<div
data-widget-preview-id={ idBase }
className={ classnames(
cleanForSlug( 'widget_' + name ),
'wp-block-legacy-widget__edit-preview',
{
'is-offscreen': ! isVisible || ! isLoaded,
Expand Down