diff --git a/src/App.css b/src/App.css index 74b5e05..e69de29 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.tsx b/src/App.tsx index bd3305c..93ed878 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,45 +1,26 @@ -import React from "react"; -import Highlight, { defaultProps } from "prism-react-renderer"; +import React, { useState, useLayoutEffect } from "react"; -import { sourceMapping } from "./logic/sourceMapping"; +import { SourceViewer } from "./components/SourceViewer"; +import { CompletionViewer } from "./components/CompletionViewer"; +import { completionMapping } from "./logic/completionMapping"; +import { runEngine } from "./logic/runEngine"; import "./tailwind.output.css"; - import "./App.css"; -const exampleCode = `var test = \`asd +const sampleInputCode = `var test = \`asd World!\`; abc()`; function App() { + const [inputCode, setInputCode] = useState(sampleInputCode); + + useLayoutEffect(() => { + runEngine(inputCode); + }, [inputCode]); + return (
- - {({ className, style, tokens, getLineProps, getTokenProps }) => ( - sourceMapping.reset(), - ( -
-              {tokens.map((line, i) => (
-                
- {line.map(function (token, key) { - const refFn = sourceMapping.registerToken(token); - return ( - - ); - })} - {(sourceMapping.registerLineEnd(), null)} -
- ))} -
- ) - )} -
+
); } diff --git a/src/components/CompletionViewer/CompletionViewer.css b/src/components/CompletionViewer/CompletionViewer.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/CompletionViewer/CompletionViewer.tsx b/src/components/CompletionViewer/CompletionViewer.tsx new file mode 100644 index 0000000..0fb67d7 --- /dev/null +++ b/src/components/CompletionViewer/CompletionViewer.tsx @@ -0,0 +1 @@ +export function CompletionViewer() {} diff --git a/src/components/CompletionViewer/index.ts b/src/components/CompletionViewer/index.ts new file mode 100644 index 0000000..106853f --- /dev/null +++ b/src/components/CompletionViewer/index.ts @@ -0,0 +1,3 @@ +import { CompletionViewer } from "./CompletionViewer"; + +export { CompletionViewer }; diff --git a/src/components/SourceViewer/SourceViewer.css b/src/components/SourceViewer/SourceViewer.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/SourceViewer/SourceViewer.tsx b/src/components/SourceViewer/SourceViewer.tsx new file mode 100644 index 0000000..ff0d9d0 --- /dev/null +++ b/src/components/SourceViewer/SourceViewer.tsx @@ -0,0 +1,38 @@ +import React from "react"; +import Highlight, { defaultProps } from "prism-react-renderer"; + +import { sourceMapping } from "../../logic/sourceMapping"; + +import "./SourceViewer.css"; + +interface ISourceViewerProps { + code: string; + onChangeCode(newCode: string): void; +} + +export function SourceViewer(props: ISourceViewerProps) { + const { code } = props; + return ( + + {({ className, style, tokens, getLineProps, getTokenProps }) => ( + // eslint-disable-next-line no-sequences + sourceMapping.reset(), + ( +
+            {tokens.map((line, i) => (
+              
+ {line.map(function (token, key) { + const refFn = sourceMapping.registerToken(token); + return ( + + ); + })} + {(sourceMapping.registerLineEnd(), null)} +
+ ))} +
+ ) + )} +
+ ); +} diff --git a/src/components/SourceViewer/index.ts b/src/components/SourceViewer/index.ts new file mode 100644 index 0000000..b06bfcd --- /dev/null +++ b/src/components/SourceViewer/index.ts @@ -0,0 +1,3 @@ +import { SourceViewer } from "./SourceViewer"; + +export { SourceViewer };