Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a pointer/hint in the settings tab informing the user about the styles tab #47670

Merged
merged 6 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@wordpress/keyboard-shortcuts": "file:../keyboard-shortcuts",
"@wordpress/keycodes": "file:../keycodes",
"@wordpress/notices": "file:../notices",
"@wordpress/preferences": "file:../preferences",
"@wordpress/rich-text": "file:../rich-text",
"@wordpress/shortcode": "file:../shortcode",
"@wordpress/style-engine": "file:../style-engine",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* WordPress dependencies
*/
import { Button } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { focus } from '@wordpress/dom';
import { useRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { close } from '@wordpress/icons';
import { store as preferencesStore } from '@wordpress/preferences';

const PREFERENCE_NAME = 'isInspectorControlsTabsHintVisible';

export default function InspectorControlsTabsHint() {
const isInspectorControlsTabsHintVisible = useSelect(
( select ) =>
select( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,
[]
);

const ref = useRef();

const { set: setPreference } = useDispatch( preferencesStore );
if ( ! isInspectorControlsTabsHintVisible ) {
return null;
}

return (
<div ref={ ref } className="block-editor-inspector-controls-tabs__hint">
<div className="block-editor-inspector-controls-tabs__hint-content">
{ __(
"Looking for other block settings? They've moved to the styles tab."
) }
</div>
<Button
className="block-editor-inspector-controls-tabs__hint-dismiss"
icon={ close }
iconSize="16"
label={ __( 'Dismiss hint' ) }
onClick={ () => {
// Retain focus when dismissing the element.
const previousElement = focus.tabbable.findPrevious(
ref.current
);
previousElement?.focus();
setPreference( 'core', PREFERENCE_NAME, false );
} }
showTooltip={ false }
/>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import AdvancedControls from './advanced-controls-panel';
import PositionControls from './position-controls-panel';
import { default as InspectorControls } from '../inspector-controls';
import SettingsTabHint from './settings-tab-hint';

const SettingsTab = ( { showAdvancedControls = false } ) => (
<>
Expand All @@ -14,6 +15,7 @@ const SettingsTab = ( { showAdvancedControls = false } ) => (
<AdvancedControls />
</div>
) }
<SettingsTabHint />
</>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,23 @@
}
}
}

.block-editor-inspector-controls-tabs__hint {
align-items: top;
background: $gray-100;
border-radius: $radius-block-ui;
color: $gray-900;
display: flex;
flex-direction: row;
margin: $grid-unit-20;
}

.block-editor-inspector-controls-tabs__hint-content {
margin: $grid-unit-15 0 $grid-unit-15 $grid-unit-15;
}

.block-editor-inspector-controls-tabs__hint-dismiss {
// The dismiss button has a lot of empty space through its padding.
// Apply margin to visually align the icon with the top of the text to its left.
margin: $grid-unit-05 $grid-unit-05 $grid-unit-05 0;
}