-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Inserter: Add close button #61421
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
Inserter: Add close button #61421
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { privateApis as componentsPrivateApis } from '@wordpress/components'; | ||
| import { | ||
| Button, | ||
| privateApis as componentsPrivateApis, | ||
| } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { forwardRef } from '@wordpress/element'; | ||
| import { closeSmall } from '@wordpress/icons'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
|
|
@@ -29,23 +33,33 @@ const mediaTab = { | |
| title: __( 'Media' ), | ||
| }; | ||
|
|
||
| function InserterTabs( { onSelect, children }, ref ) { | ||
| function InserterTabs( { onSelect, children, onClose }, ref ) { | ||
| const tabs = [ blocksTab, patternsTab, mediaTab ]; | ||
|
|
||
| return ( | ||
| <div className="block-editor-inserter__tabs" ref={ ref }> | ||
| <Tabs onSelect={ onSelect }> | ||
| <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 className="block-editor-inserter-sidebar__header"> | ||
| <Button | ||
| className="block-editor-inserter-sidebar__close-button" | ||
| icon={ closeSmall } | ||
| label={ __( 'Close block inserter' ) } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the label always be
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to update it, in a different PR :) |
||
| 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.map( ( tab ) => ( | ||
| <Tabs.TabPanel | ||
| key={ tab.name } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not great to pass the props here, but I can't find a way to access this state without passing it down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will get undone when we refactor the List View and Inserter to share the same sidebar, so I think it's OK.