MCPcopy Create free account
hub / github.com/adobe/react-spectrum / createStackBlitz

Function createStackBlitz

packages/dev/s2-docs/src/StackBlitz.tsx:3–45  ·  view source on GitHub ↗
(
  files: DownloadFiles['files'],
  deps: DownloadFiles['deps'],
  type: 'vanilla' | 'tailwind' | 's2' = 'vanilla',
  entry: string = 'Example'
)

Source from the content-addressed store, hash-verified

1import type {DownloadFiles} from './CodeBlock';
2
3export function createStackBlitz(
4 files: DownloadFiles['files'],
5 deps: DownloadFiles['deps'],
6 type: 'vanilla' | 'tailwind' | 's2' = 'vanilla',
7 entry: string = 'Example'
8) {
9 let form = document.createElement('form');
10 form.hidden = true;
11 form.method = 'POST';
12 form.action = 'https://stackblitz.com/run?file=src/Example.tsx';
13 form.target = '_blank';
14
15 let input = document.createElement('input');
16 input.type = 'hidden';
17 input.name = 'project[template]';
18 input.value = 'node';
19 form.appendChild(input);
20
21 input = document.createElement('input');
22 input.type = 'hidden';
23 input.name = 'project[title]';
24 input.value = 'Project';
25 form.appendChild(input);
26
27 input = document.createElement('input');
28 input.type = 'hidden';
29 input.name = 'project[description]';
30 input.value = 'description';
31 form.appendChild(input);
32
33 let generatedFiles = getFiles(files, deps, type, entry);
34 for (let name in generatedFiles) {
35 input = document.createElement('input');
36 input.type = 'hidden';
37 input.name = `project[files][${name}]`;
38 input.value = generatedFiles[name];
39 form.appendChild(input);
40 }
41
42 document.body.appendChild(form);
43 form.submit();
44 form.remove();
45}
46
47function getFiles(
48 files: DownloadFiles['files'],

Callers 1

CodePlatterFunction · 0.90

Calls 4

createElementMethod · 0.80
appendChildMethod · 0.80
getFilesFunction · 0.70
removeMethod · 0.65

Tested by

no test coverage detected