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 2 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,45 @@
/**
* WordPress dependencies
*/
import { speak } from '@wordpress/a11y';
import { Button } from '@wordpress/components';
import { useDispatch, useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { close } from '@wordpress/icons';
import { store as preferencesStore } from '@wordpress/preferences';

const PREFERENCE_NAME = 'isInspectorControlsTabsPointerVisible';

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

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

return (
<div className="block-editor-inspector-controls-tabs__pointer">
<div className="block-editor-inspector-controls-tabs__pointer-content">
{ __(
"Looking for other block settings? They've moved to the styles tab."
) }
</div>
<Button
className="block-editor-inspector-controls-tabs__pointer-dismiss"
icon={ close }
iconSize="16"
label={ __( 'Dismiss' ) }
onClick={ () => {
setPreference( 'core', PREFERENCE_NAME, false );
speak( __( 'Notice dismissed.' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this speak is not needed as long as you manage the focus. I think the context is good enough here with the label itself for a user to know what happened. The only time I really worry about notifying users is if it is urgent information/important information. Examples might include submitting a form and receiving a success/error message or providing navigation instructions in a non-native element, this one is closely related to Gutenberg select/edit modes.

} }
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 SettingsTabPointer from './settings-tab-pointer';

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

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

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

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

.block-editor-inspector-controls-tabs__pointer-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-10 $grid-unit-10 $grid-unit-10 0;
}