Skip to content

Commit 2a1034e

Browse files
committed
chore: ux improvements
1 parent cbf4921 commit 2a1034e

3 files changed

Lines changed: 32 additions & 22 deletions

File tree

src/lib/editor/Mirror.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,24 +83,30 @@ MyStrangeSurface := SurfaceRule {
8383
let selectedPreset = $state<null | string>(null);
8484
</script>
8585

86-
<section class="flex w-full flex-col items-stretch">
86+
<section class="flex h-full w-full flex-col items-stretch">
8787
<header class="flex justify-between px-8">
8888
<h2 class="text-lg font-bold">Source Editor</h2>
89-
<div>
90-
<select bind:value={selectedPreset}>
89+
<div class="flex items-center gap-4">
90+
<select bind:value={selectedPreset} class="border-b border-b-slate-800">
9191
<option disabled></option>
9292
{#each presets as { label, content }}
9393
<option value={content}>{label}</option>
9494
{/each}
9595
</select>
9696
<button
97+
disabled={!selectedPreset}
98+
class="
99+
px-1 py-0.5 hover:bg-slate-200
100+
active:bg-slate-300 disabled:cursor-default disabled:bg-transparent disabled:text-gray-500
101+
"
97102
onclick={() => {
98103
if (!selectedPreset) return;
99104
file.updateContent(selectedPreset);
100105
syncView();
106+
selectedPreset = '';
101107
}}>Load Preset</button
102108
>
103109
</div>
104110
</header>
105-
<div use:editor></div>
111+
<div class="overflow-y-auto" use:editor></div>
106112
</section>

src/lib/editor/presets.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ MyStrangeSurface := SurfaceRule {
2020
`.trim()
2121
},
2222
{
23-
label: 'Vanilla Overwordl Badlands',
23+
label: 'Vanilla Overworld Badlands',
2424
content: `
25-
namespace MySpace;
25+
namespace MySpace;
2626
2727
InBadlands := SurfaceCondition {
2828
Biome [
@@ -95,6 +95,6 @@ Badlands := SurfaceRule {
9595
If (StoneDepth Floor 0 add 0) WhiteTerracotta
9696
]
9797
}
98-
`
98+
`.trim()
9999
}
100100
];

src/routes/+page.svelte

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
});
5353
</script>
5454

55-
<div class="flex h-svh min-h-svh w-svw flex-col gap-8 px-8 pb-8">
55+
<div class="grid grid-rows-[auto_1fr] max-h-svh h-svh min-h-svh w-svw gap-8 px-8 pb-8">
5656
<header class="relative px-2 py-1">
5757
<h1 class="text-xl font-bold">Minecraft Metascript Demo Editor</h1>
5858
<p class="max-w-[100ch] text-xs">
@@ -71,9 +71,9 @@
7171
{#await project.init()}
7272
Initializing your MMS Project...
7373
{:then _}
74-
<div class="grid flex-1 grid-cols-5 gap-4">
74+
<div class="grid flex-1 grid-cols-5 grid-rows-6 gap-4 min-h-0">
7575
<aside
76-
class="col-span-1 flex h-full w-full flex-col gap-4 overflow-x-hidden bg-slate-100 px-2 py-1 font-mono text-sm text-ellipsis"
76+
class="col-span-1 row-span-6 flex h-full w-full flex-col gap-4 overflow-x-hidden bg-slate-100 px-2 py-1 font-mono text-sm text-ellipsis"
7777
>
7878
<section class="w-full">
7979
<h2 class="font-bold uppercase">Project Files</h2>
@@ -103,19 +103,23 @@
103103
{/if}
104104
</section>
105105
</aside>
106-
<div class="col-span-4 flex flex-1 flex-col gap-4">
107-
<Mirror {project} />
106+
<div class="col-span-4 row-span-6 max-h-full grid grid-cols-1 grid-rows-subgrid gap-4 overflow-y-auto">
107+
<div class="row-span-4 min-h-0">
108+
<Mirror {project} />
109+
</div>
108110
{#if previewContent}
109-
<h2 class="text-lg">
110-
Preview:
111-
<span class="text-sm text-slate-400"
112-
>{selectedPreview?.path.slice(0, -1).join('/')}{(selectedPreview?.path.length ?? 0) >
113-
1
114-
? '/'
115-
: ''}</span
116-
><span class="font-bold">{selectedPreview?.path.at(-1)}</span>
117-
</h2>
118-
<div {@attach preview(previewContent)} class="w-full text-sm"></div>
111+
<div class="row-span-2 overflow-y-auto min-h-0">
112+
<h2 class="text-lg">
113+
Preview:
114+
<span class="text-sm text-slate-400"
115+
>{selectedPreview?.path.slice(0, -1).join('/')}{(selectedPreview?.path.length ??
116+
0) > 1
117+
? '/'
118+
: ''}</span
119+
><span class="font-bold">{selectedPreview?.path.at(-1)}</span>
120+
</h2>
121+
<div {@attach preview(previewContent)} class="w-full overflow-y-auto text-sm"></div>
122+
</div>
119123
{/if}
120124
</div>
121125
<!-- TODO: Implement text preview panel here -->

0 commit comments

Comments
 (0)