Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
be8baa7
adds preference setter in UI
draganescu Jun 1, 2023
65bc029
Fix distraction free toolbar showing
Jun 1, 2023
e3e2299
fix distraction free flag in site editor, revert change in block tool…
draganescu Jun 2, 2023
c983dc9
basic distraction free enabled
draganescu Jun 2, 2023
7969e92
hide header items in distraction free
draganescu Jun 2, 2023
94763dc
fix the JS test for settings
draganescu Jun 15, 2023
f468154
fix the other test for editor settings
draganescu Jun 18, 2023
071bd81
remove the rerendering of the site editor header to maintain focus on…
draganescu Jun 20, 2023
b172b79
animated hader in edit mode for distraction free
draganescu Jun 20, 2023
ea5e647
fix sidebar header
draganescu Jun 21, 2023
edb7eb2
move static objects out of components
draganescu Jun 21, 2023
9171bf7
Refactor distractionFree site editor animations
jeryj Jun 22, 2023
e2db911
Remove invalid animation values for initial and exit
jeryj Jun 22, 2023
61ed821
Fix bug where edit-mode__actions would get stuck in isDistractionFree…
jeryj Jun 22, 2023
a786941
Override animation with !important CSS when focus is within header on…
jeryj Jun 22, 2023
c31b454
Adjust animation exit delay for header so the header remains visible …
jeryj Jun 22, 2023
eedf542
remove hardcoded z-index
draganescu Jun 23, 2023
3cdec4d
turn off distraction free mode when opening the styles sidebar from s…
draganescu Jun 23, 2023
7236c95
add distraction free mode to preferences panel in the site editor
draganescu Jun 23, 2023
ed86a44
Adds the distraction free mode keyboard shortcut
draganescu Jun 23, 2023
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
add distraction free mode to preferences panel in the site editor
  • Loading branch information
draganescu committed Jun 23, 2023
commit 7236c95fe8ba845a005b766ad7965e9dd964815a
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/
import { store as preferencesStore } from '@wordpress/preferences';

export default function EnableFeature( props ) {
const { featureName, ...remainingProps } = props;
const { featureName, onToggle = () => {}, ...remainingProps } = props;
const isChecked = useSelect(
( select ) =>
!! select( preferencesStore ).get( 'core/edit-site', featureName ),
[ featureName ]
);
const { toggle } = useDispatch( preferencesStore );
const onChange = () => toggle( 'core/edit-site', featureName );
const onChange = () => {
onToggle();
toggle( 'core/edit-site', featureName );
};
return (
<BaseOption
onChange={ onChange }
Expand Down
25 changes: 25 additions & 0 deletions packages/edit-site/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,33 @@ import {
} from '@wordpress/interface';
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { useDispatch, useRegistry } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
*/
import EnableFeature from './enable-feature';
import { store as siteEditorStore } from '../../store';

export default function EditSitePreferencesModal( {
isModalActive,
toggleModal,
} ) {
const registry = useRegistry();
const { closeGeneralSidebar, setIsListViewOpened, setIsInserterOpened } =
useDispatch( siteEditorStore );

const { set: setPreference } = useDispatch( preferencesStore );
const toggleDistractionFree = () => {
registry.batch( () => {
setPreference( 'core/edit-site', 'fixedToolbar', false );
setIsInserterOpened( false );
setIsListViewOpened( false );
closeGeneralSidebar();
} );
};

const sections = useMemo( () => [
{
name: 'general',
Expand All @@ -29,6 +46,14 @@ export default function EditSitePreferencesModal( {
'Customize options related to the block editor interface and editing flow.'
) }
>
<EnableFeature
featureName="distractionFree"
onToggle={ toggleDistractionFree }
help={ __(
'Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'
) }
label={ __( 'Distraction free' ) }
/>
<EnableFeature
featureName="focusMode"
help={ __(
Expand Down