defmodule PetalComponents.Typography do use Phoenix.Component @moduledoc """ Everything related to text. Headings, paragraphs and links """ # <.h1>Heading # <.h1 label="Heading" /> # <.h1 label="Heading" class="mb-10" color_class="text-blue-500" /> attr(:class, :any, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "label your heading") attr(:no_margin, :boolean, default: nil, doc: "removes margin from headings") attr(:underline, :boolean, default: false, doc: "underlines a heading") attr(:color_class, :string, default: nil, doc: "adds a color class") attr(:rest, :global) slot(:inner_block, required: false) def h1(assigns) do ~H"""

<%= render_slot(@inner_block) || @label %>

""" end attr(:class, :any, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "label your heading") attr(:no_margin, :boolean, default: nil, doc: "removes margin from headings") attr(:underline, :boolean, default: false, doc: "underlines a heading") attr(:color_class, :string, default: nil, doc: "adds a color class") attr(:rest, :global) slot(:inner_block, required: false) def h2(assigns) do ~H"""

<%= render_slot(@inner_block) || @label %>

""" end attr(:class, :any, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "label your heading") attr(:no_margin, :boolean, default: nil, doc: "removes margin from headings") attr(:underline, :boolean, default: false, doc: "underlines a heading") attr(:color_class, :string, default: nil, doc: "adds a color class") attr(:rest, :global) slot(:inner_block, required: false) def h3(assigns) do ~H"""

<%= render_slot(@inner_block) || @label %>

""" end attr(:class, :any, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "label your heading") attr(:no_margin, :boolean, default: nil, doc: "removes margin from headings") attr(:underline, :boolean, default: false, doc: "underlines a heading") attr(:color_class, :string, default: nil, doc: "adds a color class") attr(:rest, :global) slot(:inner_block, required: false) def h4(assigns) do ~H"""

<%= render_slot(@inner_block) || @label %>

""" end attr(:class, :any, default: "", doc: "CSS class") attr(:label, :string, default: nil, doc: "label your heading") attr(:no_margin, :boolean, default: nil, doc: "removes margin from headings") attr(:underline, :boolean, default: false, doc: "underlines a heading") attr(:color_class, :string, default: nil, doc: "adds a color class") attr(:rest, :global) slot(:inner_block, required: false) def h5(assigns) do ~H"""
<%= render_slot(@inner_block) || @label %>
""" end defp get_heading_classes(base_classes, custom_classes, color_class, underline, no_margin) do [ base_classes, custom_classes, color_class || "pc-heading--color", underline && "pc-heading--underline", !no_margin && "pc-heading--margin" ] end attr(:class, :any, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def p(assigns) do ~H"""

<%= render_slot(@inner_block) %>

""" end attr(:class, :any, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def prose(assigns) do ~H"""
<%= render_slot(@inner_block) %>
""" end @doc """ Usage: <.ul>
  • Item 1
  • Item 2
  • """ attr(:class, :any, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def ul(assigns) do ~H""" """ end @doc """ Usage: <.ol>
  • Item 1
  • Item 2
  • """ attr(:class, :any, default: "", doc: "CSS class") attr(:rest, :global) slot(:inner_block, required: false) def ol(assigns) do ~H"""
      <%= render_slot(@inner_block) %>
    """ end end