Skip to main content
Sign in
Snippets Groups Projects

Début du travail sur la nouvelle page d'accueil/d'atterrissage du simulateur

3 files
+ 104
15
Compare changes
  • Side-by-side
  • Inline

Files

<script lang="ts">
<script lang="ts">
export let isSearchActive: boolean
import type { SearchResult } from "minisearch"
export let searchQuery: string
 
import { browser } from "$app/environment"
 
import WithLinkedVariablesSearchWorker from "$lib/search/search_worker_variables_with_linked?worker"
 
 
let inProgress = false
 
let pendingQuery: string | null = null
 
let query = ""
 
let results: SearchResult[] = []
 
let worker: Worker | undefined = undefined
 
 
if (browser) {
 
worker = new WithLinkedVariablesSearchWorker()
 
worker.onmessage = function (event) {
 
results = event.data
 
 
// If there's no pending query, we're done!
 
if (pendingQuery === null) {
 
inProgress = false
 
} else {
 
// If we were waiting for results before searching again, run search
 
worker?.postMessage(pendingQuery)
 
pendingQuery = null
 
}
 
}
 
}
 
 
$: if (query.length > 0) {
 
search(query)
 
} else {
 
results = []
 
}
 
 
function search(query: string) {
 
if (worker === undefined) return
 
 
// If search is already running, save the query inside the
 
// pending query variable, awaiting results before searching again
 
if (inProgress) {
 
pendingQuery = query
 
return
 
}
 
 
inProgress = true
 
worker.postMessage(query)
 
}
</script>
</script>
<div
<div
class="flex gap-1.5 w-full overflow-hidden rounded-t-md border-2 border-neutral-200 border-b-4 border-b-[#A6A00C] bg-gray-100"
class="w-full flex items-center gap-1.5 overflow-hidden rounded-t-md border-2 border-neutral-200 border-b-4 border-b-[#A6A00C] bg-gray-100"
>
>
<iconify-icon
<iconify-icon
class="ml-4 self-center p-1 text-xl text-black"
class="ml-4 self-center p-1 text-xl text-black"
@@ -16,16 +60,18 @@
@@ -16,16 +60,18 @@
id="navbar_search"
id="navbar_search"
placeholder="impôt sur le revenu, CSG, ..."
placeholder="impôt sur le revenu, CSG, ..."
type="search"
type="search"
bind:value={searchQuery}
bind:value={query}
/>
/>
{#if isSearchActive}
{#if query.length > 0}
<iconify-icon
<button
class="md:mx-1 cursor-pointer self-center p-1 text-black"
class="md:mr-2.5 p-2 rounded-full hover:bg-black hover:bg-opacity-10 active:bg-black active:bg-opacity-20 transition-all duration-200 ease-out-back"
icon="ri-close-line"
on:click={() => (query = "")}
width="20"
>
height="20"
<iconify-icon class="block text-xl" icon="ri-close-line" />
on:click={() => (searchQuery = "")}
</button>
on:keyup
/>
{/if}
{/if}
</div>
</div>
 
 
{#if query.length > 0}
 
<slot {query} {results} />
 
{/if}
Loading