Sha256: 69d3b0259b92ec2aa29f9c570ebf66bab2e35c03e638b9b3003df42840ea0682

Contents?: true

Size: 912 Bytes

Versions: 7

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders a generic button.
  class ButtonCell < Decidim::ViewModel
    include LayoutHelper
    include IconHelper
    include Decidim::SanitizeHelper
    include Decidim::ResourceHelper

    DEFAULT_ATTRIBUTES = {
      button_classes: "button button__sm button__transparent-secondary",
      text_classes: nil,
      icon_classes: nil,
      method: nil,
      remote: false,
      html_options: {}
    }.freeze

    def show
      render
    end

    def button_attributes
      @button_attributes ||= model || {}
    end

    private

    DEFAULT_ATTRIBUTES.each do |key, default_classes|
      define_method(key) do
        options[key] || default_classes
      end
    end

    def path
      button_attributes[:path]
    end

    def text
      button_attributes[:text]
    end

    def icon_name
      button_attributes[:icon]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/button_cell.rb
decidim-core-0.28.3 app/cells/decidim/button_cell.rb
decidim-core-0.28.2 app/cells/decidim/button_cell.rb
decidim-core-0.28.1 app/cells/decidim/button_cell.rb
decidim-core-0.28.0 app/cells/decidim/button_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/button_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/button_cell.rb