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

Add header title to list view sidebar #61553

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 0 additions & 2 deletions packages/block-editor/src/components/inserter/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function InserterLibrary(
__experimentalOnPatternCategorySelection,
onSelect = noop,
shouldFocusBlock = false,
onClose,
},
ref
) {
Expand Down Expand Up @@ -59,7 +58,6 @@ function InserterLibrary(
__experimentalInitialCategory={ __experimentalInitialCategory }
shouldFocusBlock={ shouldFocusBlock }
ref={ ref }
onClose={ onClose }
/>
);
}
Expand Down
2 changes: 0 additions & 2 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function InserterMenu(
__experimentalFilterValue = '',
shouldFocusBlock = true,
__experimentalOnPatternCategorySelection = NOOP,
onClose,
__experimentalInitialTab,
__experimentalInitialCategory,
},
Expand Down Expand Up @@ -302,7 +301,6 @@ function InserterMenu(
<InserterTabs
ref={ tabsRef }
onSelect={ handleSetSelectedTab }
onClose={ onClose }
selectedTab={ selectedTab }
>
{ inserterSearch }
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ $block-inserter-tabs-height: 44px;

.block-editor-inserter__tablist {
width: 100%;
background-color: $gray-100;
border-bottom: $border-width solid $gray-300;

button[role="tab"] {
flex-grow: 1;
Expand Down
40 changes: 13 additions & 27 deletions packages/block-editor/src/components/inserter/tabs.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/**
* WordPress dependencies
*/
import {
Button,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { privateApis as componentsPrivateApis } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { forwardRef } from '@wordpress/element';
import { closeSmall } from '@wordpress/icons';

/**
* Internal dependencies
Expand All @@ -33,33 +29,23 @@ const mediaTab = {
title: __( 'Media' ),
};

function InserterTabs( { onSelect, children, onClose, selectedTab }, ref ) {
function InserterTabs( { onSelect, children, selectedTab }, ref ) {
const tabs = [ blocksTab, patternsTab, mediaTab ];

return (
<div className="block-editor-inserter__tabs" ref={ ref }>
<Tabs onSelect={ onSelect } selectedTabId={ selectedTab }>
<div className="block-editor-inserter-sidebar__header">
<Button
className="block-editor-inserter-sidebar__close-button"
icon={ closeSmall }
label={ __( 'Close block inserter' ) }
onClick={ () => onClose() }
size="small"
/>

<Tabs.TabList className="block-editor-inserter__tablist">
{ tabs.map( ( tab ) => (
<Tabs.Tab
key={ tab.name }
tabId={ tab.name }
className="block-editor-inserter__tab"
>
{ tab.title }
</Tabs.Tab>
) ) }
</Tabs.TabList>
</div>
<Tabs.TabList className="block-editor-inserter__tablist">
{ tabs.map( ( tab ) => (
<Tabs.Tab
key={ tab.name }
tabId={ tab.name }
className="block-editor-inserter__tab"
>
{ tab.title }
</Tabs.Tab>
) ) }
</Tabs.TabList>
{ tabs.map( ( tab ) => (
<Tabs.TabPanel
key={ tab.name }
Expand Down
17 changes: 15 additions & 2 deletions packages/editor/src/components/inserter-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { useViewportMatch } from '@wordpress/compose';
import { useCallback, useRef } from '@wordpress/element';
import { store as preferencesStore } from '@wordpress/preferences';
import { ESCAPE } from '@wordpress/keycodes';

import { __ } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
import { Button } from '@wordpress/components';
/**
* Internal dependencies
*/
Expand Down Expand Up @@ -73,6 +75,18 @@ export default function InserterSidebar( {
return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div onKeyDown={ closeOnEscape } className="editor-inserter-sidebar">
<div className="block-editor-inserter-sidebar__header">
<span className="block-editor-inserter-sidebar__header-title">
{ __( 'Insert' ) }
</span>
<Button
className="block-editor-inserter-sidebar__close-button"
icon={ closeSmall }
label={ __( 'Close block inserter' ) }
onClick={ () => setIsInserterOpened( false ) }
size="small"
/>
</div>
<div className="editor-inserter-sidebar__content">
<Library
showMostUsedBlocks={ showMostUsedBlocks }
Expand All @@ -91,7 +105,6 @@ export default function InserterSidebar( {
isRightSidebarOpen ? closeGeneralSidebar : undefined
}
ref={ libraryRef }
onClose={ closeInserterSidebar }
/>
</div>
</div>
Expand Down
23 changes: 17 additions & 6 deletions packages/editor/src/components/inserter-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@
}

.block-editor-inserter-sidebar__header {
border-bottom: $border-width solid $gray-300;
padding-right: $grid-unit-10;
display: flex;
justify-content: space-between;
padding: $grid-unit-05 $grid-unit-05 0 $grid-unit-20;
background-color: $gray-100;
}

.block-editor-inserter-sidebar__close-button {
order: 1;
align-self: center;
}
.block-editor-inserter-sidebar__header-title {
font-size: 12px;
font-weight: 500;
color: #6b6b6b;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@richtabor @SaxonF Had to change this from $gray-600 to meet AA contrast requirement of 4.5:1. Feel free to take this over and apply the background and text color styles you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jameskoster - I meant to ping you on this about the colors. I quite like your design, and we only need to tweak the colors to meet AA contrast requirements.

Copy link
Contributor

Choose a reason for hiding this comment

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

A white background would make $gray-700 adequate, this might be a better approach?

text-transform: uppercase;
position: relative;
top: $grid-unit-10;
}

.block-editor-inserter-sidebar__close-button {
background: transparent;
color: #6b6b6b;
position: relative;
z-index: 2; // allow the close button focus ring to be visible
}

.editor-inserter-sidebar__content {
Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/list-view-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,18 @@ export default function ListViewSidebar() {
defaultTabId="list-view"
>
<div className="editor-list-view-sidebar__header">
<span className="editor-list-view-sidebar__header-title">
{ __( 'Document Overview' ) }
</span>
<Button
className="editor-list-view-sidebar__close-button"
icon={ closeSmall }
label={ __( 'Close' ) }
onClick={ closeListView }
size="small"
/>
</div>
<div className="editor-list-view-sidebar__tabs">
<Tabs.TabList
className="editor-list-view-sidebar__tabs-tablist"
ref={ tabsRef }
Expand Down
28 changes: 23 additions & 5 deletions packages/editor/src/components/list-view-sidebar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,31 @@
}
.editor-list-view-sidebar__header {
display: flex;
border-bottom: $border-width solid $gray-300;
justify-content: space-between;
padding: $grid-unit-05 $grid-unit-05 0 $grid-unit-20;
background-color: $gray-100;
}

.editor-list-view-sidebar__header-title {
font-size: 12px;
font-weight: 500;
color: #6b6b6b;
text-transform: uppercase;
position: relative;
top: $grid-unit-10;
}

.editor-list-view-sidebar__close-button {
background: $white;
order: 1;
align-self: center;
margin-right: $grid-unit-15;
background: transparent;
color: #6b6b6b;
position: relative;
z-index: 2; // allow the close button focus ring to be visible
}

.editor-list-view-sidebar__tabs {
display: flex;
background-color: $gray-100;
border-bottom: $border-width solid $gray-300;
}
}

Expand Down
Loading