-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Implement Tabs in site-editor settings
#56959
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b1c0a29
take that, slot/fill!
chad1008 7b21c85
panel margin style fix
chad1008 e3bee18
style updates
chad1008 7b04524
e2e test updates
chad1008 dd7fd69
ensure canvas is in edit mode
chad1008 225aba3
fix tabpanel ids
chad1008 21587d5
update new playwright tests
chad1008 883f800
disable `selectOnMove`
chad1008 b5cd94e
address tab flow race condition
chad1008 65a8221
implement feedback
chad1008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 25 additions & 63 deletions
88
packages/edit-site/src/components/sidebar-edit-mode/settings-header/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,82 +1,44 @@ | ||
| /** | ||
| * External dependencies | ||
| */ | ||
| import classnames from 'classnames'; | ||
|
|
||
| /** | ||
| * WordPress dependencies | ||
| */ | ||
| import { Button } from '@wordpress/components'; | ||
| import { __, sprintf } from '@wordpress/i18n'; | ||
| import { useSelect, useDispatch } from '@wordpress/data'; | ||
| import { store as interfaceStore } from '@wordpress/interface'; | ||
| import { privateApis as componentsPrivateApis } from '@wordpress/components'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { useSelect } from '@wordpress/data'; | ||
| import { store as editorStore } from '@wordpress/editor'; | ||
| import { forwardRef } from '@wordpress/element'; | ||
|
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { STORE_NAME } from '../../../store/constants'; | ||
| import { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from '../constants'; | ||
| import { unlock } from '../../../lock-unlock'; | ||
|
|
||
| const SettingsHeader = ( { sidebarName } ) => { | ||
| const { Tabs } = unlock( componentsPrivateApis ); | ||
|
|
||
| const SettingsHeader = ( _, ref ) => { | ||
| const postTypeLabel = useSelect( | ||
| ( select ) => select( editorStore ).getPostTypeLabel(), | ||
| [] | ||
| ); | ||
|
|
||
| const { enableComplementaryArea } = useDispatch( interfaceStore ); | ||
| const openTemplateSettings = () => | ||
| enableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE ); | ||
| const openBlockSettings = () => | ||
| enableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK ); | ||
|
|
||
| const documentAriaLabel = | ||
| sidebarName === SIDEBAR_TEMPLATE | ||
| ? // translators: ARIA label for the Template sidebar tab, selected. | ||
| sprintf( __( '%s (selected)' ), postTypeLabel ) | ||
| : postTypeLabel; | ||
|
|
||
| /* Use a list so screen readers will announce how many tabs there are. */ | ||
| return ( | ||
| <ul> | ||
| <li> | ||
| <Button | ||
| onClick={ openTemplateSettings } | ||
| className={ classnames( | ||
| 'edit-site-sidebar-edit-mode__panel-tab', | ||
| { | ||
| 'is-active': sidebarName === SIDEBAR_TEMPLATE, | ||
| } | ||
| ) } | ||
| aria-label={ documentAriaLabel } | ||
| data-label={ postTypeLabel } | ||
| > | ||
| { postTypeLabel } | ||
| </Button> | ||
| </li> | ||
| <li> | ||
| <Button | ||
| onClick={ openBlockSettings } | ||
| className={ classnames( | ||
| 'edit-site-sidebar-edit-mode__panel-tab', | ||
| { | ||
| 'is-active': sidebarName === SIDEBAR_BLOCK, | ||
| } | ||
| ) } | ||
| aria-label={ | ||
| sidebarName === SIDEBAR_BLOCK | ||
| ? // translators: ARIA label for the Block Settings Sidebar tab, selected. | ||
| __( 'Block (selected)' ) | ||
| : // translators: ARIA label for the Block Settings Sidebar tab, not selected. | ||
| __( 'Block' ) | ||
| } | ||
| data-label={ __( 'Block' ) } | ||
| > | ||
| { __( 'Block' ) } | ||
| </Button> | ||
| </li> | ||
| </ul> | ||
| <Tabs.TabList ref={ ref }> | ||
| <Tabs.Tab | ||
| tabId={ SIDEBAR_TEMPLATE } | ||
| // Used for focus management in the SettingsSidebar component. | ||
| data-tab-id={ SIDEBAR_TEMPLATE } | ||
| > | ||
| { postTypeLabel } | ||
| </Tabs.Tab> | ||
| <Tabs.Tab | ||
| tabId={ SIDEBAR_BLOCK } | ||
| // Used for focus management in the SettingsSidebar component. | ||
| data-tab-id={ SIDEBAR_BLOCK } | ||
| > | ||
| { __( 'Block' ) } | ||
| </Tabs.Tab> | ||
| </Tabs.TabList> | ||
| ); | ||
| }; | ||
|
|
||
| export default SettingsHeader; | ||
| export default forwardRef( SettingsHeader ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.