File size: 878 Bytes
1e92f2d |
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 |
import { Button } from '@automattic/components';
import PropTypes from 'prop-types';
const DocsExampleToggle = ( { onClick, text } ) => <Button onClick={ onClick }>{ text }</Button>;
DocsExampleToggle.propTypes = {
onClick: PropTypes.func.isRequired,
text: PropTypes.string.isRequired,
};
const DocsExample = ( { children, toggleHandler, toggleText } ) => {
return (
<section className="docs-example">
<header className="docs-example__header">
{ toggleHandler && toggleText && (
<span className="docs-example__toggle">
<DocsExampleToggle onClick={ toggleHandler } text={ toggleText } />
</span>
) }
</header>
<div className="docs-example__main">{ children }</div>
</section>
);
};
DocsExample.propTypes = {
toggleHandler: PropTypes.func,
toggleText: PropTypes.string,
};
export { DocsExampleToggle };
export default DocsExample;
|