forked from solidjs/solid-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReplTab.tsx
41 lines (40 loc) · 1.06 KB
/
ReplTab.tsx
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
import { Component, createSignal, ErrorBoundary } from 'solid-js';
import { Tab } from 'solid-repl';
import Repl from 'solid-repl/lib/repl';
import { compiler, formatter } from './setupRepl';
import { useAppContext } from '../AppContext';
let count = 0;
const OldRepl: Component<{ tabs: Tab[] }> = (props) => {
count++;
const context = useAppContext();
const initialTabs = props.tabs || [
{
name: 'main.jsx',
source: '',
},
];
const [tabs, setTabs] = createSignal(initialTabs);
const [current, setCurrent] = createSignal(initialTabs[0].name, {
equals: false,
});
return (
<ErrorBoundary
fallback={
<>Repl failed to load. You may be using a browser that doesn't support Web Workers.</>
}
>
<Repl
id={`repl-${count}`}
compiler={compiler}
formatter={formatter}
isHorizontal={true}
dark={context.isDark}
tabs={tabs()}
setTabs={setTabs}
current={current()}
setCurrent={setCurrent}
/>
</ErrorBoundary>
);
};
export default OldRepl;