-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Media Inserter to Tabs Pattern (#60970)
Co-authored-by: jeryj <jeryj@git.wordpress.org> Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
- Loading branch information
1 parent
1f6fec6
commit c94f463
Showing
9 changed files
with
243 additions
and
369 deletions.
There are no files selected for viewing
This file contains 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
74 changes: 74 additions & 0 deletions
74
packages/block-editor/src/components/inserter/category-tabs/index.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { isRTL } from '@wordpress/i18n'; | ||
import { | ||
__experimentalHStack as HStack, | ||
FlexBlock, | ||
privateApis as componentsPrivateApis, | ||
} from '@wordpress/components'; | ||
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { unlock } from '../../../lock-unlock'; | ||
|
||
const { Tabs } = unlock( componentsPrivateApis ); | ||
|
||
function CategoryTabs( { | ||
categories, | ||
selectedCategory, | ||
onSelectCategory, | ||
children, | ||
} ) { | ||
return ( | ||
<Tabs | ||
className="block-editor-inserter__category-tabs" | ||
selectOnMove={ false } | ||
selectedTabId={ selectedCategory ? selectedCategory.name : null } | ||
orientation={ 'vertical' } | ||
onSelect={ ( categoryId ) => { | ||
// Pass the full category object | ||
onSelectCategory( | ||
categories.find( | ||
( category ) => category.name === categoryId | ||
) | ||
); | ||
} } | ||
> | ||
<Tabs.TabList className="block-editor-inserter__category-tablist"> | ||
{ categories.map( ( category ) => ( | ||
<Tabs.Tab | ||
key={ category.name } | ||
tabId={ category.name } | ||
className="block-editor-inserter__category-tab" | ||
aria-label={ category.label } | ||
aria-current={ | ||
category === selectedCategory ? 'true' : undefined | ||
} | ||
> | ||
<HStack> | ||
<FlexBlock>{ category.label }</FlexBlock> | ||
<Icon | ||
icon={ isRTL() ? chevronLeft : chevronRight } | ||
/> | ||
</HStack> | ||
</Tabs.Tab> | ||
) ) } | ||
</Tabs.TabList> | ||
{ categories.map( ( category ) => ( | ||
<Tabs.TabPanel | ||
key={ category.name } | ||
tabId={ category.name } | ||
focusable={ false } | ||
className="block-editor-inserter__category-panel" | ||
> | ||
{ children } | ||
</Tabs.TabPanel> | ||
) ) } | ||
</Tabs> | ||
); | ||
} | ||
|
||
export default CategoryTabs; |
2 changes: 1 addition & 1 deletion
2
packages/block-editor/src/components/inserter/media-tab/index.js
This file contains 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,3 +1,3 @@ | ||
export { default as MediaTab } from './media-tab'; | ||
export { MediaCategoryDialog } from './media-panel'; | ||
export { MediaCategoryPanel } from './media-panel'; | ||
export { useMediaCategories } from './hooks'; |
This file contains 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
This file contains 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.
c94f463
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.
Flaky tests detected in c94f463.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8817872710
📝 Reported issues:
/test/e2e/specs/site-editor/site-editor-url-navigation.spec.js