Skip to content

Commit 5f025df

Browse files
committed
feat(repl): Add font size adjustment to editor
1 parent 4ab74c4 commit 5f025df

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

packages/repl/src/lib/Editor/Editor.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<!-- svelte-ignore a11y_no_static_element_interactions -->
5656
<div
5757
class="container"
58+
style="--editor-font-size: {workspace.fontSize}px"
5859
bind:this={container}
5960
onpointerdown={() => {
6061
workspace.enable_tab_indent();
@@ -121,4 +122,8 @@
121122
.fake-content {
122123
padding: 0 1rem;
123124
}
125+
126+
.container :global(.cm-editor .cm-scroller) {
127+
font-size: var(--editor-font-size, var(--sk-font-size-mono));
128+
}
124129
</style>

packages/repl/src/lib/Input/ComponentSelector.svelte

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,17 @@
186186
/>
187187
</label>
188188

189+
<label class="option">
190+
<span>Font Size</span>
191+
<input
192+
type="number"
193+
min="10"
194+
max="128"
195+
value={workspace.fontSize}
196+
onchange={(ev) => (workspace.fontSize = ev.currentTarget.valueAsNumber)}
197+
/>
198+
</label>
199+
189200
{#if download}
190201
<button onclick={download}>Download app</button>
191202
{/if}

packages/repl/src/lib/Workspace.svelte.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export class Workspace {
117117
#files = $state.raw<Item[]>([]);
118118
#current = $state.raw() as File;
119119
#vim = $state(false);
120+
#fontSize = $state(14);
120121
#aliases = $state.raw(undefined) as undefined | Record<string, string>;
121122
#tailwind = $state(false);
122123

@@ -292,6 +293,7 @@ export class Workspace {
292293
untrack(() => {
293294
view.setState(this.#get_state(untrack(() => this.#current)));
294295
this.vim = localStorage.getItem('vim') === 'true';
296+
this.fontSize = Number(localStorage.getItem('fontSize')) || 14;
295297
});
296298
}
297299

@@ -552,6 +554,15 @@ export class Workspace {
552554
}
553555
}
554556

557+
get fontSize() {
558+
return this.#fontSize;
559+
}
560+
561+
set fontSize(value: number) {
562+
this.#fontSize = value;
563+
localStorage.setItem('fontSize', value.toString());
564+
}
565+
555566
#create_directories(item: Item) {
556567
// create intermediate directories as necessary
557568
const parts = item.name.split('/');

0 commit comments

Comments
 (0)