Sha256: 4e83f59374b583012a4b8abcfe3160ca0dfa36e9f43443a8f7721fea07536dfa

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Satis
  module Card
    class Component < Satis::ApplicationComponent
      renders_many :actions
      renders_many :tabs, Tab::Component
      renders_one :footer

      attr_reader :icon, :title, :description, :menu, :content_padding, :header_background_color, :initial_actions, :key, :custom_tabs_link_html

      def initialize(icon: nil,
                     title: nil,
                     description: nil,
                     menu: nil,
                     content_padding: true,
                     header_background_color: {
                       dark: 'bg-gray-800', light: 'bg-white'
                     },
                     actions: [],
                     key: nil)
        super
        @title = title
        @title = @title.reject(&:blank?).compact.join(' ') if @title.is_a?(Array)
        @description = description
        @icon = icon
        @menu = menu
        @content_padding = content_padding
        @header_background_color = header_background_color
        @initial_actions = actions
        @key = key
      end

      def custom_tabs_link(&block)
        return unless block_given?
        @custom_tabs_link_html = block.call.html_safe
      end

      def tabs?
        tabs.present?
      end

      def header?
        icon.present? || title.present? || description.present? || menu
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
satis-1.0.75 app/components/satis/card/component.rb
satis-1.0.74 app/components/satis/card/component.rb
satis-1.0.70 app/components/satis/card/component.rb
satis-1.0.69 app/components/satis/card/component.rb
satis-1.0.68 app/components/satis/card/component.rb