Skip to content

Commit

Permalink
remove the experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Jul 30, 2024
1 parent c5690ce commit f2d40d6
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 32 deletions.
95 changes: 95 additions & 0 deletions packages/block-editor/src/components/inserter/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* External dependencies
*/
import clsx from 'clsx';

/**
* WordPress dependencies
*/
import {
forwardRef,
useState,
useCallback,
useMemo,
useRef,
useLayoutEffect,
} from '@wordpress/element';
import { VisuallyHidden, SearchControl, Popover } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useDebouncedInput } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
*/
import Tips from './tips';
import InserterPreviewPanel from './preview-panel';
import BlockTypesTab from './block-types-tab';
import BlockPatternsTab from './block-patterns-tab';
import { PatternCategoryPreviews } from './block-patterns-tab/pattern-category-previews';
import { MediaTab, MediaCategoryPanel } from './media-tab';
import InserterSearchResults from './search-results';
import useInsertionPoint from './hooks/use-insertion-point';
import { store as blockEditorStore } from '../../store';
import TabbedSidebar from '../tabbed-sidebar';
import { useZoomOut } from '../../hooks/use-zoom-out';

// TODO - add back useMemo
export const InserterSearch = ( { filterValue, selectedTab } ) => {
if ( selectedTab === 'media' ) {
return null;
}

return (
<>
<SearchControl
__nextHasNoMarginBottom
className="block-editor-inserter__search"
onChange={ ( value ) => {
if ( hoveredItem ) {
setHoveredItem( null );
}
setFilterValue( value );
} }
value={ filterValue }
label={ __( 'Search for blocks and patterns' ) }
placeholder={ __( 'Search' ) }
/>
{ !! delayedFilterValue && (
<InserterSearchResults
filterValue={ delayedFilterValue }
onSelect={ onSelect }
onHover={ onHover }
onHoverPattern={ onHoverPattern }
rootClientId={ rootClientId }
clientId={ clientId }
isAppender={ isAppender }
__experimentalInsertionIndex={
__experimentalInsertionIndex
}
showBlockDirectory
shouldFocusBlock={ shouldFocusBlock }
prioritizePatterns={ selectedTab === 'patterns' }
/>
) }
</>
);
};
/*[
selectedTab,
hoveredItem,
setHoveredItem,
setFilterValue,
filterValue,
delayedFilterValue,
onSelect,
onHover,
onHoverPattern,
shouldFocusBlock,
clientId,
rootClientId,
__experimentalInsertionIndex,
isAppender,
]
);
*/
52 changes: 20 additions & 32 deletions packages/editor/src/components/preview-dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Icon,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { desktop, mobile, tablet, external } from '@wordpress/icons';
import { mobile, tablet, external } from '@wordpress/icons';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { useEffect, useRef } from '@wordpress/element';
Expand All @@ -26,9 +26,6 @@ import PostPreviewButton from '../post-preview-button';
import { speak } from '@wordpress/a11y';

export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
const isZoomOutExperiment =
!! window.__experimentalEnableZoomedOutPatternsTab;

const {
deviceType,
editorMode,
Expand Down Expand Up @@ -96,7 +93,6 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
const deviceIcons = {
mobile,
tablet,
desktop,
};

/**
Expand All @@ -105,6 +101,16 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
* @type {Array}
*/
const choices = [
{
value: 'Desktop',
label: __( 'Zoom to 100%' ),
icon: <>{ __( '100%' ) }</>,
},
{
value: 'ZoomOut',
label: __( 'Zoom to 50%' ),
icon: <>{ __( '50%' ) }</>,
},
{
value: 'Tablet',
label: __( 'Tablet' ),
Expand All @@ -117,25 +123,6 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
},
];

if ( isZoomOutExperiment ) {
choices.unshift( {
value: 'ZoomOut',
label: __( 'Zoom to 50%' ),
icon: <p>{ __( '50%' ) }</p>,
} );
choices.unshift( {
value: 'ZoomIn',
label: __( 'Zoom to 100%' ),
icon: <p>{ __( '100%' ) }</p>,
} );
} else {
choices.unshift( {
value: 'Desktop',
label: __( 'Desktop' ),
icon: desktop,
} );
}

/**
* The selected choice.
*
Expand Down Expand Up @@ -177,21 +164,22 @@ export default function PreviewDropdown( { forceIsAutosaveable, disabled } ) {
newEditorMode = 'zoom-out';
}

if ( isZoomOutExperiment ) {
__unstableSetEditorMode( newEditorMode );
}
__unstableSetEditorMode( newEditorMode );
};

const getIcon = () => {
switch (deviceType) {
switch ( deviceType ) {
case 'ZoomOut':
return __( '50%' );
case 'ZoomIn':
return __( '100%' );
return <>{ __( '50%' ) }</>;
case 'Desktop':
if ( editorMode === 'zoom-out' ) {
// This can happen if zoom out is enabled from by other means - like the patterns tab.
return <>{ __( '50%' ) }</>;
}
return <>{ __( '100%' ) }</>;
default:
return deviceIcons[ deviceType.toLowerCase() ];
}
}
};

return (
Expand Down

0 comments on commit f2d40d6

Please sign in to comment.