import React, { useState } from 'react' import CodeBlock from '@theme/CodeBlock' export default function CustomCodeBlock({ header, code, highlight, js, jsHighlight, response, language, }) { const [showResponse, toggleResponse] = useState(false) let wrapperClass = '' if (header) wrapperClass += ' code-with-header' if (response) wrapperClass += ' code-with-response' return ( <>
{header &&
{header}
} <> {code && ( {code} )} {js && {js}}
{response && ( <>
toggleResponse(!showResponse)} > {showResponse ? 'Hide' : 'Show'} Response {showResponse && {response}}
)} ) } const styles = { responseShown: { textAlign: 'right', display: 'block', borderRadius: '0', color: 'var(--custom-primary)', borderTop: '1px solid #444', }, responseHidden: { textAlign: 'right', display: 'block', borderBottom: 'none', borderRadius: '0 0 4px 4px', borderTop: '1px solid #444', color: '#ccc', }, }