Skip to content

Commit 304a29e

Browse files
authored
fix runes mode indicator (#9388)
* fix runes mode indicator * tidy up --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 7bcd33d commit 304a29e

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

sites/svelte-5-preview/src/lib/Input/ComponentSelector.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
/** @type {boolean} */
88
export let show_modified;
99
10+
/** @type {boolean} */
11+
export let runes;
12+
1013
/** @type {ReturnType<typeof createEventDispatcher<{
1114
* remove: { files: import('$lib/types').File[]; diff: import('$lib/types').File },
1215
* add: { files: import('$lib/types').File[]; diff: import('$lib/types').File },
@@ -292,7 +295,7 @@
292295
</svg>
293296
</button>
294297
295-
<div class="runes-info"><RunesInfo /></div>
298+
<div class="runes-info"><RunesInfo {runes} /></div>
296299
</div>
297300
298301
<style>

sites/svelte-5-preview/src/lib/Input/RunesInfo.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<script>
22
import { get_repl_context } from '$lib/context.js';
33
4+
/** @type {boolean} */
5+
export let runes;
6+
47
let open = false;
58
6-
const { selected_name, runes_mode } = get_repl_context();
9+
const { selected_name } = get_repl_context();
710
</script>
811

912
<svelte:window
@@ -13,7 +16,7 @@
1316
/>
1417

1518
<div class="container">
16-
<button class:active={$runes_mode} class:open on:click={() => (open = !open)}>
19+
<button class:active={runes} class:open on:click={() => (open = !open)}>
1720
<svg viewBox="0 0 24 24">
1821
<path d="M9.4,1H19l-5.9,7.7h8L8.3,23L11,12.6H3.5L9.4,1z" />
1922
</svg>
@@ -40,7 +43,7 @@
4043
extension to <code>.svelte.js</code>.
4144
</p>
4245
{:else if $selected_name.endsWith('.svelte')}
43-
{#if $runes_mode}
46+
{#if runes}
4447
<p>
4548
This component is in
4649
<a href="https://svelte.dev/blog/runes">runes mode</a>.

sites/svelte-5-preview/src/lib/Repl.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
export let showAst = false;
3030
export let autocomplete = true;
3131
32+
let runes = false;
33+
3234
export function toJSON() {
3335
return {
3436
imports: $bundle?.imports ?? [],
@@ -113,9 +115,6 @@
113115
/** @type {ReplContext['toggleable']} */
114116
const toggleable = writable(false);
115117
116-
/** @type {ReplContext['runes_mode']} */
117-
const runes_mode = writable(false);
118-
119118
/** @type {ReplContext['bundler']} */
120119
const bundler = writable(null);
121120
@@ -133,7 +132,6 @@
133132
cursor_pos,
134133
module_editor,
135134
toggleable,
136-
runes_mode,
137135
138136
EDITOR_STATE_MAP,
139137
@@ -256,7 +254,9 @@
256254
257255
if ($selected.type === 'svelte' || $selected.type === 'js') {
258256
compiled = await compiler.compile($selected, $compile_options, false);
259-
$runes_mode = compiled.metadata?.runes ?? false;
257+
runes = compiled.result.metadata?.runes ?? false;
258+
} else {
259+
runes = false;
260260
}
261261
}
262262
@@ -324,7 +324,7 @@
324324
max="-4.1rem"
325325
>
326326
<section slot="a">
327-
<ComponentSelector show_modified={showModified} on:add on:remove />
327+
<ComponentSelector show_modified={showModified} {runes} on:add on:remove />
328328
<ModuleEditor
329329
{autocomplete}
330330
error={compiled?.result.error}

sites/svelte-5-preview/src/lib/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export type ReplState = {
4747
cursor_pos: number;
4848
toggleable: boolean;
4949
module_editor: import('./CodeMirror.svelte').default | null;
50-
runes_mode: boolean;
5150
};
5251

5352
export type ReplContext = {
@@ -61,7 +60,6 @@ export type ReplContext = {
6160
cursor_pos: Writable<ReplState['cursor_pos']>;
6261
toggleable: Writable<ReplState['toggleable']>;
6362
module_editor: Writable<ReplState['module_editor']>;
64-
runes_mode: Writable<ReplState['runes_mode']>;
6563

6664
EDITOR_STATE_MAP: Map<string, EditorState>;
6765

0 commit comments

Comments
 (0)