X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/c9687b102bb6f544a034dc4d508bf0ae4a5fc221..9f280ac8ee3878fa1774be452a879e6d37b67510:/src/components/ResultsList.svelte

diff --git a/src/components/ResultsList.svelte b/src/components/ResultsList.svelte
index 584e481..2fc6828 100644
--- a/src/components/ResultsList.svelte
+++ b/src/components/ResultsList.svelte
@@ -1,11 +1,13 @@
 <script>
-  import { results_store, current_result_store } from '../lib/stores.js';
-  import { formatLabel, detailsURL } from '../lib/helpers.js';
+  import { results_store } from '../lib/stores.js';
+  import { formatLabel } from '../lib/helpers.js';
 
+  import DetailsLink from './DetailsLink.svelte';
   import Welcome from './Welcome.svelte';
   import MapIcon from './MapIcon.svelte';
 
-  export let reverse_search=false;
+  export let reverse_search = false;
+  export let current_result = null;
 
   let aSearchResults;
   let iHighlightNum;
@@ -15,7 +17,7 @@
     if (!data) { return; }
     aSearchResults = data;
     iHighlightNum = 0;
-    current_result_store.set(aSearchResults[0]);
+    current_result = aSearchResults[0];
 
 
     let search_params = new URLSearchParams(window.location.search);
@@ -39,12 +41,12 @@
 
   function handleClick(e) {
     let result_el = e.target;
-    if (! result_el.className.match('result') ){
+    if (!result_el.className.match('result')) {
       result_el = result_el.parentElement;
     }
     let pos = Number(result_el.dataset.position);
 
-    current_result_store.set(aSearchResults[pos]);
+    current_result = aSearchResults[pos];
     iHighlightNum = pos;
   }
 
@@ -60,9 +62,9 @@
         </div>
         <span class="name">{aResult.display_name}</span>
         <span class="type">{formatLabel(aResult)}</span>
-        <p class="coords">{aResult.lat},{aResult.lon}</p>  
+        <p class="coords">{aResult.lat},{aResult.lon}</p>
 
-        <a class="details btn btn-outline-secondary btn-sm" href="{detailsURL(aResult)}">details</a>
+        <DetailsLink extra_classes="btn btn-outline-secondary btn-sm" feature={aResult}>details</DetailsLink>
       </div>
     {/each}
 
@@ -101,17 +103,18 @@
     background-color: #D9E7F7;
     border-color: #9DB9E4;
   }
-  .result.highlight .details {
+  .result.highlight :global(a) {
     margin: 10px auto;
     display: block;
     max-width: 10em;
     padding: 1px;
+    background-color: white;
   }
   .result .type{
     color: gray;
     font-size: 0.8em;
   }
-  .result .details {
+  .result :global(a) {
     display: none;
   }
 
@@ -129,11 +132,7 @@
     margin-top: 1em;
   }
 
-  .btn-outline-secondary {
-    background-color: white;
-  }
-
-  .btn-outline-secondary:hover {
+  .result.highlight :global(a):hover {
     color: #111;
   }
-</style>
\ No newline at end of file
+</style>
