clean up search form behaviour
This commit is contained in:
@@ -21,34 +21,11 @@
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
<div class="flex-1 flex flex-col">
|
||||
<section class="bg-white border-b border-slate-200">
|
||||
<section id="search">
|
||||
<div class="max-w-7xl mx-auto px-4 pb-1 space-y-4">
|
||||
<%= form_with url: entries_path,
|
||||
method: :get,
|
||||
data: { turbo_stream: true } do |form| %>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||
<svg class="h-5 w-5 text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div class="absolute inset-y-0 right-0 pr-4 flex items-center">
|
||||
<button type="button"
|
||||
class="text-slate-400 hover:text-slate-600 text-2xl leading-none <%= @query.present? ? "" : "hidden" %>"
|
||||
data-clear-search
|
||||
aria-label="Clear search"
|
||||
onclick="const input=this.closest('form').querySelector('input[name=q]'); if(input){input.value='';} this.closest('form').requestSubmit();">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<%= form.text_field :q,
|
||||
value: @query,
|
||||
placeholder: "Search words, phrases, or biblical terms...",
|
||||
class: "block w-full pl-11 pr-10 mt-2 mb-2 py-4 bg-white border border-slate-200 rounded-2xl shadow-sm focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 transition",
|
||||
oninput: "const clearBtn=this.form.querySelector('[data-clear-search]'); if(clearBtn){clearBtn.classList.toggle('hidden', this.value.length===0);} this.form.requestSubmit();" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= render "entries/search_form" %>
|
||||
|
||||
<div id="entries_filters" class="hidden">
|
||||
<%= render "entries/filters" %>
|
||||
@@ -59,6 +36,7 @@
|
||||
<div id="entries_results">
|
||||
<%= render "entries/results" %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user