-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathindex.js
More file actions
62 lines (57 loc) · 1.58 KB
/
index.js
File metadata and controls
62 lines (57 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* WordPress dependencies
*/
import { TabPanel } from '@wordpress/components';
/**
* Internal dependencies
*/
import { TAB_SETTINGS, TAB_STYLES, TAB_LIST_VIEW } from './utils';
import SettingsTab from './settings-tab';
import StylesTab from './styles-tab';
import InspectorControls from '../inspector-controls';
import useIsListViewTabDisabled from './use-is-list-view-tab-disabled';
export default function InspectorControlsTabs( {
blockName,
clientId,
hasBlockStyles,
tabs,
} ) {
// The tabs panel will mount before fills are rendered to the list view
// slot. This means the list view tab isn't initially included in the
// available tabs so the panel defaults selection to the styles tab
// which at the time is the first tab. This check allows blocks known to
// include the list view tab to set it as the tab selected by default.
const initialTabName = ! useIsListViewTabDisabled( blockName )
? TAB_LIST_VIEW.name
: undefined;
return (
<TabPanel
className="block-editor-block-inspector__tabs"
tabs={ tabs }
initialTabName={ initialTabName }
key={ clientId }
>
{ ( tab ) => {
if ( tab.name === TAB_SETTINGS.name ) {
return (
<SettingsTab showAdvancedControls={ !! blockName } />
);
}
if ( tab.name === TAB_STYLES.name ) {
return (
<StylesTab
blockName={ blockName }
clientId={ clientId }
hasBlockStyles={ hasBlockStyles }
/>
);
}
if ( tab.name === TAB_LIST_VIEW.name ) {
return (
<InspectorControls.Slot __experimentalGroup="list" />
);
}
} }
</TabPanel>
);
}