mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
652 B
652 B
import React from 'react';
import { AddonPanel, Button } from '@storybook/components';
import { useGlobals } from '@storybook/manager-api';
export const Panel = () => {
const [globals, updateGlobals] = useGlobals();
const isActive = globals['my-param-key'] || false; // 👈 Sets visibility based on the global value.
return (
<AddonPanel key="custom-panel" active={isActive}>
<Button onClick={() => updateGlobals({ ['my-param-key']: !isActive })}>
{isActive ? 'Hide the addon panel' : 'Show the panel'}
</Button>
</AddonPanel>
);
};