Implement spinner on load from search

pull/3463/head
Adrian Gruntkowski 3 years ago
parent 6c75cbba9c
commit 9aa04b1287

@ -421,7 +421,7 @@ defmodule PlausibleWeb.Live.Sites do
value={@filter_text}
x-ref="filter_text"
x-on:keydown.escape="$refs.filter_text.blur(); $refs.reset_filter?.dispatchEvent(new Event('click', {bubbles: true, cancelable: true}));"
x-on:keydown.prevent.slash.window="$refs.filter_text.focus();"
x-on:keydown.prevent.slash.window="$refs.filter_text.focus(); $refs.filter_text.select();"
x-on:blur="$refs.filter_text.placeholder = 'Press / to search sites';"
x-on:focus="$refs.filter_text.placeholder = 'Search sites';"
/>
@ -429,7 +429,7 @@ defmodule PlausibleWeb.Live.Sites do
<button
:if={String.trim(@filter_text) != ""}
class="ml-2 cursor-pointer"
class="phx-change-loading:hidden ml-2"
phx-click="reset-filter-text"
id="reset-filter"
x-ref="reset_filter"
@ -437,6 +437,8 @@ defmodule PlausibleWeb.Live.Sites do
>
<Heroicons.backspace class="feather hover:text-red-500 dark:text-gray-300 dark:hover:text-red-500" />
</button>
<.spinner class="hidden phx-change-loading:inline ml-2" />
</div>
</form>
"""
@ -451,6 +453,28 @@ defmodule PlausibleWeb.Live.Sites do
"""
end
attr :class, :any, default: ""
def spinner(assigns) do
~H"""
<svg
class={["animate-spin h-4 w-4 text-indigo-500", @class]}
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4">
</circle>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
>
</path>
</svg>
"""
end
def handle_event("filter", %{"filter_text" => filter_text}, socket) do
socket =
socket

Loading…
Cancel
Save