Sha256: 2e2622cd55808d5c8fa59b4881ed64051b1c3b951ff0dcac0dcf413f4db22b1e

Contents?: true

Size: 852 Bytes

Versions: 7

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders the button to follow the given resource.
  class FollowButtonCell < Decidim::ViewModel
    include LayoutHelper

    def show
      return if model == current_user
      render
    end

    private

    def current_user
      context[:current_user]
    end

    def button_classes
      return "card__button secondary text-uppercase follow-button mb-none" if inline?
      "button secondary hollow expanded small button--icon follow-button"
    end

    def icon_options
      return { class: "icon--small" } if inline?
      {}
    end

    # Checks whether the button will be shown inline or not. Inline buttons will
    # not have any border, and the icon will be small. This is mostly intended
    # to be used from cards.
    def inline?
      options[:inline]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.15.2 app/cells/decidim/follow_button_cell.rb
decidim-core-0.15.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.15.0 app/cells/decidim/follow_button_cell.rb
decidim-core-0.14.4 app/cells/decidim/follow_button_cell.rb
decidim-core-0.14.3 app/cells/decidim/follow_button_cell.rb
decidim-core-0.14.2 app/cells/decidim/follow_button_cell.rb
decidim-core-0.14.1 app/cells/decidim/follow_button_cell.rb