Sha256: 17a033700673c9e3c93683d5ed7490e41d1890abeb18e5179b36175b70e70c33

Contents?: true

Size: 1.92 KB

Versions: 7

Compression:

Stored size: 1.92 KB

Contents

require 'ui_bibz/ui/core/cards/components/block/card_block_text'
require 'ui_bibz/ui/core/cards/components/block/card_block_title'
require 'ui_bibz/ui/core/cards/components/block/card_block_link'
module UiBibz::Ui::Core::Cards::Components

  # Create a card block
  #
  # ==== Attributes
  #
  # * +content+ - Content of element
  # * +options+ - Options of element
  # * +html_options+ - Html Options of element
  #
  # ==== Options
  #
  # You can add HTML attributes using the +html_options+.
  # You can pass arguments in options attribute:
  #
  # ==== Signatures
  #
  #   UiBibz::Ui::Core::Cards::CardBlock.new(content, options = nil, html_options = nil)
  #
  #   UiBibz::Ui::Core::Cards::CardBlock.new(options = nil, html_options = nil) do
  #     content
  #   end
  #
  # ==== Examples
  #
  #   UiBibz::Ui::Core::Cards::CardBlock.new.render
  #
  #   UiBibz::Ui::Core::Cards::CardBlock.new do
  #     'Exemple'
  #   end.render
  #
  class CardBlock < UiBibz::Ui::Core::Component

    # See UiBibz::Ui::Core::Component.initialize
    def initialize content = nil, options = nil, html_options = nil, &block
      super
      @items = [@content]
    end

    # Render html tag
    def render
      content_tag :div, @items.join.html_safe, html_options
    end

    def title content = nil, options = nil, html_options = nil, &block
      @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockTitle.new(content, options, html_options, &block).render
    end

    def link content = nil, options = nil, html_options = nil, &block
      @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockLink.new(content, options, html_options, &block).render
    end

    def text content = nil, options = nil, html_options = nil, &block
      @items << UiBibz::Ui::Core::Cards::Components::Block::CardBlockText.new(content, options, html_options, &block).render
    end

  private

    def component_html_classes
      "card-block"
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ui_bibz-2.0.0.alpha32 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha31 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha30 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha29 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha28 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha27 lib/ui_bibz/ui/core/cards/components/card_block.rb
ui_bibz-2.0.0.alpha26 lib/ui_bibz/ui/core/cards/components/card_block.rb