Skip to content
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

fix: added Svelte version check to runes widget in Playground #1072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions packages/repl/src/lib/Input/RunesInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

let { runes }: { runes: boolean } = $props();

const { workspace } = get_repl_context();
const { workspace, svelteVersion } = get_repl_context();
const majorVersion = Number(svelteVersion.split(".")[0]);
</script>

<Dropdown align="right">
Expand All @@ -16,7 +17,12 @@

{#snippet dropdown()}
<div class="popup">
{#if workspace.current.name.endsWith('.svelte.js')}
{#if Number.isInteger(majorVersion) && majorVersion < 5}
<p>
<a href="/blog/runes">Runes</a> are available from Svelte 5 onwards, and this playground is
using Svelte {svelteVersion}.
</p>
{:else if workspace.current.name.endsWith('.svelte.js')}
<p>
Files with a <code>.svelte.js</code> extension are always in
<a href="/blog/runes">runes mode</a>.
Expand Down
3 changes: 2 additions & 1 deletion packages/repl/src/lib/Repl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
set_repl_context({
bundle,
toggleable,
workspace
workspace,
svelteVersion
});

let current_token: Symbol;
Expand Down
1 change: 1 addition & 0 deletions packages/repl/src/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export type ReplContext = {
bundle: Writable<ReplState['bundle']>;
toggleable: Writable<ReplState['toggleable']>;
workspace: Workspace;
svelteVersion: string;
};