forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenInCodeSandbox.js
More file actions
64 lines (57 loc) · 1.38 KB
/
OpenInCodeSandbox.js
File metadata and controls
64 lines (57 loc) · 1.38 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import JSXAddon from 'storybook-addon-jsx';
import { storiesOf, setAddon } from '@storybook/react';
import SandpackProvider from '../src/components/SandpackProvider/index.ts';
import OpenInCodeSandbox from '../src/components/OpenInCodeSandbox/index.ts';
setAddon(JSXAddon);
const stories = storiesOf('Export To CodeSandbox', module);
stories.addWithJSX('minimal', () => (
<SandpackProvider
entry="/index.js"
files={{
'/index.js': {
code: '',
},
}}
dependencies={{}}
>
<OpenInCodeSandbox />
</SandpackProvider>
));
stories.addWithJSX('with multiple files', () => (
<SandpackProvider
entry="/index.js"
files={{
'/index.js': {
code: `import Hello from './Hello.js';
document.body.innerHTML = JSON.stringify(Hello);
`,
},
'/Hello.js': {
code: `export default \`Hello from another file, here's an ID: $\{require('uuid')()}!\``,
},
}}
dependencies={{
uuid: 'latest',
}}
>
<OpenInCodeSandbox />
</SandpackProvider>
));
stories.addWithJSX('with render prop', () => (
<SandpackProvider
entry="/index.js"
files={{
'/index.js': {
code: '',
},
}}
dependencies={{}}
>
<OpenInCodeSandbox
render={() => {
return <button type="submit">CodeSandbox is awesome!</button>;
}}
/>
</SandpackProvider>
));