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

[WIP] List View: Initial attempt at resizable list view sidebar #53452

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __experimentalListView as ListView } from '@wordpress/block-editor';
import { Button, TabPanel } from '@wordpress/components';
import { Button, TabPanel, ResizableBox } from '@wordpress/components';
import {
useFocusOnMount,
useFocusReturn,
Expand Down Expand Up @@ -119,46 +119,59 @@ export default function ListViewSidebar() {
}

return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
className="edit-post-editor__document-overview-panel"
onKeyDown={ closeOnEscape }
ref={ sidebarRef }
<ResizableBox
className="edit-post-editor__document-overview-panel__resizable-box"
enable={ {
top: false,
right: true, // TODO: update with an isRTL check.
bottom: false,
left: false, // TODO: update with a ! isRTL check.
} }
minWidth={ 350 }
maxWidth={ 700 }
showHandle={ true }
>
<Button
className="edit-post-editor__document-overview-panel__close-button"
ref={ headerFocusReturnRef }
icon={ closeSmall }
label={ __( 'Close' ) }
onClick={ () => setIsListViewOpened( false ) }
/>
<TabPanel
className="edit-post-editor__document-overview-panel__tab-panel"
ref={ tabPanelRef }
onSelect={ ( tabName ) => setTab( tabName ) }
selectOnMove={ false }
tabs={ [
{
name: 'list-view',
title: _x( 'List View', 'Post overview' ),
className: 'edit-post-sidebar__panel-tab',
},
{
name: 'outline',
title: _x( 'Outline', 'Post overview' ),
className: 'edit-post-sidebar__panel-tab',
},
] }
{ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions */ }
<div
className="edit-post-editor__document-overview-panel"
onKeyDown={ closeOnEscape }
ref={ sidebarRef }
>
{ ( currentTab ) => (
<div
className="edit-post-editor__list-view-container"
ref={ listViewContainerRef }
>
{ renderTabContent( currentTab.name ) }
</div>
) }
</TabPanel>
</div>
<Button
className="edit-post-editor__document-overview-panel__close-button"
ref={ headerFocusReturnRef }
icon={ closeSmall }
label={ __( 'Close' ) }
onClick={ () => setIsListViewOpened( false ) }
/>
<TabPanel
className="edit-post-editor__document-overview-panel__tab-panel"
ref={ tabPanelRef }
onSelect={ ( tabName ) => setTab( tabName ) }
selectOnMove={ false }
tabs={ [
{
name: 'list-view',
title: _x( 'List View', 'Post overview' ),
className: 'edit-post-sidebar__panel-tab',
},
{
name: 'outline',
title: _x( 'Outline', 'Post overview' ),
className: 'edit-post-sidebar__panel-tab',
},
] }
>
{ ( currentTab ) => (
<div
className="edit-post-editor__list-view-container"
ref={ listViewContainerRef }
>
{ renderTabContent( currentTab.name ) }
</div>
) }
</TabPanel>
</div>
</ResizableBox>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
flex-direction: column;
}

.edit-post-editor__document-overview-panel {
.edit-post-editor__document-overview-panel__resizable-box {
@include break-medium() {
// Same width as the Inserter.
// @see packages/block-editor/src/components/inserter/style.scss
width: 350px;
}
}

.edit-post-editor__document-overview-panel {

.edit-post-editor__document-overview-panel__close-button {
position: absolute;
Expand Down