Skip to content

Commit

Permalink
Move preferences toggle to Publishing
Browse files Browse the repository at this point in the history
Removed modal footer and related components
  • Loading branch information
ramonjd committed Sep 6, 2024
1 parent c3e41ab commit 01552df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 48 deletions.
20 changes: 10 additions & 10 deletions packages/editor/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
/>
</PreferencesModalSection>
) }
{ starterPatterns?.length && (
<PreferenceToggleControl
scope="core"
featureName="enableChoosePatternModal"
help={ __(
'Shows starter patterns when creating a new page.'
) }
label={ __( 'Show starter patterns' ) }
/>
) }
{ extraSections?.general }
</>
),
Expand Down Expand Up @@ -210,16 +220,6 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
) }
label={ __( 'Spotlight mode' ) }
/>
{ starterPatterns?.length && (
<PreferenceToggleControl
scope="core"
featureName="enableChoosePatternModal"
help={ __(
'Shows starter patterns when creating a new page.'
) }
label={ __( 'Show starter patterns' ) }
/>
) }
{ extraSections?.appearance }
</PreferencesModalSection>
),
Expand Down
43 changes: 5 additions & 38 deletions packages/editor/src/components/start-page-options/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/**
* WordPress dependencies
*/
import {
Button,
CheckboxControl,
Modal,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { Modal } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useState, useMemo } from '@wordpress/element';
import {
Expand Down Expand Up @@ -98,53 +93,25 @@ function PatternSelection( { blockPatterns, onChoosePattern } ) {
}

function StartPageOptionsModal( { onClose } ) {
const { set: setPreference } = useDispatch( preferencesStore );
const [ disablePreference, setDisablePreference ] = useState( false );
const startPatterns = useStartPatterns();
const hasStartPattern = startPatterns.length > 0;

if ( ! startPatterns.length ) {
return;
if ( ! hasStartPattern ) {
return null;
}

return (
<Modal
title={ __( 'Choose a pattern' ) }
isFullScreen
isDismissible={ false }
onRequestClose={ onClose }
>
<div className="editor-start-page-options__modal-content">
<PatternSelection
blockPatterns={ startPatterns }
onChoosePattern={ onClose }
/>
</div>
<div className="editor-start-page-options__modal-footer">
<HStack justify="space-between" spacing={ 8 }>
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Do not show me this again' ) }
onChange={ ( newValue ) =>
setDisablePreference( newValue )
}
/>
<Button
__next40pxDefaultSize={ false }
variant="secondary"
onClick={ () => {
if ( disablePreference ) {
setPreference(
'core',
'enableChoosePatternModal',
false
);
}
onClose();
} }
>
{ __( 'Skip' ) }
</Button>
</HStack>
</div>
</Modal>
);
}
Expand Down

0 comments on commit 01552df

Please sign in to comment.