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