defmodule Oban.Web.Components.Core do use Oban.Web, :html attr :click, :string, required: true attr :danger, :boolean, default: false attr :disabled, :boolean, default: false attr :label, :string, required: true attr :target, :any slot :icon slot :title def action_button(assigns) do class = cond do assigns.disabled -> "text-gray-400" assigns.danger -> "text-red-500 group-hover:text-red-600 hover:bg-gray-100 dark:hover:bg-gray-950" true -> "text-gray-500 group-hover:text-gray-600 hover:bg-gray-100 dark:hover:bg-gray-950" end assigns = assign(assigns, :class, class) ~H""" """ end @doc """ A numerical input with increment and decrement buttons. """ def number_input(assigns) do ~H"""
<%= if @label do %> <% end %>
""" end slot :inner_block, required: true attr :name, :string, required: true attr :options, :list, required: true attr :selected, :any, required: true attr :title, :string, required: true attr :disabled, :boolean, default: false attr :target, :any, default: "myself" def dropdown_button(assigns) do ~H"""
""" end attr :name, :any, required: true attr :value, :any, required: true attr :selected, :any, required: true attr :target, :any defp dropdown_option(assigns) do class = if assigns.selected == assigns.value do "text-blue-500 dark:text-blue-400" else "text-gray-500 dark:text-gray-400 " end assigns = assign(assigns, :class, class) ~H"""
  • <%= if to_string(@value) == to_string(@selected) do %> <% else %> <% end %> {@value |> to_string() |> String.replace("_", " ")}
  • """ end attr :checked, :boolean, default: false attr :click, :string, required: true attr :myself, :any, required: true attr :value, :string, required: true def row_checkbox(assigns) do style = if assigns.checked do "border-blue-500 bg-blue-500" else "border-gray-400 dark:border-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-600" end assigns = assign(assigns, :style, style) ~H""" """ end attr :checked, :atom, required: true attr :click, :string, required: true attr :myself, :any, required: true def all_checkbox(assigns) do style = if assigns.checked in [:all, :some] do "border-blue-500 bg-blue-500" else "border-gray-400 dark:border-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-600" end assigns = assign(assigns, :style, style) ~H""" """ end end