Sha256: 0a0cea664cd50ea32fc99dc50df1adbe8902b46f39cbc6429ff5b2f07829b39b

Contents?: true

Size: 1.18 KB

Versions: 24

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module PandaCms
  module Admin
    class HeadingComponent < ViewComponent::Base
      renders_many :buttons, PandaCms::Admin::ButtonComponent

      def initialize(text:, level: 2, icon: "", additional_styles: "")
        @text = text
        @level = level
        @icon = icon
        @additional_styles = additional_styles
        @additional_styles = @additional_styles.split(" ") if @additional_styles.is_a?(String)
      end

      def call
        output = ""
        output += content_tag(:div, @text, class: "grow")

        if buttons?
          output += content_tag(:span, class: "actions flex gap-x-2") do
            safe_join(buttons, "")
          end
        end

        output = output.html_safe

        if @level == 1
          content_tag(:h1, output, class: ["flex", "text-2xl", "font-medium", "text-gray-900", @additional_styles])
        elsif @level == 2
          content_tag(:h2, output, class: ["flex", "text-xl", "font-medium", "text-gray-800", @additional_styles])
        elsif @level == 3
          content_tag(:h3, output, class: ["flex", "text-xl", "font-bold", "text-gray-700", @additional_styles])
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
panda_cms-0.3.15 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.14 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.13 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.12 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.11 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.10 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.9 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.8 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.7 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.6 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.5 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.4 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.3 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.2 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.1 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.3.0 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.2.7 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.2.6 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.2.5 app/components/panda_cms/admin/heading_component.rb
panda_cms-0.2.4 app/components/panda_cms/admin/heading_component.rb