Skip to content

Commit

Permalink
Add bindings panel to inspector controls with tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed May 9, 2024
1 parent 74a900c commit c5dd1b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function InspectorControlsTabs( {
clientId,
hasBlockStyles,
tabs,
block,
} ) {
// 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
Expand Down Expand Up @@ -52,7 +53,10 @@ export default function InspectorControlsTabs( {
) ) }
</Tabs.TabList>
<Tabs.TabPanel tabId={ TAB_SETTINGS.name } focusable={ false }>
<SettingsTab showAdvancedControls={ !! blockName } />
<SettingsTab
showAdvancedControls={ !! blockName }
block={ block }
/>
</Tabs.TabPanel>
<Tabs.TabPanel tabId={ TAB_STYLES.name } focusable={ false }>
<StylesTab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,26 @@ import AdvancedControls from './advanced-controls-panel';
import PositionControls from './position-controls-panel';
import { default as InspectorControls } from '../inspector-controls';
import SettingsTabHint from './settings-tab-hint';
import { BindingsPanel } from '../inspector-controls/bindings-panel';

const SettingsTab = ( { showAdvancedControls = false } ) => (
<>
<InspectorControls.Slot />
<PositionControls />
{ showAdvancedControls && (
<div>
<AdvancedControls />
</div>
) }
<SettingsTabHint />
</>
);
function SettingsTab( { showAdvancedControls = false, block } ) {
const hasBindings = block?.attributes?.metadata?.bindings
? Object.keys( block.attributes.metadata.bindings ).length > 0
: false;

return (
<>
{ hasBindings && <BindingsPanel block={ block } /> }
<InspectorControls.Slot />
<PositionControls />
{ showAdvancedControls && (
<div>
<AdvancedControls />
</div>
) }
<SettingsTabHint />
</>
);
}

export default SettingsTab;

0 comments on commit c5dd1b7

Please sign in to comment.