module CardsHelper
  def card_header(text: "", subtext: "", close_action_path: nil)
    heading = 
      content_tag(:div, class: "d-flex flex-row justify-content-between align-items-center") do
        concat content_tag(:h1, text, class: "h3")
        if close_action_path.present?
          concat link_to(t("shared.close"), close_action_path, class: "font-weight-bold small text-uppercase text-more-muted")
        end
      end

    content_tag(:div, class: "card-header") do
      concat heading
      if subtext.present?
        concat content_tag(:small, subtext, class: "text-muted")
      end
    end
  end

  def card_field_set_tag(text, &block)
    field_set_tag content_tag(:span, text, class: "h6 text-muted text-uppercase"), &block
  end
end
