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 11<!-- @component
22 A context menu for the tutorial's file tree
33-->
4- <script module >
5- import { writable } from ' svelte/store ' ;
4+ <script module lang = " ts " >
5+ import type { MenuItem } from ' $lib/tutorial ' ;
66
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 );
118
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 []) {
1810 if (items .length > 0 ) {
19- menu_items . set ( { x, y, items }) ;
11+ menu_items = { x , y , items };
2012 }
2113 }
2214 </script >
2315
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" >
2618 <div class =" context-menu" >
2719 <ul >
28- {#each $ menu_items .items as item }
20+ {#each menu_items .items as item }
2921 <li >
30- <button on:click ={item .fn }>{item .label }</button >
22+ <button onclick ={item .fn }>{item .label }</button >
3123 </li >
3224 {/each }
3325 </ul >
3426 </div >
3527 </nav >
3628{/if }
3729
38- <svelte:window on:click ={() => menu_items . set ( null )} />
30+ <svelte:window onclick ={() => ( menu_items = null )} />
3931
4032<style >
4133 .context-menu {
Original file line number Diff line number Diff line change 22 import { tick } from ' svelte' ;
33 import { open } from ' ./ContextMenu.svelte' ;
44 import type { MenuItem } from ' $lib/tutorial' ;
5+ import { forcefocus } from ' @sveltejs/site-kit/actions' ;
56
67 interface Props {
78 basename? : string ;
6364 <!-- svelte-ignore a11y_autofocus -->
6465 <input
6566 type =" text"
66- autofocus
67+ use:forcefocus
6768 autocomplete =" off"
6869 spellcheck =" false"
6970 value ={basename }
135136 }
136137
137138 input {
138- background : var (--sk-bg-1 );
139+ background : var (--sk-bg-3 );
139140 margin : 0 0.5rem 0 calc (0.5rem + var (--inset ));
140141 border : 2px solid transparent ;
141142 padding : 0 0.5rem ;
You can’t perform that action at this time.
0 commit comments