Sha256: d2547e6ceee48dd069d0d54998f2217c2cd4bf71dbdc7cabca2b7c299169086e

Contents?: true

Size: 916 Bytes

Versions: 7

Compression:

Stored size: 916 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 decidim
      Decidim::Core::Engine.routes.url_helpers
    end

    def button_classes
      return "card__button secondary text-uppercase follow-button" 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.13.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.12.2 app/cells/decidim/follow_button_cell.rb
decidim-core-0.13.0 app/cells/decidim/follow_button_cell.rb
decidim-core-0.12.1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.13.0.pre1 app/cells/decidim/follow_button_cell.rb
decidim-core-0.12.0 app/cells/decidim/follow_button_cell.rb
decidim-core-0.12.0.pre app/cells/decidim/follow_button_cell.rb