|
|
@ -2,7 +2,7 @@
|
|
|
|
import { getContext } from 'svelte';
|
|
|
|
import { getContext } from 'svelte';
|
|
|
|
import CodeMirror from '../CodeMirror.svelte';
|
|
|
|
import CodeMirror from '../CodeMirror.svelte';
|
|
|
|
|
|
|
|
|
|
|
|
const { selected, handle_change } = getContext('REPL');
|
|
|
|
const { selected, handle_change, navigate } = getContext('REPL');
|
|
|
|
|
|
|
|
|
|
|
|
export let error;
|
|
|
|
export let error;
|
|
|
|
export let errorLoc;
|
|
|
|
export let errorLoc;
|
|
|
@ -13,10 +13,49 @@
|
|
|
|
.editor-wrapper {
|
|
|
|
.editor-wrapper {
|
|
|
|
z-index: 5;
|
|
|
|
z-index: 5;
|
|
|
|
background: var(--back-light);
|
|
|
|
background: var(--back-light);
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.editor {
|
|
|
|
|
|
|
|
height: 0;
|
|
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.info p {
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
|
|
padding: 1.2rem 1.6rem 1.2rem 4.4rem;
|
|
|
|
|
|
|
|
font: 400 1.2rem/1.7 var(--font);
|
|
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
|
|
border-top: 1px solid white;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.info p::before {
|
|
|
|
|
|
|
|
content: '!';
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
left: 1.2rem;
|
|
|
|
|
|
|
|
top: 1.1rem;
|
|
|
|
|
|
|
|
width: 1rem;
|
|
|
|
|
|
|
|
height: 1rem;
|
|
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
line-height: 1;
|
|
|
|
|
|
|
|
padding: .4rem;
|
|
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
|
|
border: .2rem solid white;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.error {
|
|
|
|
|
|
|
|
background-color: #da106e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.warning {
|
|
|
|
|
|
|
|
background-color: #e47e0a;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (min-width: 600px) {
|
|
|
|
@media (min-width: 600px) {
|
|
|
|
.editor-wrapper {
|
|
|
|
.editor-wrapper.columns {
|
|
|
|
/* make it easier to interact with scrollbar */
|
|
|
|
/* make it easier to interact with scrollbar */
|
|
|
|
padding-right: 8px;
|
|
|
|
padding-right: 8px;
|
|
|
|
height: auto;
|
|
|
|
height: auto;
|
|
|
@ -26,14 +65,22 @@
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="editor-wrapper">
|
|
|
|
<div class="editor-wrapper">
|
|
|
|
{#if $selected}
|
|
|
|
<div class="editor">
|
|
|
|
<CodeMirror
|
|
|
|
{#if $selected}
|
|
|
|
mode="{$selected.type === 'js' ? 'javascript' : 'handlebars'}"
|
|
|
|
<CodeMirror
|
|
|
|
code={$selected.source}
|
|
|
|
mode="{$selected.type === 'js' ? 'javascript' : 'handlebars'}"
|
|
|
|
{error}
|
|
|
|
code={$selected.source}
|
|
|
|
{errorLoc}
|
|
|
|
{errorLoc}
|
|
|
|
{warningCount}
|
|
|
|
on:change={handle_change}
|
|
|
|
on:change={handle_change}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="info">
|
|
|
|
|
|
|
|
{#if error}
|
|
|
|
|
|
|
|
<p class="error" on:click="{() => navigate(error)}">{error.message}</p>
|
|
|
|
|
|
|
|
{:else if warningCount > 0}
|
|
|
|
|
|
|
|
<p class="warning">Compiled, but with {warningCount} {warningCount === 1 ? 'warning' : 'warnings'} — check the console for details</p>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|