Skip to content

fix runes mode indicator #9388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
/** @type {boolean} */
export let show_modified;

/** @type {boolean} */
export let runes;

/** @type {ReturnType<typeof createEventDispatcher<{
* remove: { files: import('$lib/types').File[]; diff: import('$lib/types').File },
* add: { files: import('$lib/types').File[]; diff: import('$lib/types').File },
Expand Down Expand Up @@ -292,7 +295,7 @@
</svg>
</button>

<div class="runes-info"><RunesInfo /></div>
<div class="runes-info"><RunesInfo {runes} /></div>
</div>

<style>
Expand Down
9 changes: 6 additions & 3 deletions sites/svelte-5-preview/src/lib/Input/RunesInfo.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<script>
import { get_repl_context } from '$lib/context.js';

/** @type {boolean} */
export let runes;

let open = false;

const { selected_name, runes_mode } = get_repl_context();
const { selected_name } = get_repl_context();
</script>

<svelte:window
Expand All @@ -13,7 +16,7 @@
/>

<div class="container">
<button class:active={$runes_mode} class:open on:click={() => (open = !open)}>
<button class:active={runes} class:open on:click={() => (open = !open)}>
<svg viewBox="0 0 24 24">
<path d="M9.4,1H19l-5.9,7.7h8L8.3,23L11,12.6H3.5L9.4,1z" />
</svg>
Expand All @@ -40,7 +43,7 @@
extension to <code>.svelte.js</code>.
</p>
{:else if $selected_name.endsWith('.svelte')}
{#if $runes_mode}
{#if runes}
<p>
This component is in
<a href="https://svelte.dev/blog/runes">runes mode</a>.
Expand Down
12 changes: 6 additions & 6 deletions sites/svelte-5-preview/src/lib/Repl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
export let showAst = false;
export let autocomplete = true;

let runes = false;

export function toJSON() {
return {
imports: $bundle?.imports ?? [],
Expand Down Expand Up @@ -113,9 +115,6 @@
/** @type {ReplContext['toggleable']} */
const toggleable = writable(false);

/** @type {ReplContext['runes_mode']} */
const runes_mode = writable(false);

/** @type {ReplContext['bundler']} */
const bundler = writable(null);

Expand All @@ -133,7 +132,6 @@
cursor_pos,
module_editor,
toggleable,
runes_mode,

EDITOR_STATE_MAP,

Expand Down Expand Up @@ -256,7 +254,9 @@

if ($selected.type === 'svelte' || $selected.type === 'js') {
compiled = await compiler.compile($selected, $compile_options, false);
$runes_mode = compiled.metadata?.runes ?? false;
runes = compiled.result.metadata?.runes ?? false;
} else {
runes = false;
}
}

Expand Down Expand Up @@ -324,7 +324,7 @@
max="-4.1rem"
>
<section slot="a">
<ComponentSelector show_modified={showModified} on:add on:remove />
<ComponentSelector show_modified={showModified} {runes} on:add on:remove />
<ModuleEditor
{autocomplete}
error={compiled?.result.error}
Expand Down
2 changes: 0 additions & 2 deletions sites/svelte-5-preview/src/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export type ReplState = {
cursor_pos: number;
toggleable: boolean;
module_editor: import('./CodeMirror.svelte').default | null;
runes_mode: boolean;
};

export type ReplContext = {
Expand All @@ -61,7 +60,6 @@ export type ReplContext = {
cursor_pos: Writable<ReplState['cursor_pos']>;
toggleable: Writable<ReplState['toggleable']>;
module_editor: Writable<ReplState['module_editor']>;
runes_mode: Writable<ReplState['runes_mode']>;

EDITOR_STATE_MAP: Map<string, EditorState>;

Expand Down