Skip to content

Commit

Permalink
search
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Dec 23, 2024
1 parent b0cadda commit b885c77
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 114 deletions.
12 changes: 5 additions & 7 deletions backend/templates/v2/public/all-ngos.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ <h1 class="text-3xl font-bold text-center text-gray-900">

<section class="container grid gap-12">
<!-- Search and filters -->
{% include "public/components/ngo-search.html" %}
<form action="" method="GET">
{% include "public/components/ngo-search.html" %}
</form>

<div class="grid gap-x-8 gap-y-16 sm:grid-cols-2 lg:grid-cols-4 xl:gap-x-10 xl:gap-y-20">
<div class="col-span-full">
{% include "public/components/pagination.html" with page_obj=page_obj %}
</div>
{% include "public/components/pagination.html" with page_obj=page_obj %}


{% for ngo in ngos %}
{% include "public/components/ngo-card.html" with ngo=ngo %}
{% endfor %}
</div>

<div class="col-span-full">
{% include "public/components/pagination.html" with page_obj=page_obj %}
</div>
{% include "public/components/pagination.html" with page_obj=page_obj %}
</section>

{% endblock %}
43 changes: 43 additions & 0 deletions backend/templates/v2/public/components/home-hero-search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="relative pt-8 pb-4" x-data="ngoSearch" x-on:click.outside="close">
<ul
id="ngo-results"
role="listbox"
class="absolute w-full pt-10 overflow-auto text-sm bg-white border border-gray-300 shadow-lg rounded-2xl max-h-60 ring-1 ring-black/5 focus:outline-none sm:text-sm"
x-show="isOpen"
x-cloak
>
<template x-for="(ngo, index) in results" :key="index">
<li
class="relative cursor-default select-none"
role="option"
tabindex="-1">

<a
class="block px-3 py-2 text-gray-900 truncate hover:bg-amber-300 hover:outline-none"
:href="ngo.url"
>
<span x-text="ngo.name"></span>
</a>
</li>
</template>
</ul>

<label class="relative grid grid-cols-1">
<span class="sr-only">Caută un ONG după nume sau CUI/CIF</span>

<input
type="text"
class="border-none col-start-1 row-start-1 block w-full rounded-full bg-white py-1.5 pl-10 pr-3 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-amber-300 sm:pl-9 sm:text-sm/6 focus:outline-none"
role="combobox"
aria-controls="ngo-results"
placeholder="Caută un ONG după nume sau CUI/CIF"
x-model.debounce="query"
autocomplete="off"
x-on:click="open"
>

<svg class="self-center col-start-1 row-start-1 ml-3 text-gray-400 pointer-events-none size-5 sm:size-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M9 3.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11ZM2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Z" clip-rule="evenodd" />
</svg>
</label>
</div>
3 changes: 1 addition & 2 deletions backend/templates/v2/public/components/home-hero.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ <h1 class="block mt-1 text-4xl font-extrabold tracking-tight sm:text-5xl xl:text
Declarația 230 pentru redirecționarea a 3,5% din impozitul pe venit aferent anului 2024 va fi disponibilă după 15 ianuarie 2025.
</p>

{% include "public/components/ngo-search.html" %}
{% include "public/components/home-hero-search.html" %}

{% include "public/components/home-hero-stats.html" %}

</div>
</div>
<div class="mt-20 sm:mt-24 md:mx-auto md:max-w-2xl lg:mx-0 lg:mt-0 lg:w-screen lg:col-span-5">
Expand Down
28 changes: 1 addition & 27 deletions backend/templates/v2/public/components/ngo-search.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
<div class="relative pt-8 pb-4" x-data="ngoSearch" x-on:click.outside="close">
<ul
id="ngo-results"
role="listbox"
class="absolute w-full pt-10 overflow-auto text-sm bg-white border border-gray-300 shadow-lg rounded-2xl max-h-60 ring-1 ring-black/5 focus:outline-none sm:text-sm"
x-show="isOpen"
x-cloak
>
<template x-for="(ngo, index) in results" :key="index">
<li
class="relative cursor-default select-none"
role="option"
tabindex="-1">

<a
class="block px-3 py-2 text-gray-900 truncate hover:bg-amber-300 hover:outline-none"
:href="ngo.url"
>
<span x-text="ngo.name"></span>
</a>
</li>
</template>
</ul>

<label class="relative grid grid-cols-1">
<span class="sr-only">Caută un ONG după nume sau CUI/CIF</span>

<input
type="text"
name="q"
class="border-none col-start-1 row-start-1 block w-full rounded-full bg-white py-1.5 pl-10 pr-3 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-amber-300 sm:pl-9 sm:text-sm/6 focus:outline-none"
role="combobox"
aria-controls="ngo-results"
placeholder="Caută un ONG după nume sau CUI/CIF"
x-model.debounce="query"
autocomplete="off"
x-on:click="open"
>

<svg class="self-center col-start-1 row-start-1 ml-3 text-gray-400 pointer-events-none size-5 sm:size-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
Expand Down
106 changes: 54 additions & 52 deletions backend/templates/v2/public/components/pagination.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
{% load elided_pagination %}

<div class="flex items-center justify-between">
<div class="flex justify-between flex-1 sm:hidden">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}" class="inline-flex items-center text-sm font-medium text-gray-500 hover:text-yellow-400">
<svg class="mr-3 size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M18 10a.75.75 0 0 1-.75.75H4.66l2.1 1.95a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 1 1 1.02 1.1l-2.1 1.95h12.59A.75.75 0 0 1 18 10Z" clip-rule="evenodd" />
</svg>
Previous
</a>
{% endif %}

<div class="flex justify-end flex-1 w-0 -mt-px">
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="inline-flex items-center text-sm font-medium text-gray-500 hover:text-yellow-400">
Next
<svg class="ml-3 size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M2 10a.75.75 0 0 1 .75-.75h12.59l-2.1-1.95a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.1-1.95H2.75A.75.75 0 0 1 2 10Z" clip-rule="evenodd" />
{% if page_obj.paginator.num_pages > 1 %}
<div class="flex items-center justify-between col-span-full">
<div class="flex justify-between flex-1 sm:hidden">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}" class="inline-flex items-center text-sm font-medium text-gray-500 hover:text-yellow-400">
<svg class="mr-3 size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M18 10a.75.75 0 0 1-.75.75H4.66l2.1 1.95a.75.75 0 1 1-1.02 1.1l-3.5-3.25a.75.75 0 0 1 0-1.1l3.5-3.25a.75.75 0 1 1 1.02 1.1l-2.1 1.95h12.59A.75.75 0 0 1 18 10Z" clip-rule="evenodd" />
</svg>
Previous
</a>
{% endif %}
</div>
</div>

<div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
<div class="text-sm text-gray-700">
<span class="font-medium">{{ page_obj.paginator.count }}</span>
organizații
<div class="flex justify-end flex-1 w-0 -mt-px">
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="inline-flex items-center text-sm font-medium text-gray-500 hover:text-yellow-400">
Next
<svg class="ml-3 size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M2 10a.75.75 0 0 1 .75-.75h12.59l-2.1-1.95a.75.75 0 1 1 1.02-1.1l3.5 3.25a.75.75 0 0 1 0 1.1l-3.5 3.25a.75.75 0 1 1-1.02-1.1l2.1-1.95H2.75A.75.75 0 0 1 2 10Z" clip-rule="evenodd" />
</svg>
</a>
{% endif %}
</div>
</div>

<nav class="inline-flex gap-1 isolate" aria-label="Pagination">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}" class="relative inline-flex items-center justify-center text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Previous</span>
<svg class="size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M11.78 5.22a.75.75 0 0 1 0 1.06L8.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06l-4.25-4.25a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0Z" clip-rule="evenodd" />
</svg>
</a>
{% endif %}
<div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
<div class="text-sm text-gray-700">
<span class="font-medium">{{ page_obj.paginator.count }}</span>
organizații
</div>

{% adjusted_elided_page_range paginator page_obj.number 2 1 as page_range %}

{% for num in page_range %}
{% if num == '…' %}
<span class="relative inline-flex items-center justify-center text-sm font-semibold text-gray-500 rounded-full w-9 h-9 focus:outline-offset-0">&hellip;</span>
{% elif page_obj.number == num %}
<a href="?page={{ num }}" aria-current="page" class="relative z-10 inline-flex items-center justify-center text-sm font-semibold text-gray-900 bg-yellow-400 rounded-full w-9 h-9 focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-yellow-400">{{ num }}</a>
{% else %}
<a href="?page={{ num }}" class="relative inline-flex items-center justify-center text-sm font-semibold text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">{{ num }}</a>
<nav class="inline-flex gap-1 isolate" aria-label="Pagination">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}" class="relative inline-flex items-center justify-center text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Previous</span>
<svg class="size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M11.78 5.22a.75.75 0 0 1 0 1.06L8.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06l-4.25-4.25a.75.75 0 0 1 0-1.06l4.25-4.25a.75.75 0 0 1 1.06 0Z" clip-rule="evenodd" />
</svg>
</a>
{% endif %}
{% endfor %}

{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="relative inline-flex items-center justify-center text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Next</span>
<svg class="size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
</svg>
</a>
{% endif %}
</nav>
{% adjusted_elided_page_range paginator page_obj.number 2 1 as page_range %}

{% for num in page_range %}
{% if num == '…' %}
<span class="relative inline-flex items-center justify-center text-sm font-semibold text-gray-500 rounded-full w-9 h-9 focus:outline-offset-0">&hellip;</span>
{% elif page_obj.number == num %}
<a href="?page={{ num }}" aria-current="page" class="relative z-10 inline-flex items-center justify-center text-sm font-semibold text-gray-900 bg-yellow-400 rounded-full w-9 h-9 focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-yellow-400">{{ num }}</a>
{% else %}
<a href="?page={{ num }}" class="relative inline-flex items-center justify-center text-sm font-semibold text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">{{ num }}</a>
{% endif %}
{% endfor %}

{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}" class="relative inline-flex items-center justify-center text-gray-500 rounded-full w-9 h-9 hover:bg-yellow-100 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Next</span>
<svg class="size-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
</svg>
</a>
{% endif %}
</nav>

</div>
</div>
</div>
{% endif %}
Loading

0 comments on commit b885c77

Please sign in to comment.