Skip to content

Commit f9e49af

Browse files
authored
feat: deprecated-codesandbox (ant-design#48081)
* feat: deprecated-codesandbox * feat: debug show csb
1 parent 5e65463 commit f9e49af

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

.dumi/theme/builtins/Previewer/CodePreviewer.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import CodeSandboxIcon from '../../common/CodeSandboxIcon';
1717
import EditButton from '../../common/EditButton';
1818
import ExternalLinkIcon from '../../common/ExternalLinkIcon';
1919
import RiddleIcon from '../../common/RiddleIcon';
20+
import DemoContext from '../../slots/DemoContext';
2021
import type { SiteContextProps } from '../../slots/SiteContext';
2122
import SiteContext from '../../slots/SiteContext';
2223
import { ping } from '../../utils';
@@ -107,6 +108,7 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
107108
clientOnly,
108109
pkgDependencyList,
109110
} = props;
111+
const { showDebug } = useContext(DemoContext);
110112

111113
const { pkg } = useSiteData();
112114
const location = useLocation();
@@ -469,26 +471,28 @@ createRoot(document.getElementById('container')).render(<Demo />);
469471
<CodePenIcon className="code-box-codepen" />
470472
</Tooltip>
471473
</form>
472-
<form
473-
className="code-box-code-action"
474-
action="https://codesandbox.io/api/v1/sandboxes/define"
475-
method="POST"
476-
target="_blank"
477-
ref={codeSandboxIconRef}
478-
onClick={() => {
479-
track({ type: 'codesandbox', demo: asset.id });
480-
codeSandboxIconRef.current?.submit();
481-
}}
482-
>
483-
<input
484-
type="hidden"
485-
name="parameters"
486-
value={compress(JSON.stringify(codesanboxPrefillConfig))}
487-
/>
488-
<Tooltip title={<FormattedMessage id="app.demo.codesandbox" />}>
489-
<CodeSandboxIcon className="code-box-codesandbox" />
490-
</Tooltip>
491-
</form>
474+
{showDebug && (
475+
<form
476+
className="code-box-code-action"
477+
action="https://codesandbox.io/api/v1/sandboxes/define"
478+
method="POST"
479+
target="_blank"
480+
ref={codeSandboxIconRef}
481+
onClick={() => {
482+
track({ type: 'codesandbox', demo: asset.id });
483+
codeSandboxIconRef.current?.submit();
484+
}}
485+
>
486+
<input
487+
type="hidden"
488+
name="parameters"
489+
value={compress(JSON.stringify(codesanboxPrefillConfig))}
490+
/>
491+
<Tooltip title={<FormattedMessage id="app.demo.codesandbox" />}>
492+
<CodeSandboxIcon className="code-box-codesandbox" />
493+
</Tooltip>
494+
</form>
495+
)}
492496
<Tooltip title={<FormattedMessage id="app.demo.separate" />}>
493497
<a
494498
className="code-box-code-action"

0 commit comments

Comments
 (0)