Skip to content

Commit

Permalink
fix runes mode indicator (#9388)
Browse files Browse the repository at this point in the history
* fix runes mode indicator

* tidy up

---------

Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
Rich-Harris and Rich-Harris authored Nov 11, 2023
1 parent 7bcd33d commit 304a29e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
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

1 comment on commit 304a29e

@vercel
Copy link

@vercel vercel bot commented on 304a29e Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-5-preview.vercel.app

Please sign in to comment.