Sha256: 3a1b224c968381e4ff6e6353144b4a6473ad74079bbd9ad5129798ab2c71ac86

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

module Plutonium
  module UI
    class PageHeader < Plutonium::UI::Component::Base
      def initialize(title:, description:, actions:)
        @title = title
        @description = description
        @actions = actions || []
      end

      def view_template
        div(class: "sm:flex sm:space-y-0 sm:space-x-4 sm:flex-row items-center justify-between space-y-3 mb-6") {
          div {
            phlexi_render(@title) {
              render_title @title
            }

            phlexi_render(@description) {
              render_description @description
            }
          }
          div(class: "flex flex-row space-x-2") {
            render_actions
          }
        }
      end

      private

      def render_title(title)
        h2(class: "mb-2 text-3xl font-extrabold leading-none tracking-tight text-gray-900 md:text-4xl dark:text-white") {
          title
        }
      end

      def render_description(description)
        p(class: "text-gray-500 dark:text-gray-400") {
          description
        }
      end

      def render_actions
        @actions.each do |action|
          url = resource_url_for(resource_record? || resource_class, *action.route_options.url_args, **action.route_options.url_options)
          ActionButton(action, url:)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
plutonium-0.19.2 lib/plutonium/ui/page_header.rb
plutonium-0.19.1 lib/plutonium/ui/page_header.rb
plutonium-0.19.0 lib/plutonium/ui/page_header.rb
plutonium-0.18.8 lib/plutonium/ui/page_header.rb
plutonium-0.18.7 lib/plutonium/ui/page_header.rb
plutonium-0.18.6 lib/plutonium/ui/page_header.rb