Skip to content

Commit 8c22aa4

Browse files
committed
Migrate components to svelte 5 runes syntax, minor css fixups, dependency bump
1 parent 47be06e commit 8c22aa4

20 files changed

+338
-184
lines changed

vscode-wpilib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@
513513
"run-sequence": "^2.2.1",
514514
"npm-run-all": "^4.1.5",
515515
"svelte": "^5.0.0",
516-
"svelte-preprocess": "^5.1.4",
516+
"svelte-preprocess": "^6.0.0",
517517
"terser-webpack-plugin": "^5.3.14",
518518
"ts-loader": "^9.5.4",
519519
"ts-node": "^9.1.1",

vscode-wpilib/resources/media/main.css

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,25 @@
291291
text-align: center;
292292
position: relative;
293293
transition: all 0.2s;
294+
background-color: var(--vscode-editor-background);
294295
}
295296

296297
.selection-card:hover {
297-
background-color: var(--vscode-list-hoverBackground);
298+
background-color: var(--vscode-button-background);
299+
border-color: var(--vscode-button-background);
300+
color: var(--vscode-button-foreground);
301+
}
302+
303+
.selection-card:hover h3,
304+
.selection-card:hover p,
305+
.selection-card:hover .card-icon {
306+
color: var(--vscode-button-foreground);
298307
}
299308

300309
.selection-card.selected {
301310
border-color: var(--vscode-button-background);
302-
background-color: var(--vscode-editor-lineHighlightBackground, rgba(255, 255, 255, 0.05));
311+
background-color: var(--vscode-editor-background);
312+
color: inherit;
303313
}
304314

305315
.selection-card h3 {
@@ -308,22 +318,22 @@
308318
}
309319

310320
.selection-card p {
311-
color: var(--vscode-descriptionForeground);
321+
/* color: var(--vscode-descriptionForeground); */
312322
font-size: 13px;
313323
margin-bottom: 16px;
314324
}
315325

316-
.card-icon {
326+
/* .card-icon {
317327
color: var(--vscode-descriptionForeground);
318-
}
328+
} */
319329

320330
.card-icon i.codicon {
321331
font-size: 48px;
322332
}
323333

324-
.selection-card.selected .card-icon {
334+
/* .selection-card.selected .card-icon {
325335
color: var(--vscode-button-background);
326-
}
336+
} */
327337

328338
.select-wrapper {
329339
position: relative;
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
<script lang="ts" context="module">
1+
<script lang="ts" module>
22
export interface SummaryItem {
33
label: string;
44
value?: string | number | null;
55
}
66
</script>
77

88
<script lang="ts">
9-
export let title: string | undefined = undefined;
10-
export let items: SummaryItem[] = [];
9+
interface Props {
10+
title?: string | undefined;
11+
items?: SummaryItem[];
12+
children?: import('svelte').Snippet;
13+
}
14+
15+
let { title = undefined, items = [], children }: Props = $props();
1116
</script>
1217

1318
<div class="summary-box">
1419
{#if title}
1520
<h3>{title}</h3>
1621
{/if}
1722

18-
<slot>
23+
{#if children}{@render children()}{:else}
1924
{#each items as item (item.label)}
2025
<div class="summary-row">
2126
<strong>{item.label}:</strong>
2227
<span>{item.value ?? ''}</span>
2328
</div>
2429
{/each}
25-
</slot>
30+
{/if}
2631
</div>
2732

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
<script lang="ts">
2-
export let message: string | undefined = undefined;
3-
export let visible = false;
4-
export let id: string | undefined = undefined;
5-
export let className = 'project-error-text';
2+
interface Props {
3+
message?: string | undefined;
4+
visible?: boolean;
5+
id?: string | undefined;
6+
className?: string;
7+
children?: import('svelte').Snippet;
8+
}
9+
10+
let {
11+
message = undefined,
12+
visible = false,
13+
id = undefined,
14+
className = 'project-error-text',
15+
children
16+
}: Props = $props();
617
</script>
718

819
<div
@@ -12,10 +23,10 @@
1223
aria-hidden={!visible}
1324
style:display={visible ? 'block' : 'none'}
1425
>
15-
<slot>
26+
{#if children}{@render children()}{:else}
1627
{#if message}
1728
{message}
1829
{/if}
19-
</slot>
30+
{/if}
2031
</div>
2132

vscode-wpilib/src/webviews/svelte/components/shared/WizardProgress.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
<script lang="ts" context="module">
1+
<script lang="ts" module>
22
export interface WizardProgressStep {
33
step: number;
44
label: string;
55
}
66
</script>
77

88
<script lang="ts">
9-
export let steps: WizardProgressStep[] = [];
10-
export let currentStep = 1;
9+
interface Props {
10+
steps?: WizardProgressStep[];
11+
currentStep?: number;
12+
}
13+
14+
let { steps = [], currentStep = 1 }: Props = $props();
1115
</script>
1216

1317
<div class="wizard-progress" role="list" aria-label="Wizard progress">
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
<script lang="ts">
2-
export let active = false;
3-
export let step: number | string | undefined = undefined;
4-
export let element: 'section' | 'div' = 'div';
5-
export let ariaLabelledBy: string | undefined = undefined;
2+
interface Props {
3+
active?: boolean;
4+
step?: number | string | undefined;
5+
element?: 'section' | 'div';
6+
ariaLabelledBy?: string | undefined;
7+
children?: import('svelte').Snippet;
8+
}
69
7-
$: classes = ['wizard-step', active ? 'active' : ''].filter(Boolean).join(' ');
10+
let {
11+
active = false,
12+
step = undefined,
13+
element = 'div',
14+
ariaLabelledBy = undefined,
15+
children
16+
}: Props = $props();
17+
18+
let classes = $derived(['wizard-step', active ? 'active' : ''].filter(Boolean).join(' '));
819
</script>
920

1021
{#if element === 'section'}
@@ -13,7 +24,7 @@
1324
data-step={step}
1425
aria-labelledby={ariaLabelledBy}
1526
>
16-
<slot />
27+
{@render children?.()}
1728
</section>
1829
{:else}
1930
<div
@@ -22,7 +33,7 @@
2233
aria-expanded={active}
2334
aria-labelledby={ariaLabelledBy}
2435
>
25-
<slot />
36+
{@render children?.()}
2637
</div>
2738
{/if}
2839

vscode-wpilib/src/webviews/svelte/dependencyview/AvailableDependencies.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
55
const dispatch = createEventDispatcher();
66
7-
export let dependencies: AvailableDependency[] = [];
7+
interface Props {
8+
dependencies?: AvailableDependency[];
9+
}
10+
11+
let { dependencies = [] }: Props = $props();
812
</script>
913

1014
{#if dependencies.length === 0}
@@ -14,7 +18,7 @@
1418
<div class="available-dependency">
1519
<div class="dependency-header">
1620
<span class="dependency-name">{dependency.name}</span>
17-
<button class="vscode-button" on:click={() => dispatch('install', { index })}>
21+
<button class="vscode-button" onclick={() => dispatch('install', { index })}>
1822
<i class="codicon codicon-add"></i>
1923
<span> Install</span>
2024
</button>

vscode-wpilib/src/webviews/svelte/dependencyview/DependencyView.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
available?: AvailableDependency[];
1313
}
1414
15-
let installedDependencies: InstalledDependency[] = [];
16-
let availableDependencies: AvailableDependency[] = [];
17-
let urlInput = '';
15+
let installedDependencies: InstalledDependency[] = $state([]);
16+
let availableDependencies: AvailableDependency[] = $state([]);
17+
let urlInput = $state('');
1818
1919
const updateAll = () => {
2020
postMessage({ type: 'updateall' });
@@ -57,7 +57,7 @@
5757
</script>
5858

5959
<div class="top-line">
60-
<button id="updateall-action" class="vscode-button block" disabled={installedDependencies.length === 0} on:click={updateAll}>
60+
<button id="updateall-action" class="vscode-button block" disabled={installedDependencies.length === 0} onclick={updateAll}>
6161
<i class="codicon codicon-sync"></i>
6262
<span>Update All Dependencies</span>
6363
</button>

vscode-wpilib/src/webviews/svelte/dependencyview/InstalledDependencies.svelte

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<script lang="ts">
2+
import { run } from 'svelte/legacy';
3+
24
import { createEventDispatcher } from 'svelte';
35
import type { InstalledDependency } from './types';
46
57
const dispatch = createEventDispatcher();
68
7-
export let dependencies: InstalledDependency[] = [];
9+
interface Props {
10+
dependencies?: InstalledDependency[];
11+
}
12+
13+
let { dependencies = [] }: Props = $props();
814
9-
let selectedVersions: string[] = [];
15+
let selectedVersions: string[] = $state([]);
1016
11-
$: {
17+
run(() => {
1218
const nextSelected = dependencies.map((dep, index) => selectedVersions[index] ?? dep.currentVersion);
1319
if (
1420
nextSelected.length !== selectedVersions.length ||
1521
nextSelected.some((value, idx) => value !== selectedVersions[idx])
1622
) {
1723
selectedVersions = nextSelected;
1824
}
19-
}
25+
});
2026
2127
const getButtonText = (dependency: InstalledDependency, selectedVersion: string) => {
2228
const entry = dependency.versionInfo.find((info) => info.version === selectedVersion);
@@ -56,15 +62,15 @@
5662
<button
5763
class="vscode-button"
5864
disabled={isUpdateDisabled(dependency, selectedVersions[index])}
59-
on:click={() => dispatch('update', { index, version: selectedVersions[index] })}
65+
onclick={() => dispatch('update', { index, version: selectedVersions[index] })}
6066
>
6167
{getButtonText(dependency, selectedVersions[index])}
6268
</button>
6369

6470
<button
6571
class="uninstall-button vscode-button"
6672
title={`Uninstall ${dependency.name}`}
67-
on:click={() => dispatch('uninstall', { index })}
73+
onclick={() => dispatch('uninstall', { index })}
6874
>
6975
<i class="codicon codicon-trash"></i>
7076
</button>

vscode-wpilib/src/webviews/svelte/dependencyview/UrlInstallSection.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
44
const dispatch = createEventDispatcher();
55
6-
export let url = '';
6+
interface Props {
7+
url?: string;
8+
}
9+
10+
let { url = $bindable('') }: Props = $props();
711
812
const install = () => {
913
if (url.trim().length === 0) {
@@ -28,9 +32,9 @@
2832
type="text"
2933
placeholder="Enter vendordep URL..."
3034
bind:value={url}
31-
on:keypress={onKeyPress}
35+
onkeypress={onKeyPress}
3236
/>
33-
<button id="install-url-action" class="vscode-button" on:click={install}>
37+
<button id="install-url-action" class="vscode-button" onclick={install}>
3438
<i class="codicon codicon-cloud-download"></i>
3539
<span> Install</span>
3640
</button>

0 commit comments

Comments
 (0)