11<script lang =" ts" >
2- import { ArrowBendDownLeft , ArrowElbowDownLeft , ArrowUDownLeft , MagnifyingGlass , MapPinSimple } from ' phosphor-svelte' ;
2+ import {
3+ ArrowBendDownLeft ,
4+ ArrowElbowDownLeft ,
5+ ArrowUDownLeft ,
6+ MagnifyingGlass ,
7+ MapPinSimple
8+ } from ' phosphor-svelte' ;
39 import { throttle } from ' lodash-es' ;
410 import type { GeocoderProvider } from ' $lib/geocoder/provider' ;
511 import type { GeojsonPoint } from ' @allmaps/types' ;
5561 }
5662
5763 $effect (() => {
58- if (visible ) inputEl .focus ();
59- else inputValue = " " ;
60- })
64+ if (visible ) inputEl .focus ();
65+ else inputValue = ' ' ;
66+ });
6167 </script >
6268
6369{#if visible }
64- <div
65- class =" fixed top-0 left-0 w-full h-full bg-[#33336688] z-1000"
66- onclick ={() => visible = false }
67- transition:fade
68- ></div >
69- <div
70- class =" z-1001 absolute top-50 left-1/2 w-120 -translate-x-1/2 overflow-hidden shadow-lg rounded-[8px] border-gray-200 bg-white"
71- transition:fly ={{ y : - 20 , duration : 250 }}
72- >
73- <div class =" relative w-full" >
74- <input
75- bind:this ={inputEl }
76- bind:value ={inputValue }
77- onkeydown ={(e ) => {
78- if (e .key == " Escape" ) visible = false ;
79- else if (e .key == " Enter" && features ) { flyToFeature (features [selectedFeature ]); visible = false }
80- else if (e .key == " ArrowDown" ) selectedFeature = Math .min (++ selectedFeature , features .length - 1 )
81- else if (e .key == " ArrowUp" ) selectedFeature = Math .max (-- selectedFeature , 0 )
82- }}
83- class =" px-4 py-4 pl-14 font-[500] text-[20px] w-full rounded-[16px] pr-2 pl-10 focus:z-10 focus:outline-none"
84- type =" search"
85- spellcheck =" false"
86- autocomplete =" off"
87- autofocus
88- placeholder =" Zoek een locatie..."
89- />
70+ <div
71+ class =" fixed top-0 left-0 z-1000 h-full w-full bg-[#33336688]"
72+ onclick ={() => (visible = false )}
73+ transition:fade
74+ ></div >
75+ <div
76+ class ="
77+ fixed top-1/4 left-1/2 z-1001
78+ w-[90vw] max-w-120 -translate-x-1/2
79+ overflow-hidden rounded-[8px] border-gray-200 bg-white shadow-lg"
80+ transition:fly ={{ y : - 20 , duration : 250 }}
81+ >
82+ <div class =" relative w-full" >
83+ <input
84+ bind:this ={inputEl }
85+ bind:value ={inputValue }
86+ onkeydown ={(e ) => {
87+ e .stopPropagation ();
88+ if (e .key == ' Escape' ) visible = false ;
89+ else if (e .key == ' Enter' && features ) {
90+ flyToFeature (features [selectedFeature ]);
91+ visible = false ;
92+ } else if (e .key == ' ArrowDown' )
93+ selectedFeature = Math .min (++ selectedFeature , features .length - 1 );
94+ else if (e .key == ' ArrowUp' ) selectedFeature = Math .max (-- selectedFeature , 0 );
95+ }}
96+ class =" w-full rounded-[16px] px-4 py-4 pr-2 pl-10 pl-14 text-[20px] font-[500] focus:z-10 focus:outline-none"
97+ type =" search"
98+ spellcheck =" false"
99+ autocomplete =" off"
100+ autofocus
101+ placeholder =" Zoek een locatie..."
102+ />
90103
91- <div class =" pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-gray-400" >
92- <MagnifyingGlass size =" 24" color =" #f4a" ></MagnifyingGlass >
104+ <div class =" pointer-events-none absolute top-1/2 left-4 -translate-y-1/2 text-gray-400" >
105+ <MagnifyingGlass size =" 24" color =" #f4a" ></MagnifyingGlass >
106+ </div >
93107 </div >
94- </div >
95-
96- {#if inputValue !== ' ' }
97- <ul
98- transition:slide
99- class =" relative left-0 top-full text-[#336] z-20 w-full overflow-hidden"
100- >
101- {#if features .length > 0 }
102- {#each features as feature , i }
103- <li
104- class =" flex cursor-pointer items-center justify-between px-4 py-3 text-[16px] font-[500] hover:bg-[#eef]"
105- style:background ={i == selectedFeature ? " #eef" : " transparent" }
106- >
107- <!-- <MapPinSimple size="20" class="inline"></MapPinSimple> -->
108- <div class =" truncate" >
109- {feature .properties .label }
110- {#if feature .properties .alt }
111- <span class =" text-gray-500 before:mx-1 before:content-['·']" >
112- {feature .properties .alt }
113- </span >
114- {/if }
115- </div >
116108
117- {#if i == selectedFeature }
118- < kbd
119- class = " bg-background-alt text-xxs pointer-events-none flex inline items-center gap-1 rounded-sm border px-1 font-sans font-medium opacity-50 shadow-[0px_2px_0px_0px_#59595b] select-none dark:border-[rgba(0,_0,_0,_0.10)] dark:bg-white dark:shadow-[0px_2px_0px_0px_#B8B8B8] "
120- >
121- < span class = " text-foreground-alt text-[12px] " >Enter</ span >
122- < ArrowElbowDownLeft size = " 16 " class = " inline " ></ ArrowElbowDownLeft >
123- </ kbd
109+ {#if inputValue ! == ' ' }
110+ < ul transition:slide class = " relative top-full left-0 z-20 w-full overflow-hidden text-[#336] " >
111+ { #if features . length > 0 }
112+ { #each features as feature , i }
113+ < li
114+ class = " flex cursor-pointer items-center justify-between px-4 py-3 text-[16px] font-[500] hover:bg-[#eef] "
115+ style:background ={ i == selectedFeature ? ' #eef ' : ' transparent ' }
124116 >
125- {/if }
126-
127- </li >
128- {/each }
129- {:else }
130- <li class =" px-4 py-3 text-sm text-[#33336688]" >
131- Geen resultaten gevonden
132- </li >
133- {/if }
134- </ul >
135- {/if }
136- </div >
137- {/if }
117+ <!-- <MapPinSimple size="20" class="inline"></MapPinSimple> -->
118+ <div class =" truncate" >
119+ {feature .properties .label }
120+ {#if feature .properties .alt }
121+ <span class =" text-gray-500 before:mx-1 before:content-['·']" >
122+ {feature .properties .alt }
123+ </span >
124+ {/if }
125+ </div >
126+
127+ {#if i == selectedFeature }
128+ <kbd
129+ class =" bg-background-alt text-xxs pointer-events-none flex inline items-center gap-1 rounded-sm border px-1 font-sans font-medium opacity-50 shadow-[0px_2px_0px_0px_#59595b] select-none dark:border-[rgba(0,_0,_0,_0.10)] dark:bg-white dark:shadow-[0px_2px_0px_0px_#B8B8B8]"
130+ >
131+ <span class =" text-foreground-alt text-[12px]" >Enter</span >
132+ <ArrowElbowDownLeft size =" 16" class =" inline" ></ArrowElbowDownLeft >
133+ </kbd >
134+ {/if }
135+ </li >
136+ {/each }
137+ {:else }
138+ <li class =" px-4 py-3 text-sm text-[#33336688]" >Geen resultaten gevonden</li >
139+ {/if }
140+ </ul >
141+ {/if }
142+ </div >
143+ {/if }
0 commit comments