Fix size of CodeMirror to available viewport
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.app {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
height: 2.5lh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1em;
|
||||
flex-shrink: 0;
|
||||
background-color: #cde;
|
||||
}
|
||||
|
||||
.editor-component {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.editor-component .cm-editor {
|
||||
height: 100%;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { render } from 'solid-js/web';
|
||||
import App from './components/App';
|
||||
import './app.css';
|
||||
|
||||
const app = document.getElementById('app')!;
|
||||
|
||||
|
||||
@@ -6,13 +6,20 @@ function App() {
|
||||
const [currentFile, setCurrentFile] = createSignal<string | null>(null);
|
||||
|
||||
return (
|
||||
<div class="app">
|
||||
<div class="navbar">
|
||||
<Show when={currentFile() !== null}>
|
||||
<button onclick={() => setCurrentFile(null)}>Back</button>
|
||||
</Show>
|
||||
<div class="title">{currentFile() ?? 'Choose a file'}</div>
|
||||
</div>
|
||||
<Show
|
||||
when={currentFile()}
|
||||
fallback={<Chooser file={currentFile} setFile={setCurrentFile} />}
|
||||
>
|
||||
<button onclick={() => setCurrentFile(null)}>Back</button>
|
||||
<Editor file={currentFile()!} />
|
||||
</Show>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,16 +46,9 @@ function Editor(props: EditorProps) {
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>You are editing {props.file}.</p>
|
||||
<Show when={syncedDoc()}>
|
||||
<div
|
||||
ref={editorDiv}
|
||||
class="editor-component"
|
||||
style={{ border: '1px solid black' }}
|
||||
/>
|
||||
<div ref={editorDiv} class="editor-component" />
|
||||
</Show>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user