freedive/lib/freedive_web/live/liliform_live.ex

29 lines
754 B
Elixir
Raw Normal View History

defmodule FreediveWeb.LiliformLive do
defmacro __using__(opts) do
quote location: :keep, bind_quoted: [opts: opts] do
2024-05-15 22:18:55 +02:00
use FreediveWeb, :live_view
@behaviour FreediveWeb.LiliformLive
2024-05-16 01:37:36 +02:00
@all [
%{
title: "All",
icon: "all",
active: false
}
]
2024-05-16 01:37:36 +02:00
def(mount(_params, _session, socket)) do
socket = assign(socket, :opts, Keyword.get(unquote(opts), :opts, []))
socket = assign(socket, :items, items())
2024-05-16 01:37:36 +02:00
socket = assign(socket, :filters, @all ++ filters())
socket = assign(socket, :query, "")
{:ok, socket}
end
2024-05-16 01:37:36 +02:00
2024-05-15 22:18:55 +02:00
end
end
@callback items() :: [map]
2024-05-16 01:37:36 +02:00
@callback filters() :: [map]
@callback search(query :: String.t()) :: [map]
end