defmodule PhoenixDuskmoon.Component.Modal do use PhoenixDuskmoon.Component, :html import PhoenixDuskmoon.Component.Icons @doc """ Open ad dialog modal. ## Examples ```heex <.dm_modal> <:trigger :let={f}> <:title>PhoenixDuskmoon <:body>PhoenixDuskmoon Storybook ``` """ @doc type: :component attr(:id, :any, doc: "Modal id") attr(:class, :any, default: "", doc: "Modal class" ) attr(:hide_close, :boolean, default: false, doc: "Hide top right close button" ) slot(:trigger, doc: "Modal trigger") slot(:title, doc: "Modal title") do attr(:class, :any, doc: "html class") end slot(:body, doc: "Modal content", required: true) slot(:footer, doc: "Modal footer, buttons") do attr(:class, :any, doc: "html class") end def dm_modal(assigns) do assigns = assigns |> assign_new(:id, fn -> "modal-#{Enum.random(0..999_999)}" end) ~H""" <%= render_slot(@trigger, @id) %> """ end end