Skip to content

Commit 355c01a

Browse files
committed
chore: ability to run sandbox without autorun
1 parent 3a456ea commit 355c01a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/react/Sandbox/Provider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from '@codesandbox/sandpack-react'
99
import * as React from 'react'
1010
import { transform } from 'sucrase'
11+
import { RunButton } from './Run.js'
1112

1213
export function SandboxProvider(props: SandboxProvider.Props) {
1314
const {
@@ -75,6 +76,7 @@ export function SandboxProvider(props: SandboxProvider.Props) {
7576
showResetConsoleButton={true}
7677
showRestartButton={true}
7778
showSetupProgress={false}
79+
actionsChildren={<RunButton autoRun={autoRun ?? false} />}
7880
/>
7981
</SandpackProvider>
8082
)

src/react/Sandbox/Run.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RoundedButton, RunIcon, useSandpack } from '@codesandbox/sandpack-react
44
import * as React from 'react'
55
import { transform } from 'sucrase'
66

7-
export function RunButton(props: { autoRun: boolean }) {
7+
export function RunButton(props: RunButton.Props) {
88
const { autoRun } = props
99
const { sandpack } = useSandpack()
1010
const [hasRun, setHasRun] = React.useState(autoRun)
@@ -24,10 +24,14 @@ export function RunButton(props: { autoRun: boolean }) {
2424
if (hasRun && autoRun) return null
2525

2626
return (
27-
<div className="vocs:absolute vocs:top-2 vocs:right-2 vocs:flex vocs:gap-1">
28-
<RoundedButton onClick={transpileAndRun}>
29-
<RunIcon />
30-
</RoundedButton>
31-
</div>
27+
<RoundedButton onClick={transpileAndRun}>
28+
<RunIcon />
29+
</RoundedButton>
3230
)
3331
}
32+
33+
export declare namespace RunButton {
34+
type Props = {
35+
autoRun: boolean
36+
}
37+
}

0 commit comments

Comments
 (0)