Fix content of Panel rendered wrong at Docs-page (#7327)

Fix content of Panel rendered wrong at Docs-page
This commit is contained in:
Michael Shilman 2019-07-14 06:58:28 +08:00 committed by GitHub
commit 48e5505723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 33 deletions

View File

@ -44,39 +44,41 @@ SafeTab.defaultProps = {
children: null,
};
const AddonPanel = React.memo(({ panels, actions, selectedPanel, panelPosition }) => (
<Tabs
absolute
selected={selectedPanel}
actions={actions}
flex
tools={
<Fragment>
<DesktopOnlyIconButton
key="position"
onClick={actions.togglePosition}
title="Change orientation"
>
<Icons icon={panelPosition === 'bottom' ? 'bottombar' : 'sidebaralt'} />
</DesktopOnlyIconButton>
<DesktopOnlyIconButton
key="visibility"
onClick={actions.toggleVisibility}
title="Hide addons"
>
<Icons icon="close" />
</DesktopOnlyIconButton>
</Fragment>
}
id="storybook-panel-root"
>
{Object.entries(panels).map(([k, v]) => (
<SafeTab key={k} id={k} title={v.title}>
{v.render}
</SafeTab>
))}
</Tabs>
));
const AddonPanel = React.memo(
({ panels, actions, selectedPanel, panelPosition, absolute = true }) => (
<Tabs
absolute={absolute}
selected={selectedPanel}
actions={actions}
flex
tools={
<Fragment>
<DesktopOnlyIconButton
key="position"
onClick={actions.togglePosition}
title="Change orientation"
>
<Icons icon={panelPosition === 'bottom' ? 'bottombar' : 'sidebaralt'} />
</DesktopOnlyIconButton>
<DesktopOnlyIconButton
key="visibility"
onClick={actions.toggleVisibility}
title="Hide addons"
>
<Icons icon="close" />
</DesktopOnlyIconButton>
</Fragment>
}
id="storybook-panel-root"
>
{Object.entries(panels).map(([k, v]) => (
<SafeTab key={k} id={k} title={v.title}>
{v.render}
</SafeTab>
))}
</Tabs>
)
);
AddonPanel.displayName = 'AddonPanel';
AddonPanel.propTypes = {
selectedPanel: PropTypes.string,
@ -86,10 +88,12 @@ AddonPanel.propTypes = {
}).isRequired,
panels: PropTypes.shape({}).isRequired,
panelPosition: PropTypes.oneOf(['bottom', 'right']),
absolute: PropTypes.bool,
};
AddonPanel.defaultProps = {
selectedPanel: null,
panelPosition: 'right',
absolute: true,
};
export default AddonPanel;

View File

@ -37,6 +37,7 @@ storiesOf('UI|Panel', module)
})
.add('default', () => (
<Panel
absolute={false}
panels={panels}
actions={{ onSelect, toggleVisibility, togglePosition }}
selectedPanel="test2"