Visually hide tabs when not selected, to keep state
This commit is contained in:
parent
1c40d2e892
commit
5727281493
|
@ -50,6 +50,10 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.woocommerce-product-editor-dev-tools-bar__tab-panel {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.woocommerce-product-editor-dev-tools-block-inspector {
|
.woocommerce-product-editor-dev-tools-block-inspector {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import { useEntityProp } from '@wordpress/core-data';
|
||||||
import { BlockInspector } from './block-inspector';
|
import { BlockInspector } from './block-inspector';
|
||||||
import { Help } from './help';
|
import { Help } from './help';
|
||||||
import { Product } from './product';
|
import { Product } from './product';
|
||||||
|
import { TabPanel } from './tab-panel';
|
||||||
import { useFocusedBlock } from './hooks/use-focused-block';
|
import { useFocusedBlock } from './hooks/use-focused-block';
|
||||||
|
|
||||||
function TabButton( {
|
function TabButton( {
|
||||||
|
@ -120,13 +121,15 @@ export function ProductEditorDevToolsBar( {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="woocommerce-product-editor-dev-tools-bar__panel">
|
<div className="woocommerce-product-editor-dev-tools-bar__panel">
|
||||||
{ selectedTab === 'inspector' && (
|
<TabPanel isSelected={ selectedTab === 'inspector' }>
|
||||||
<BlockInspector blockInfo={ blockInfo } />
|
<BlockInspector blockInfo={ blockInfo } />
|
||||||
) }
|
</TabPanel>
|
||||||
{ selectedTab === 'product' && (
|
<TabPanel isSelected={ selectedTab === 'product' }>
|
||||||
<Product evaluationContext={ evaluationContext } />
|
<Product evaluationContext={ evaluationContext } />
|
||||||
) }
|
</TabPanel>
|
||||||
{ selectedTab === 'help' && <Help /> }
|
<TabPanel isSelected={ selectedTab === 'help' }>
|
||||||
|
<Help />
|
||||||
|
</TabPanel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</WooFooterItem>
|
</WooFooterItem>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
export function TabPanel( {
|
||||||
|
isSelected,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
isSelected: boolean;
|
||||||
|
children: React.ReactNode;
|
||||||
|
} ) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="woocommerce-product-editor-dev-tools-bar__tab-panel"
|
||||||
|
style={ isSelected ? {} : { display: 'none' } }
|
||||||
|
>
|
||||||
|
{ children }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue