parent
1f895f7ef5
commit
a3b5155337
@ -0,0 +1,50 @@
|
|||||||
|
defmodule DecentralisedBookIndexWeb.Components.MyComponents.JustSearchResources do
|
||||||
|
use Phoenix.Component
|
||||||
|
use DecentralisedBookIndexWeb, :verified_routes
|
||||||
|
|
||||||
|
alias DecentralisedBookIndex.Accounts.Role
|
||||||
|
|
||||||
|
attr :search_query, :string, default: ""
|
||||||
|
attr :select_options, :list, required: true
|
||||||
|
attr :selected_option, :string, required: true
|
||||||
|
attr :current_user, :map, default: nil
|
||||||
|
|
||||||
|
attr :search_placeholder, :string, default: "Search by name"
|
||||||
|
|
||||||
|
def just_search_resources(assigns) do
|
||||||
|
~H"""
|
||||||
|
<div class="relative bg-white shadow-md dark:bg-gray-800 sm:rounded-lg">
|
||||||
|
<div class="flex flex-col items-center justify-between p-4 space-y-3 md:flex-row md:space-y-0 md:space-x-4">
|
||||||
|
<div class="w-full grow">
|
||||||
|
<form class="flex items-center" phx-submit="search">
|
||||||
|
<label for="simple-search" class="sr-only">Search</label>
|
||||||
|
<div class="relative w-full">
|
||||||
|
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
|
||||||
|
<svg aria-hidden="true" class="w-5 h-5 text-gray-500 dark:text-gray-400" fill="currentColor" viewbox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<input name="query" type="text" id="simple-search" class="block w-full p-2 pl-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500" placeholder={@search_placeholder} value={@search_query}>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-col items-stretch justify-end flex-shrink-0 w-full space-y-2 md:w-auto md:flex-row md:space-y-0 md:items-center md:space-x-3">
|
||||||
|
<div class="flex items-center w-full space-x-3 md:w-auto">
|
||||||
|
<form phx-change="change-sort">
|
||||||
|
<select name="sort_by" id="sort_by" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||||
|
<%= for {name, value} <- @select_options do %>
|
||||||
|
<%= if value == @selected_option do %>
|
||||||
|
<option value={value} selected>{name}</option>
|
||||||
|
<% else %>
|
||||||
|
<option value={value}>{name}</option>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue