Skip to content

Commit

Permalink
Add "Show block breadcrumbs" preference (#28133)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 authored Jan 20, 2021
1 parent 1c59a2c commit e9c7561
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
12 changes: 12 additions & 0 deletions packages/e2e-tests/specs/editor/plugins/block-variations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
searchForBlock,
pressKeyWithModifier,
openDocumentSettingsSidebar,
toggleScreenOption,
toggleMoreMenu,
} from '@wordpress/e2e-test-utils';

describe( 'Block variations', () => {
Expand Down Expand Up @@ -107,6 +109,16 @@ describe( 'Block variations', () => {
} );
// @see @wordpres/block-editor/src/components/use-block-display-information (`useBlockDisplayInformation` hook).
describe( 'testing block display information with matching variations', () => {
beforeEach( async () => {
await toggleScreenOption( 'Display block breadcrumbs', true );
await toggleMoreMenu();
} );

afterEach( async () => {
await toggleScreenOption( 'Display block breadcrumbs', false );
await toggleMoreMenu();
} );

const getActiveBreadcrumb = async () =>
page.evaluate(
() =>
Expand Down
5 changes: 5 additions & 0 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function Layout( { styles } ) {
isInserterOpened,
showIconLabels,
hasReducedUI,
showBlockBreadcrumbs,
} = useSelect( ( select ) => {
return {
hasFixedToolbar: select( editPostStore ).isFeatureActive(
Expand Down Expand Up @@ -129,6 +130,9 @@ function Layout( { styles } ) {
hasReducedUI: select( editPostStore ).isFeatureActive(
'reducedUI'
),
showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
'showBlockBreadcrumbs'
),
};
}, [] );
const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
Expand Down Expand Up @@ -269,6 +273,7 @@ function Layout( { styles } ) {
}
footer={
! hasReducedUI &&
showBlockBreadcrumbs &&
! isMobileViewport &&
isRichEditingEnabled &&
mode === 'visual' && (
Expand Down
33 changes: 31 additions & 2 deletions packages/edit-post/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { get } from 'lodash';
*/
import { Modal } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { withSelect, withDispatch, useSelect } from '@wordpress/data';
import { compose, useViewportMatch } from '@wordpress/compose';
import {
PostTaxonomies,
PostExcerptCheck,
Expand All @@ -34,9 +34,26 @@ import { store as editPostStore } from '../../store';
const MODAL_NAME = 'edit-post/preferences';

export function PreferencesModal( { isModalActive, isViewable, closeModal } ) {
const isMobileViewport = useViewportMatch( 'medium', '<' );
const { mode, isRichEditingEnabled, hasReducedUI } = useSelect(
( select ) => {
return {
mode: select( editPostStore ).getEditorMode(),
isRichEditingEnabled: select(
'core/editor'
).getEditorSettings().richEditingEnabled,
hasReducedUI: select( editPostStore ).isFeatureActive(
'reducedUI'
),
};
},
[]
);

if ( ! isModalActive ) {
return null;
}

return (
<Modal
className="edit-post-preferences-modal"
Expand Down Expand Up @@ -93,6 +110,18 @@ export function PreferencesModal( { isModalActive, isViewable, closeModal } ) {
help={ __( 'Make the editor look like your theme.' ) }
label={ __( 'Use theme styles' ) }
/>
{ ! hasReducedUI &&
! isMobileViewport &&
isRichEditingEnabled &&
mode === 'visual' && (
<EnableFeature
featureName="showBlockBreadcrumbs"
help={ __(
'Shows block breadcrumbs at the bottom of the editor.'
) }
label={ __( 'Display block breadcrumbs' ) }
/>
) }
</Section>
<Section
title={ __( 'Document settings' ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ exports[`PreferencesModal should match snapshot when the modal is active 1`] = `
help="Make the editor look like your theme."
label="Use theme styles"
/>
<WithSelect(WithDispatch(BaseOption))
featureName="showBlockBreadcrumbs"
help="Shows block breadcrumbs at the bottom of the editor."
label="Display block breadcrumbs"
/>
</Section>
<Section
description="Choose what displays in the panel."
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/store/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const PREFERENCES_DEFAULTS = {
fullscreenMode: true,
showIconLabels: false,
themeStyles: true,
showBlockBreadcrumbs: true,
},
hiddenBlockTypes: [],
preferredStyleVariations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function InterfaceSkeleton(
className={ classnames(
className,
'interface-interface-skeleton',
regionsClassName
regionsClassName,
!! footer && 'has-footer'
) }
>
{ !! drawer && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ html.interface-interface-skeleton__html-container {
overscroll-behavior-y: none;

// Footer overlap prevention
@include break-medium() {
padding-bottom: $button-size-small + $border-width;
.has-footer & {
@include break-medium() {
padding-bottom: $button-size-small + $border-width;
}
}
}

Expand Down

0 comments on commit e9c7561

Please sign in to comment.