From 310f4d1633d59cbbbdb1589e8ae7aa0e1ed1abd9 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:39:53 +1000 Subject: [PATCH 1/3] Explore text only mode for inspector tabs --- packages/block-editor/package.json | 1 + .../use-inspector-controls-tabs.js | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json index 7673886369ab9a..4f28526e3386ed 100644 --- a/packages/block-editor/package.json +++ b/packages/block-editor/package.json @@ -53,6 +53,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", diff --git a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js index fbe072fab11c58..ae82d2edb60e49 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js @@ -3,6 +3,7 @@ */ import { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; +import { store as preferencesStore } from '@wordpress/preferences'; /** * Internal dependencies @@ -46,12 +47,23 @@ export default function useInspectorControlsTabs( blockName ) { typography: typographyGroup, } = InspectorControlsGroups; + const showIconLabels = useSelect( ( select ) => { + return select( preferencesStore ).get( + 'core/edit-post', + 'showIconLabels' + ); + } ); + // List View Tab: If there are any fills for the list group add that tab. const listViewDisabled = useIsListViewTabDisabled( blockName ); const listFills = useSlotFills( listGroup.Slot.__unstableName ); if ( ! listViewDisabled && !! listFills && listFills.length ) { - tabs.push( TAB_LIST_VIEW ); + tabs.push( + showIconLabels + ? { ...TAB_LIST_VIEW, icon: undefined } + : TAB_LIST_VIEW + ); } // Styles Tab: Add this tab if there are any fills for block supports @@ -64,7 +76,9 @@ export default function useInspectorControlsTabs( blockName ) { ]; if ( styleFills.length ) { - tabs.push( TAB_STYLES ); + tabs.push( + showIconLabels ? { ...TAB_STYLES, icon: undefined } : TAB_STYLES + ); } // Settings Tab: If there are any fills for the general InspectorControls @@ -75,7 +89,9 @@ export default function useInspectorControlsTabs( blockName ) { ]; if ( settingsFills.length ) { - tabs.push( TAB_SETTINGS ); + tabs.push( + showIconLabels ? { ...TAB_SETTINGS, icon: undefined } : TAB_SETTINGS + ); } const tabSettings = useSelect( ( select ) => { From d36ac987be1097e01426266f5d4a010f814d2861 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Tue, 10 Jan 2023 13:50:52 +1000 Subject: [PATCH 2/3] Revert "Explore text only mode for inspector tabs" This reverts commit 310f4d1633d59cbbbdb1589e8ae7aa0e1ed1abd9. --- packages/block-editor/package.json | 1 - .../use-inspector-controls-tabs.js | 22 +++---------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/packages/block-editor/package.json b/packages/block-editor/package.json index 4f28526e3386ed..7673886369ab9a 100644 --- a/packages/block-editor/package.json +++ b/packages/block-editor/package.json @@ -53,7 +53,6 @@ "@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", diff --git a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js index ae82d2edb60e49..fbe072fab11c58 100644 --- a/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +++ b/packages/block-editor/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js @@ -3,7 +3,6 @@ */ import { __experimentalUseSlotFills as useSlotFills } from '@wordpress/components'; import { useSelect } from '@wordpress/data'; -import { store as preferencesStore } from '@wordpress/preferences'; /** * Internal dependencies @@ -47,23 +46,12 @@ export default function useInspectorControlsTabs( blockName ) { typography: typographyGroup, } = InspectorControlsGroups; - const showIconLabels = useSelect( ( select ) => { - return select( preferencesStore ).get( - 'core/edit-post', - 'showIconLabels' - ); - } ); - // List View Tab: If there are any fills for the list group add that tab. const listViewDisabled = useIsListViewTabDisabled( blockName ); const listFills = useSlotFills( listGroup.Slot.__unstableName ); if ( ! listViewDisabled && !! listFills && listFills.length ) { - tabs.push( - showIconLabels - ? { ...TAB_LIST_VIEW, icon: undefined } - : TAB_LIST_VIEW - ); + tabs.push( TAB_LIST_VIEW ); } // Styles Tab: Add this tab if there are any fills for block supports @@ -76,9 +64,7 @@ export default function useInspectorControlsTabs( blockName ) { ]; if ( styleFills.length ) { - tabs.push( - showIconLabels ? { ...TAB_STYLES, icon: undefined } : TAB_STYLES - ); + tabs.push( TAB_STYLES ); } // Settings Tab: If there are any fills for the general InspectorControls @@ -89,9 +75,7 @@ export default function useInspectorControlsTabs( blockName ) { ]; if ( settingsFills.length ) { - tabs.push( - showIconLabels ? { ...TAB_SETTINGS, icon: undefined } : TAB_SETTINGS - ); + tabs.push( TAB_SETTINGS ); } const tabSettings = useSelect( ( select ) => { From 02bde2528cb549f9e76c8e4925f449dd74966646 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Tue, 10 Jan 2023 14:30:53 +1000 Subject: [PATCH 3/3] Use CSS approach to displaying the labels --- .../components/inspector-controls-tabs/style.scss | 15 +++++++++++++++ packages/block-editor/src/style.scss | 1 + 2 files changed, 16 insertions(+) create mode 100644 packages/block-editor/src/components/inspector-controls-tabs/style.scss diff --git a/packages/block-editor/src/components/inspector-controls-tabs/style.scss b/packages/block-editor/src/components/inspector-controls-tabs/style.scss new file mode 100644 index 00000000000000..f863f8f844d720 --- /dev/null +++ b/packages/block-editor/src/components/inspector-controls-tabs/style.scss @@ -0,0 +1,15 @@ +.show-icon-labels { + .block-editor-block-inspector__tabs .components-tab-panel__tabs { + .components-button.has-icon { + // Hide the button icons when labels are set to display... + svg { + display: none; + } + // ... and display labels. + // Uses ::before as ::after is already used for active tab styling. + &::before { + content: attr(aria-label); + } + } + } +} diff --git a/packages/block-editor/src/style.scss b/packages/block-editor/src/style.scss index 76da3c16325db9..951b9a8a40d3b1 100644 --- a/packages/block-editor/src/style.scss +++ b/packages/block-editor/src/style.scss @@ -31,6 +31,7 @@ @import "./components/height-control/style.scss"; @import "./components/image-size-control/style.scss"; @import "./components/inserter-list-item/style.scss"; +@import "./components/inspector-controls-tabs/style.scss"; @import "./components/inspector-popover-header/style.scss"; @import "./components/justify-content-control/style.scss"; @import "./components/link-control/style.scss";