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

Components: replace TabPanel with Tabs in the Style Book #57287

Merged
merged 3 commits into from
Jan 8, 2024
Merged
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
49 changes: 32 additions & 17 deletions packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import classnames from 'classnames';
*/
import {
Disabled,
TabPanel,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
Expand Down Expand Up @@ -48,6 +47,7 @@ const {
CompositeV2: Composite,
CompositeItemV2: CompositeItem,
useCompositeStoreV2: useCompositeStore,
Tabs,
} = unlock( componentsPrivateApis );

// The content area of the Style Book is rendered within an iframe so that global styles
Expand Down Expand Up @@ -253,22 +253,37 @@ function StyleBook( {
>
{ resizeObserver }
{ showTabs ? (
<TabPanel
className="edit-site-style-book__tab-panel"
tabs={ tabs }
>
{ ( tab ) => (
<StyleBookBody
category={ tab.name }
examples={ examples }
isSelected={ isSelected }
onSelect={ onSelect }
settings={ settings }
sizes={ sizes }
title={ tab.title }
/>
) }
</TabPanel>
<div className="edit-site-style-book__tabs">
<Tabs>
<Tabs.TabList>
{ tabs.map( ( tab ) => (
<Tabs.Tab
tabId={ tab.name }
key={ tab.name }
>
{ tab.title }
</Tabs.Tab>
) ) }
</Tabs.TabList>
{ tabs.map( ( tab ) => (
<Tabs.TabPanel
key={ tab.name }
tabId={ tab.name }
focusable={ false }
>
<StyleBookBody
category={ tab.name }
examples={ examples }
isSelected={ isSelected }
onSelect={ onSelect }
settings={ settings }
sizes={ sizes }
title={ tab.title }
/>
</Tabs.TabPanel>
) ) }
</Tabs>
</div>
) : (
<StyleBookBody
examples={ examples }
Expand Down
6 changes: 3 additions & 3 deletions packages/edit-site/src/components/style-book/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
}
}

.edit-site-style-book__tab-panel {
.components-tab-panel__tabs {
.edit-site-style-book__tabs {
[role="tablist"] {
background: $white;
color: $gray-900;
}

.components-tab-panel__tab-content {
[role="tabpanel"] {
bottom: 0;
left: 0;
overflow: auto;
Expand Down
Loading