File tree Expand file tree Collapse file tree 2 files changed +13
-20
lines changed
apps/svelte.dev/src/routes/tutorial/[...slug]/filetree Expand file tree Collapse file tree 2 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 1
1
<!-- @component
2
2
A context menu for the tutorial's file tree
3
3
-->
4
- <script module >
5
- import { writable } from ' svelte/store ' ;
4
+ <script module lang = " ts " >
5
+ import type { MenuItem } from ' $lib/tutorial ' ;
6
6
7
- /**
8
- * @type {import("svelte/store").Writable<{x: number; y: number; items: import('$lib/tutorial').MenuItem[]} | null>}
9
- */
10
- let menu_items = writable (null );
7
+ let menu_items: { x: number ; y: number ; items: MenuItem [] } | null = $state (null );
11
8
12
- /**
13
- * @param {number} x
14
- * @param {number} y
15
- * @param {import('$lib/tutorial').MenuItem[]} items
16
- */
17
- export function open (x , y , items ) {
9
+ export function open(x : number , y : number , items : MenuItem []) {
18
10
if (items .length > 0 ) {
19
- menu_items . set ( { x, y, items }) ;
11
+ menu_items = { x , y , items };
20
12
}
21
13
}
22
14
</script >
23
15
24
- {#if $ menu_items }
25
- <nav style ="position: fixed; z-index: 5; top: {$ menu_items .y }px; left: {$ menu_items .x }px" >
16
+ {#if menu_items }
17
+ <nav style ="position: fixed; z-index: 5; top: {menu_items .y }px; left: {menu_items .x }px" >
26
18
<div class =" context-menu" >
27
19
<ul >
28
- {#each $ menu_items .items as item }
20
+ {#each menu_items .items as item }
29
21
<li >
30
- <button on:click ={item .fn }>{item .label }</button >
22
+ <button onclick ={item .fn }>{item .label }</button >
31
23
</li >
32
24
{/each }
33
25
</ul >
34
26
</div >
35
27
</nav >
36
28
{/if }
37
29
38
- <svelte:window on:click ={() => menu_items . set ( null )} />
30
+ <svelte:window onclick ={() => ( menu_items = null )} />
39
31
40
32
<style >
41
33
.context-menu {
Original file line number Diff line number Diff line change 2
2
import { tick } from ' svelte' ;
3
3
import { open } from ' ./ContextMenu.svelte' ;
4
4
import type { MenuItem } from ' $lib/tutorial' ;
5
+ import { forcefocus } from ' @sveltejs/site-kit/actions' ;
5
6
6
7
interface Props {
7
8
basename? : string ;
63
64
<!-- svelte-ignore a11y_autofocus -->
64
65
<input
65
66
type =" text"
66
- autofocus
67
+ use:forcefocus
67
68
autocomplete =" off"
68
69
spellcheck =" false"
69
70
value ={basename }
135
136
}
136
137
137
138
input {
138
- background : var (--sk-bg-1 );
139
+ background : var (--sk-bg-3 );
139
140
margin : 0 0.5rem 0 calc (0.5rem + var (--inset ));
140
141
border : 2px solid transparent ;
141
142
padding : 0 0.5rem ;
You can’t perform that action at this time.
0 commit comments