defmodule ChiyaWeb.CoreComponents do @moduledoc """ Provides core UI components. The components in this module use Tailwind CSS, a utility-first CSS framework. See the [Tailwind CSS documentation](https://tailwindcss.com) to learn how to customize the generated components in this module. Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage. """ use Phoenix.Component alias Phoenix.LiveView.JS import ChiyaWeb.Gettext @doc """ Renders a horizontal line """ def line(assigns) do ~H"""
""" end @doc """" Renders the admin menu bar """ attr :current_user, :map, required: true def admin_bar(assigns) do ~H""" """ end @doc """ Renders a UI for uploading files """ attr :upload, :map, required: true attr :cancel_upload, :string, default: "cancel-upload" def live_upload(assigns) do ~H"""
<.live_file_input upload={@upload} />
<%= for entry <- @upload.entries do %>
<.live_img_preview entry={entry} />
<%= entry.client_name %>
<%!-- entry.progress will update automatically for in-flight entries --%> <%= entry.progress %>% <%!-- a regular click event whose handler will invoke Phoenix.LiveView.cancel_upload/3 --%> <%!-- Phoenix.Component.upload_errors/2 returns a list of error atoms --%> <%= for err <- upload_errors(@upload, entry) do %>

<%= upload_error_to_string(err) %>

<% end %>
<% end %> <%!-- Phoenix.Component.upload_errors/1 returns a list of error atoms --%> <%= for err <- upload_errors(@upload) do %>

<%= upload_error_to_string(err) %>

<% end %>
""" end @doc """ Renders a modal. ## Examples <.modal id="confirm-modal"> Are you sure? <:confirm>OK <:cancel>Cancel JS commands may be passed to the `:on_cancel` and `on_confirm` attributes for the caller to react to each button press, for example: <.modal id="confirm" on_confirm={JS.push("delete")} on_cancel={JS.navigate(~p"/posts")}> Are you sure you? <:confirm>OK <:cancel>Cancel """ attr :id, :string, required: true attr :show, :boolean, default: false attr :on_cancel, JS, default: %JS{} attr :on_confirm, JS, default: %JS{} slot :inner_block, required: true slot :title slot :subtitle slot :confirm slot :cancel def modal(assigns) do ~H"""